Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance IDB, CacheStorage algorithms. #54

Merged
merged 2 commits into from
Jan 4, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Enhance IDB, CacheStorage algorithms.
Also distinguish between the conceptual bottle and the StorageBottle object in the
open() definition.
Evan Stade committed Jan 4, 2023
commit 2cb97dc9178080f3fb7b7127fff6a47466f582e9
42 changes: 36 additions & 6 deletions index.bs
Original file line number Diff line number Diff line change
@@ -124,7 +124,11 @@ dictionary StorageBucketOptions {

1. Set |bucket|'s [=bucket expiration|expiration=] to |expires|.

1. Return |bucket|.
1. Let |storageBucket| be a new {{StorageBucket}}.

1. Set |storageBucket|'s [=/storage bucket=] to |bucket|.

1. Return |storageBucket|.

</div>

@@ -175,6 +179,9 @@ To <dfn>delete a bucket</dfn> for a |storageKey| given a bucket |name|, run the

</div>

Issue: [[Storage]] needs to define bucket removal/clearing. The bucket needs to be internally marked as
removed and subsequent attempts to access it (through associated storage endpoints) should fail.

<h3 id="storage-bucket-keys">Enumerating buckets</h3>

<div algorithm>
@@ -227,6 +234,8 @@ interface StorageBucket {
};
</xmp>

A {{StorageBucket}} has an associated [=/storage bucket=].

A {{StorageBucket}} has a <dfn>bucket quota</dfn>, a number-or-null, initially null.
Specifies the upper limit of usage which can be used by the bucket. The user agent MAY further limit
the realized storage space.
@@ -250,8 +259,19 @@ The user agent MUST ignore the [=bucket durability=] for operations that otherwi

<h3 id="storage-bucket-indexeddb">Using Indexed Database</h3>

A {{StorageBucket}} has an {{IDBFactory}} object. [[IndexedDB]] objects created through
{{StorageBucket/indexedDB}} are associated with the bucket.
Issue: {{IDBFactory}} methods need to take a storage bottle map rather than a storageKey.

A {{StorageBucket}} has an {{IDBFactory}} object. {{StorageBucket/indexedDB}} getter steps are:

1. Let |bucket| be [=this=]'s [=/storage bucket=].
evanstade marked this conversation as resolved.
Show resolved Hide resolved

1. Let |bottle map| be the result of [=obtain a local storage bottle map=] with |bucket| and `"indexedDB"`.

1. Let |indexedDB| be an {{IDBFactory}} object.

1. Set the [=bottle map=] for |indexedDB| to |bottle map|.

1. Return |indexedDB|.

<div algorithm>

@@ -269,7 +289,17 @@ of an {{IDBTransaction}} |transaction|. To <dfn>calculate the effective <a spec=

<h3 id="storage-bucket-caches">Using CacheStorage</h3>

A {{StorageBucket}} has a {{CacheStorage}} object. [[service-workers#cache-objects]] objects created through {{StorageBucket/caches}} are associated with the bucket.
ayuishii marked this conversation as resolved.
Show resolved Hide resolved
A {{StorageBucket}} has a {{CacheStorage}} object. {{StorageBucket/caches}} getter steps are:

1. Let |bucket| be [=this=]'s [=/storage bucket=].

1. Let |bottle map| be the result of [=obtain a local storage bottle map=] with |bucket| and `"cacheStorage"`.

1. Let |cacheStorage| be a {{CacheStorage}} object.

1. Set the <a spec="service-workers">relevant name to cache map</a> for |cacheStorage| to |bottle map|.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if this should be [=obtain a local storage bottle map=] similar to indexedDB? relevant name to cache map looks like it might be keyed by cacheName within a bucket, and not a key for buckets.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm, I believe there is some confusion here because

  • a bucket has a "bottle map", i.e. map of bottle identifiers to bottles, mapping "cacheStorage" to a storage bottle for CacheStorage
  • a storage bottle has a map, used for:

A storage bottle’s map is where the actual data meant to be stored lives

The algorithm "obtain a local storage bottle map" refers to the (storage bottle)'s (map), rather than a (storage bucket)'s (bottle map).

Does this clear things up?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yes, somehow missed L302 😵 lgtm!


1. Return |cacheStorage|.

<h3 id="storage-bucket-getdirectory">Using an Origin Private File System</h3>

@@ -279,9 +309,9 @@ Issue: [[FS]] needs to define a helper to retrieve an OPFS given a bottle map.

<div algorithm>

The <dfn method for=StorageBucket>getDirectory()</dfn> steps for |bucket| are:
The <dfn method for=StorageBucket>getDirectory()</dfn> steps are:

1. Let |map| be the result of [=obtain a local storage bottle map=] with |bucket| and `"fileSystem"`.
1. Let |map| be the result of [=obtain a local storage bottle map=] with [=this=]'s [=/storage bucket=] and `"fileSystem"`.

1. Return the result of retrieving a [[FS#sandboxed-filesystem]] with |map|.