From 11807445228c40e007b05ad2c8a66ce4a950b82f Mon Sep 17 00:00:00 2001 From: Austin Sullivan Date: Mon, 16 Jan 2023 02:42:19 -0500 Subject: [PATCH] Introduce a storage task source and queue a storage task Also make use of them internally. Additionally cross-reference more and adopt modern practices. Helps with https://github.com/whatwg/fs/issues/3. Fixes #89. Co-authored-by: Anne van Kesteren --- storage.bs | 57 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/storage.bs b/storage.bs index 9249b0d..ea7338f 100644 --- a/storage.bs +++ b/storage.bs @@ -14,6 +14,10 @@ urlPrefix: https://tc39.github.io/ecma262/; spec: ECMASCRIPT text: agent cluster; url: #sec-agent-clusters; type: dfn + +

Introduction

@@ -466,6 +470,19 @@ is needed for issue #4 Storage Access API. +

Storage task source

+ +

The storage task source is a task source to be used +for all tasks related to a storage endpoint. In particular those that relate to +a storage endpoint's quota. + +

+

To queue a storage task given a global object global +and a series of steps steps, queue a global task on the storage task source +with global and steps. +

+ +

Persistence permission

@@ -602,15 +619,19 @@ dictionary StorageEstimate { }; +

The persisted() method steps are:

    -
  1. Let promise be a new promise. +

  2. Let promise be a new promise. + +

  3. Let global be this's relevant global object.

  4. Let shelf be the result of running obtain a local storage shelf with this's relevant settings object. -

  5. If shelf is failure, then reject promise with a {{TypeError}}. +

  6. If shelf is failure, then reject promise with a + {{TypeError}}.

  7. Otherwise, run these steps in parallel: @@ -623,21 +644,27 @@ dictionary StorageEstimate {

    It will be false when there's an internal error. -

  8. Queue a task to resolve promise with persisted. +

  9. Queue a storage task with global to resolve + promise with persisted.

  • Return promise. +

  • +

    The persist() method steps are:

      -
    1. Let promise be a new promise. +

    2. Let promise be a new promise. + +

    3. Let global be this's relevant global object.

    4. Let shelf be the result of running obtain a local storage shelf with this's relevant settings object. -

    5. If shelf is failure, then reject promise with a {{TypeError}}. +

    6. If shelf is failure, then reject promise with a + {{TypeError}}.

    7. Otherwise, run these steps in parallel: @@ -670,21 +697,27 @@ dictionary StorageEstimate {

    8. If there was no internal error, then set persisted to true.

    -
  • Queue a task to resolve promise with persisted. +

  • Queue a storage task with global to resolve + promise with persisted.

  • Return promise. +

  • +

    The estimate() method steps are:

      -
    1. Let promise be a new promise. +

    2. Let promise be a new promise. + +

    3. Let global be this's relevant global object.

    4. Let shelf be the result of running obtain a local storage shelf with this's relevant settings object. -

    5. If shelf is failure, then reject promise with a {{TypeError}}. +

    6. If shelf is failure, then reject promise with a + {{TypeError}}.

    7. Otherwise, run these steps in parallel: @@ -699,17 +732,20 @@ dictionary StorageEstimate {

    8. If there was an internal error while obtaining usage and quota, then - queue a task to reject promise with a {{TypeError}}. + queue a storage task with global to reject promise + with a {{TypeError}}.

      Internal errors are supposed to be extremely rare and indicate some kind of low-level platform or hardware fault. However, at the scale of the web with the diversity of implementation and platforms, the unexpected does occur. -

    9. Otherwise, queue a task to resolve promise with dictionary. +

    10. Otherwise, queue a storage task with global to resolve + promise with dictionary.

  • Return promise. +

  • @@ -722,6 +758,7 @@ Alex Russell, Ali Alabbas, Andrew Sutherland, Andrew Williams, +Austin Sullivan, Ben Kelly, Ben Turner, Dale Harvey,