From 993600681652046bec225105d95acb73bf3367eb Mon Sep 17 00:00:00 2001 From: Ayu Ishii <48255136+ayuishii@users.noreply.github.com> Date: Tue, 10 Oct 2023 15:47:55 -0700 Subject: [PATCH] Update Bucket Interface to use "in parallel" and resolve promise once (#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 --- index.bs | 36 +++++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 13 deletions(-) diff --git a/index.bs b/index.bs index b9756ea..231e683 100644 --- a/index.bs +++ b/index.bs @@ -308,17 +308,19 @@ The persist() 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|. @@ -332,13 +334,13 @@ The persisted() 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|. @@ -379,7 +381,7 @@ The estimate() 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|. @@ -410,9 +412,13 @@ The setExpires(|expires|) 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|. @@ -426,9 +432,13 @@ The expires() 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|.