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 all commits
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
50 changes: 44 additions & 6 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -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>

Expand Down Expand Up @@ -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>
Expand Down Expand Up @@ -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.
Expand All @@ -250,8 +259,23 @@ 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.

<div algorithm>

A {{StorageBucket}} has an {{IDBFactory}} object. The <dfn attribute for=StorageBucket>indexedDB</dfn> 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>

<div algorithm>

Expand All @@ -269,7 +293,21 @@ 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
<div algorithm>

A {{StorageBucket}} has a {{CacheStorage}} object. The <dfn attribute for=StorageBucket>caches</dfn> 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|.

</div>

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

Expand All @@ -279,9 +317,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|.

Expand Down