Skip to content

Commit

Permalink
Enhance IDB, CacheStorage algorithms. (#54)
Browse files Browse the repository at this point in the history
* Enhance IDB, CacheStorage algorithms.

Also distinguish between the conceptual bottle and the StorageBottle object in the
open() definition.

* algo tags

Co-authored-by: Evan Stade <estade@chromium.org>
  • Loading branch information
evanstade and Evan Stade authored Jan 4, 2023
1 parent 0f8f120 commit 3d1b4d2
Showing 1 changed file with 44 additions and 6 deletions.
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=].

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.
<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|.

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

0 comments on commit 3d1b4d2

Please sign in to comment.