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

Update Bucket Interface to use "in parallel" and resolve promise once #109

Merged
merged 7 commits into from
Oct 10, 2023
Merged
Changes from 4 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
38 changes: 24 additions & 14 deletions index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -313,19 +313,21 @@ The <dfn method for="StorageBucket">persist()</dfn> method steps are:

1. Let |p| be [=a new promise=].

1. Run the following steps [=in parallel=]:
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, set |persisted| to false.

1. Otherwise, [=/resolve=] |p| with false.
1. [=Queue a storage task=] to [=/resolve=] |p| with |persisted|
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I was wondering why we use [=/resolve=] (with slash) but [=reject=] (without slash). I think both work in this case, but we should choose one and be consistent.

https://speced.github.io/bikeshed/#autolink-inside

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point, updated for the bucket interface. I'll follow-up for the bucket manager


1. Return |p|.

Expand All @@ -339,13 +341,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 @@ -386,7 +388,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 @@ -454,9 +456,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=] and [=queue a storage task=] to [=/resolve=] |p|.
1. Otherwise, set |bucket|'s [=StorageBucket/expiration time=] to |expires| milliseconds after the [=Unix epoch=].

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

1. Return |p|.

Expand All @@ -470,9 +476,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