Skip to content

Commit

Permalink
Update Bucket Interface to use "in parallel" and resolve promise once (
Browse files Browse the repository at this point in the history
…#109)

* Use "in parallel" and resolve once queue task one on bucket interface

* Fix build

* Address comments

* Use consistent wording

* Consistent formatting for resolve/reject on bucket interface

* Cleanup spaces

* More nits
  • Loading branch information
ayuishii authored Oct 10, 2023
1 parent 21a6caf commit 9936006
Showing 1 changed file with 23 additions and 13 deletions.
36 changes: 23 additions & 13 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -308,17 +308,19 @@ The <dfn method for="StorageBucket">persist()</dfn> method steps are:

1. Run the following steps [=in parallel=]:

1. If |bucket|'s [=storage bucket/removed=] flag is true, [=reject=] |p| with {{InvalidStateError}}.
1. If |bucket|'s [=storage bucket/removed=] flag is true, then [=queue a storage task=] to [=reject=] |p| with an {{InvalidStateError}}.

1. If |bucket|'s [=bucket mode=] is `"persistent"`, [=/resolve=] |p| with true.
1. Let |persisted| be true if |bucket|'s [=bucket mode=] is `"persistent"`.

1. Otherwise,

1. Let |permission| be the result of [=getting the current permission state=] with `"persistent-storage"` and |environment|.

1. If |permission| is "{{PermissionState/granted}}", then set |bucket|'s [=bucket mode=] to `"persistent"` and [=queue a storage task=] to [=/resolve=] |p| with true.
1. If |permission| is "{{PermissionState/granted}}", then set |bucket|'s [=bucket mode=] to `"persistent"` and set |persisted| to true.

1. Otherwise, [=/resolve=] |p| with false.
1. Otherwise, set |persisted| to false.

1. [=Queue a storage task=] to [=resolve=] |p| with |persisted|.

1. Return |p|.

Expand All @@ -332,13 +334,13 @@ The <dfn method for="StorageBucket">persisted()</dfn> method steps are:

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

1. If |bucket|'s [=storage bucket/removed=] flag is true, then [=queue a storage task=] to [=reject=] |p| with an {{InvalidStateError}}.
1. Otherwise, run these steps [=in parallel=]:

1. Otherwise,
1. If |bucket|'s [=storage bucket/removed=] flag is true, then [=queue a storage task=] to [=reject=] |p| with an {{InvalidStateError}}.

1. If |bucket|'s [=bucket mode=] is `"persistent"`, then [=queue a storage task=] to [=/resolve=] |p| with true.
1. Let |persistent| be true if |bucket|'s [=bucket mode=] is `"persistent"`, otherwise false.

1. Otherwise, [=queue a storage task=] to [=/resolve=] |p| with false.
1. [=Queue a storage task=] to [=resolve=] |p| with |persistent|.

1. Return |p|.

Expand Down Expand Up @@ -379,7 +381,7 @@ The <dfn method for="StorageBucket">estimate()</dfn> method steps are:

1. Let |dictionary| be a new {{StorageEstimate}} dictionary whose {{StorageEstimate/usage}} member is |usage| and {{StorageEstimate/quota}} member is |quota|.

1. [=/Resolve=] |p| with |dictionary|.
1. [=Queue a storage task=] to [=resolve=] |p| with |dictionary|.

1. Return |p|.

Expand Down Expand Up @@ -410,9 +412,13 @@ The <dfn method for="StorageBucket">setExpires(|expires|)</dfn> method steps are

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

1. If |bucket|'s [=storage bucket/removed=] flag is true, [=queue a storage task=] to [=reject=] |p| with an {{InvalidStateError}}.
1. Otherwise, run these steps [=in parallel=]:

1. If |bucket|'s [=storage bucket/removed=] flag is true, then [=queue a storage task=] to [=reject=] |p| with an {{InvalidStateError}}.

1. Otherwise, set |bucket|'s [=StorageBucket/expiration time=] to |expires| milliseconds after the [=Unix epoch=].

1. Otherwise, set |bucket|'s [=StorageBucket/expiration time=] to |expires| milliseconds after the [=Unix epoch=] and [=queue a storage task=] to [=/resolve=] |p|.
1. [=Queue a storage task=] to [=resolve=] |p|.

1. Return |p|.

Expand All @@ -426,9 +432,13 @@ The <dfn method for="StorageBucket">expires()</dfn> method steps are:

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

1. If |bucket|'s [=storage bucket/removed=] flag is true, [=queue a storage task=] to [=reject=] |p| with an {{InvalidStateError}}.
1. Otherwise, run these steps [=in parallel=]:

1. If |bucket|'s [=storage bucket/removed=] flag is true, then [=queue a storage task=] to [=reject=] |p| with an {{InvalidStateError}}.

1. Otherwise, let |expiration| be |bucket|'s [=StorageBucket/expiration time=].

1. Otherwise, [=queue a storage task=] to [=/resolve=] |p| with |bucket|'s [=StorageBucket/expiration time=].
1. [=Queue a storage task=] to [=resolve=] |p| with |expiration|.

1. Return |p|.

Expand Down

0 comments on commit 9936006

Please sign in to comment.