Skip to content

Commit 6d251ad

Browse files
authored
Add the ability for bottles to have a quota
And use this to port HTML's 5 MiB suggestion. See #95.
1 parent 3656181 commit 6d251ad

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

storage.bs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,19 @@ allow for different storage policies. And lastly, a <a>storage bucket</a> consis
138138
<h3 id=storage-endpoints>Storage endpoints</h3>
139139

140140
<p>A <dfn export>storage endpoint</dfn> is a <a lt="local storage">local</a> or
141-
<a>session storage</a> API that uses the infrastructure defined by this standard to keep track of
142-
its storage needs.
141+
<a>session storage</a> API that uses the infrastructure defined by this standard, most notably
142+
<a for=/>storage bottles</a>, to keep track of its storage needs.
143143

144144
<p>A <a>storage endpoint</a> has an <dfn for="storage endpoint">identifier</dfn>, which is a
145145
<a>storage identifier</a>.
146146

147147
<p>A <a>storage endpoint</a> also has <dfn for="storage endpoint">types</dfn>, which is a
148148
<a for=/>set</a> of <a>storage types</a>.
149149

150+
<p>A <a>storage endpoint</a> also has a <dfn for="storage endpoint">quota</dfn>, which is null or a
151+
number representing a recommended <a for="storage bottle">quota</a> (in bytes) for all
152+
<a for=/>storage bottles</a> corresponding to this <a>storage endpoint</a>.
153+
150154
<p>A <dfn>storage identifier</dfn> is an <a for=/>ASCII string</a>.
151155

152156
<p>A <dfn>storage type</dfn> is "<code>local</code>" or "<code>session</code>".
@@ -160,23 +164,29 @@ defined by the following table:
160164

161165
<table>
162166
<tr>
163-
<th><a>Storage identifier</a>
164-
<th><a>Storage types</a>
167+
<th><a for="storage endpoint">Identifier</a>
168+
<th><a for="storage endpoint">Type</a>
169+
<th><a for="storage endpoint">Quota</a>
165170
<tr>
166171
<td>"<code>caches</code>"
167172
<td>« "<code>local</code>" »
173+
<td>null
168174
<tr>
169175
<td>"<code>indexedDB</code>"
170176
<td>« "<code>local</code>" »
177+
<td>null
171178
<tr>
172179
<td>"<code>localStorage</code>"
173180
<td>« "<code>local</code>" »
181+
<td>5 &times; 2<sup>20</sup> (i.e., 5 mebibytes)
174182
<tr>
175183
<td>"<code>serviceWorkerRegistrations</code>"
176184
<td>« "<code>local</code>" »
185+
<td>null
177186
<tr>
178187
<td>"<code>sessionStorage</code>"
179188
<td>« "<code>session</code>" »
189+
<td>5 &times; 2<sup>20</sup> (i.e., 5 mebibytes)
180190
</table>
181191

182192
<p class=note>As mentioned, standards can use these <a>storage identifiers</a> with
@@ -300,7 +310,8 @@ steps:
300310
<li><p><a for=set>For each</a> <var>endpoint</var> of <a>registered storage endpoints</a> whose
301311
<a for="storage endpoint">types</a> <a for=set>contain</a> <var>type</var>, set <var>bucket</var>'s
302312
<a>bottle map</a>[<var>endpoint</var>'s <a for="storage endpoint">identifier</a>] to a new
303-
<a>storage bottle</a>.
313+
<a>storage bottle</a> whose <a for="storage bottle">quota</a> is <var>endpoint</var>'s
314+
<a for="storage endpoint">quota</a>.
304315

305316
<li><p>Return <var>bucket</var>.
306317
</ol>
@@ -312,7 +323,10 @@ steps:
312323
<a>storage endpoint</a>. A <a>storage bottle</a> has a <dfn for="storage bottle">map</dfn>, which is
313324
initially an empty <a for=/>map</a>. A <a>storage bottle</a> also has a
314325
<dfn for="storage bottle">proxy map reference set</dfn>, which is initially an empty
315-
<a for=/>set</a>.
326+
<a for=/>set</a>. A <a>storage bottle</a> also has a <dfn for="storage bottle">quota</dfn>, which is
327+
null or a number representing a conservative estimate of the total amount of bytes it can hold. Null
328+
indicates the lack of a limit. <span class=note>It is still bound by the <a>storage quota</a> of its
329+
encompassing <a for=/>storage shelf</a>.
316330

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

429443
<p>The <dfn export>storage quota</dfn> of a <a>storage shelf</a> is a conservative estimate of the
430-
amount of bytes available to it. This amount should be less than the total available storage space
444+
total amount of bytes it can hold. This amount should be less than the total available storage space
431445
on the device to give users some wiggle room.
432446

433447
<p class=note>User agents are strongly encouraged to consider navigation frequency, recency of

0 commit comments

Comments
 (0)