@@ -18,7 +18,7 @@ these APIs by defining:
1818<ul class=brief>
1919 <li> A bucket, the primitive these APIs store their data in
2020 <li> A way of making that bucket persistent
21- <li> A way of getting usage and quota estimates for an <a for=/>origin</a>
21+ <li> A way of getting usage, quota, and per-system usage estimates for an <a for=/>origin</a>
2222</ul>
2323
2424<p> Traditionally, as the user runs out of storage space on their device, the data stored with these
@@ -178,7 +178,27 @@ larger <a>site storage quota</a>. Factors such as navigation frequency, recency
178178bookmarking, and <a href="#persistence">permission</a> for {{"persistent-storage"}} can be used as
179179indications of "popularity".
180180
181+ The <dfn export>application cache site storage usage</dfn> for an <a for=/>origin</a>
182+ <var> origin</var> is a rough estimate of the amount of bytes used in <a>Application Cache</a>
183+ in <var> origin</var> 's <a>site storage unit</a> . <a>Application Cache</a> can contain cross-origin
184+ opaque responses, thus it is important to obfuscate the size for security reasons. The
185+ solution for this is to artificially pad the size of cross-origin responses (see [[#padding]] ).
186+ [[!HTML]]
181187
188+ The <dfn export>caches site storage usage</dfn> for an <a for=/>origin</a>
189+ <var> origin</var> is a rough estimate of the amount of bytes used in {{CacheStorage}} API
190+ in <var> origin</var> 's <a>site storage unit</a> . <a>Caches</a> can contain cross-origin
191+ opaque responses, thus it is important to obfuscate the size for security reasons. The
192+ solution for this is to artificially pad the size of cross-origin responses (see [[#padding]] ).
193+ [[!SERVICE-WORKERS]]
194+
195+ The <dfn export>indexedDB site storage usage</dfn> for an <a for=/>origin</a>
196+ <var> origin</var> is a rough estimate of the amount of bytes used in IndexedDB
197+ in <var> origin</var> 's <a>site storage unit</a> . [[!IndexedDB]]
198+
199+ The <dfn export>service worker registration site storage usage</dfn> for an
200+ <a for=/>origin</a> <var> origin</var> is a rough estimate of the amount of bytes
201+ used in service worker registrations in <var> origin</var> 's <a>site storage unit</a> . [[!SERVICE-WORKERS]]
182202
183203<h2 id=ui-guidelines>User Interface Guidelines</h2>
184204
@@ -234,7 +254,16 @@ interface StorageManager {
234254dictionary StorageEstimate {
235255 unsigned long long usage;
236256 unsigned long long quota;
257+ StorageUsageDetails usageDetails;
258+ };
259+
260+ dictionary StorageUsageDetails {
261+ unsigned long long applicationCache;
262+ unsigned long long caches;
263+ unsigned long long indexedDB;
264+ unsigned long long serviceWorkerRegistrations;
237265};
266+
238267</pre>
239268
240269The <dfn method for=StorageManager><code>persisted()</code></dfn> method, when invoked, must run
@@ -331,11 +360,40 @@ must run these steps:
331360
332361 <li><p> Let <var> quota</var> be <a>site storage quota</a> for <var> origin</var> .
333362
334- <li><p> Let <var> dictionary</var> be a new {{StorageEstimate}} dictionary whose {{usage}} member
335- is <var> usage</var> and {{quota}} member is <var> quota</var> .
363+ <li><p> Let <var> applicationCache</var> be <a>application cache site storage usage</a>
364+ for <var> origin</var> .
365+
366+ <li><p> Let <var> indexedDB</var> be <a>indexedDB site storage usage</a> for <var> origin</var> .
367+
368+ <li><p> Let <var> caches</var> be <a>caches site storage usage</a> for <var> origin</var> .
369+
370+ <li><p> Let <var> serviceWorkerRegistrations</var> be <a>service worker registration
371+ site storage usage</a> for <var> origin</var> .
372+
373+ <li><p> Let <var> usageDetails</var> be a new {{StorageUsageDetails}} dictionary.
374+
375+ <li><p> If <var> applicationCache</var> is greater than 0, set the
376+ {{StorageUsageDetails/applicationCache}} member of <var> usageDetails</var> to
377+ <var> applicationCache</var> .
378+
379+ <li><p> If <var> indexedDB</var> is greater than 0, set the
380+ {{StorageUsageDetails/indexedDB}} member of <var> usageDetails</var> to
381+ <var> indexedDB</var> .
382+
383+ <li><p> If <var> caches</var> is greater than 0, set the
384+ {{StorageUsageDetails/caches}} member of <var> usageDetails</var> to
385+ <var> caches</var> .
386+
387+ <li><p> If <var> serviceWorkerRegistrations</var> is greater than 0, set the
388+ {{StorageUsageDetails/serviceWorkerRegistrations}} member of <var> usageDetails</var> to
389+ <var> serviceWorkerRegistrations</var> .
390+
391+ <li><p> Let <var> dictionary</var> be a new {{StorageEstimate}} dictionary whose {{StorageEstimate/usage}} member
392+ is <var> usage</var> , {{StorageEstimate/quota}} member is <var> quota</var> and {{StorageEstimate/usageDetails}}
393+ member is <var> usageDetails</var> .
336394
337395 <li>
338- <p> If there was an internal error while obtaining <var> usage </var> and <var> quota </var> , then
396+ <p> If there was an internal error while obtaining any of the above , then
339397 <a>queue a task</a> to reject <var> promise</var> with a {{TypeError}} .
340398
341399 <p class=note> Internal errors are supposed to be extremely rare and indicate some kind of
@@ -348,7 +406,21 @@ must run these steps:
348406 <li><p> Return <var> promise</var> .
349407</ol>
350408
409+ <h2 id="padding">Padding Opaque Responses</h2>
410+ Exposing the size of opaque responses can expose sensitive information. Because of this, it is
411+ recommended that implementers obfuscate this size by artificially padding the size of opaque responses
412+ when stored. An example set of steps might look like:
351413
414+ <ol>
415+ <li><p> Let <var> response</var> be a new {{Response}} from an <a lt="opaque origin">opaque origin</a> to
416+ be stored in <a>Application Cache</a> or {{CacheStorage}} .
417+ <li><p> Let <var> size</var> be the size, in bytes, of <var> response</var> .
418+ <li><p> Let <var> padding size</var> be a randomly generated padding size, in bytes.
419+ size.
420+ <li><p> Store <var> padding size</var> along with the <var> size</var> as metadata alongside
421+ <var> response</var> in <a>Application Cache</a> or {{CacheStorage}} .
422+ <li><p> When queried about size, return the sum of <var> size</var> and <var> padding size</var>
423+ </ol>
352424
353425<h2 class=no-num id="acks">Acknowledgments</h2>
354426
0 commit comments