whatwg / storage

Storage Standard
https://storage.spec.whatwg.org/
Other
126 stars 55 forks source link

Clarify storage infrastructure #86

Closed annevk closed 4 years ago

annevk commented 4 years ago

(See WHATWG Working Mode: Changes for more details.)


Preview | Diff

annevk commented 4 years ago

I think this now defines sufficient infrastructure to define storage and session storage APIs. It does not:

  1. Define a replacement operation that is needed for #4 and Clear-Site-Data.
  2. Change the keying away from origin (though it does acknowledge and isolate the problem to a single point).

A storage API would do something like:

Let map be the result of running obtain a storage bucket area map with environment, "storage", and "localStorage".

It can then use that map as it pleases, for instance in response to API calls.

(Writing this down I realize we should probably expose a separate "obtain a storage bucket area map" and a "obtain a session storage bucket area map" so APIs do not have to pass a storage type.)

It should also provide a solid basis for any kind of multiple storage bucket API though in the absence of one looks a bit complicated.

If this looks agreeable I would like, in order:

  1. Merge this.
  2. Work on defining the replacement operation and get that merged.
  3. Work on a PR for localStorage/sessionStorage to make use of this.
  4. Continue work on storage partitioning for improvements to the storage key.

I could wait with 1 until 2 is further along, but I would greatly appreciate detailed feedback on this PR first.

asutherland commented 4 years ago

I understand this to be the hierarchy:

  1. Storage Map
  2. Storage Unit
  3. Storage Bucket
  4. (Storage) Area

While the following sounds very silly, my brain has a lot of trouble with there being no inherent containment relationship among the terms in use and with 3 of the 4 being generic. What about something like:

  1. Storage Shed
  2. Storage Shelf
  3. Storage Bucket
  4. Storage Bottle
annevk commented 4 years ago

Note that now it's clearly prefixed, "storage box" would work as well. Nobody commented on that suggestion from https://github.com/whatwg/storage/issues/51#issuecomment-338227477.

pwnall commented 4 years ago

I'd like to express mild support for keeping bucket. It wasn't the first word that came to my mind, but it has grown on me.

Storage box is a bit of a mouthful. I worry that developers everywhere (web apps, browsers) will end up with variables named box instead of storageBox. I'd definitely use the word "boxes" when discussing this concept with my colleagues.

For better or worse, "bucket" is not used in other parts of the web platform (as far as I know). I think this will make everyone's (web developers, browser vendors) life easier when searching in code / docs. I expect that this concept will be a big deal, and deserves a unique name.

annevk commented 4 years ago

Fair. Any thoughts on @asutherland's suggested names? (And the remainder of the PR? 😊)

annevk commented 4 years ago

cc @youennf

annevk commented 4 years ago

I plan to address the remainder of @domenic's comments tomorrow as well as fully adopt @asutherland's fancy naming scheme. If you all have comments beyond those now would be a great time to make them. Thanks everyone!

annevk commented 4 years ago

I did the refactoring in batches, but reviewing https://whatpr.org/storage/86.html#model is probably easier. Note that apart from the Model section this also improved various aspects of the Storage Standard itself, by making it much more clear what exactly various aspects are talking about and when things might fail and such.