From 6d251adb3109aeeca23a760c48e9b0060eb95863 Mon Sep 17 00:00:00 2001 From: Anne van Kesteren Date: Fri, 5 Jun 2020 19:57:29 +0200 Subject: [PATCH] Add the ability for bottles to have a quota And use this to port HTML's 5 MiB suggestion. See #95. --- storage.bs | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/storage.bs b/storage.bs index 562ce28..3d42d31 100644 --- a/storage.bs +++ b/storage.bs @@ -138,8 +138,8 @@ allow for different storage policies. And lastly, a storage bucket consis

Storage endpoints

A storage endpoint is a local or -session storage API that uses the infrastructure defined by this standard to keep track of -its storage needs. +session storage API that uses the infrastructure defined by this standard, most notably +storage bottles, to keep track of its storage needs.

A storage endpoint has an identifier, which is a storage identifier. @@ -147,6 +147,10 @@ its storage needs.

A storage endpoint also has types, which is a set of storage types. +

A storage endpoint also has a quota, which is null or a +number representing a recommended quota (in bytes) for all +storage bottles corresponding to this storage endpoint. +

A storage identifier is an ASCII string.

A storage type is "local" or "session". @@ -160,23 +164,29 @@ defined by the following table: -
Storage identifier - Storage types + Identifier + Type + Quota
"caches" « "local" » + null
"indexedDB" « "local" » + null
"localStorage" « "local" » + 5 × 220 (i.e., 5 mebibytes)
"serviceWorkerRegistrations" « "local" » + null
"sessionStorage" « "session" » + 5 × 220 (i.e., 5 mebibytes)

As mentioned, standards can use these storage identifiers with @@ -300,7 +310,8 @@ steps:

  • For each endpoint of registered storage endpoints whose types contain type, set bucket's bottle map[endpoint's identifier] to a new - storage bottle. + storage bottle whose quota is endpoint's + quota.

  • Return bucket. @@ -312,7 +323,10 @@ steps: storage endpoint. A storage bottle has a map, which is initially an empty map. A storage bottle also has a proxy map reference set, which is initially an empty -set. +set. A storage bottle also has a quota, which is +null or a number representing a conservative estimate of the total amount of bytes it can hold. Null +indicates the lack of a limit. It is still bound by the storage quota of its +encompassing storage shelf.

    A storage bottle's map is where the actual data meant to be stored lives. User agents are expected to store this data, and make it available across agent @@ -427,7 +441,7 @@ deduplication, compression, and other techniques that obscure exactly how much b storage shelf uses.

    The storage quota of a storage shelf is a conservative estimate of the -amount of bytes available to it. This amount should be less than the total available storage space +total amount of bytes it can hold. This amount should be less than the total available storage space on the device to give users some wiggle room.

    User agents are strongly encouraged to consider navigation frequency, recency of