Skip to content

Commit

Permalink
Add UsageDetails dictionary.
Browse files Browse the repository at this point in the history
    squash 47187f6 Address style nits from domenic.
    squash 0fd3b44 Explicitly define each storage system's usage.
  • Loading branch information
Jarryd Goodman committed Jun 3, 2019
1 parent 725373f commit 657ce68
Showing 1 changed file with 56 additions and 4 deletions.
60 changes: 56 additions & 4 deletions storage.bs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ these APIs by defining:
<ul class=brief>
<li>A bucket, the primitive these APIs store their data in
<li>A way of making that bucket persistent
<li>A way of getting usage and quota estimates for an <a for=/>origin</a>
<li>A way of getting usage, quota, and per-system usage estimates for an <a for=/>origin</a>
</ul>

<p>Traditionally, as the user runs out of storage space on their device, the data stored with these
Expand Down Expand Up @@ -178,7 +178,21 @@ larger <a>site storage quota</a>. Factors such as navigation frequency, recency
bookmarking, and <a href="#persistence">permission</a> for {{"persistent-storage"}} can be used as
indications of "popularity".

The <dfn export>application cache site storage usage</dfn> for an <a for=/>origin</a>
<var>origin</var> is a rough estimate of the amount of bytes used in <a>Application Cache</a>
in <var>origin</var>'s <a>site storage unit</a>. [[!HTML]]

The <dfn export>caches site storage usage</dfn> for an <a for=/>origin</a>
<var>origin</var> is a rough estimate of the amount of bytes used in <a attribute>caches</a> API
in <var>origin</var>'s <a>site storage unit</a>. [[!SERVICE-WORKERS]]

The <dfn export>indexedDB site storage usage</dfn> for an <a for=/>origin</a>
<var>origin</var> is a rough estimate of the amount of bytes used in IndexedDB
in <var>origin</var>'s <a>site storage unit</a>. [[!IndexedDB]]

The <dfn export>service worker registration site storage usage</dfn> for an
<a for=/>origin</a> <var>origin</var> is a rough estimate of the amount of bytes
used in service worker registrations in <var>origin</var>'s <a>site storage unit</a>. [[!SERVICE-WORKERS]]

<h2 id=ui-guidelines>User Interface Guidelines</h2>

Expand Down Expand Up @@ -234,7 +248,16 @@ interface StorageManager {
dictionary StorageEstimate {
unsigned long long usage;
unsigned long long quota;
StorageUsageDetails usageDetails;
};

dictionary StorageUsageDetails {
unsigned long long applicationCache;
unsigned long long caches;
unsigned long long indexedDB;
unsigned long long serviceWorkerRegistrations;
};

</pre>

The <dfn method for=StorageManager><code>persisted()</code></dfn> method, when invoked, must run
Expand Down Expand Up @@ -331,11 +354,40 @@ must run these steps:

<li><p>Let <var>quota</var> be <a>site storage quota</a> for <var>origin</var>.

<li><p>Let <var>dictionary</var> be a new {{StorageEstimate}} dictionary whose {{usage}} member
is <var>usage</var> and {{quota}} member is <var>quota</var>.
<li><p>Let <var>applicationCache</var> be <a>application cache site storage usage</a>
for <var>origin</var>.

<li><p>Let <var>indexedDB</var> be <a>indexedDB site storage usage</a> for <var>origin</var>.

<li><p>Let <var>caches</var> be <a>caches site storage usage</a> for <var>origin</var>.

<li><p>Let <var>serviceWorkerRegistrations</var> be <a>service worker registration
site storage usage</a> for <var>origin</var>.

<li><p>Let <var>usageDetails</var> be a new {{StorageUsageDetails}} dictionary.

<li><p>If <var>applicationCache</var> is greater than 0, set the
{{StorageUsageDetails/applicationCache}} member of <var>usageDetails</var> to
<var>applicationCache</var>.

<li><p>If <var>indexedDB</var> is greater than 0, set the
{{StorageUsageDetails/indexedDB}} member of <var>usageDetails</var> to
<var>indexedDB</var>.

<li><p>If <var>caches</var> is greater than 0, set the
{{StorageUsageDetails/caches}} member of <var>usageDetails</var> to
<var>caches</var>.

<li><p>If <var>serviceWorkerRegistrations</var> is greater than 0, set the
{{StorageUsageDetails/serviceWorkerRegistrations}} member of <var>usageDetails</var> to
<var>serviceWorkerRegistrations</var>.

<li><p>Let <var>dictionary</var> be a new {{StorageEstimate}} dictionary whose {{StorageEstimate/usage}} member
is <var>usage</var>, {{StorageEstimate/quota}} member is <var>quota</var> and {{StorageEstimate/usageDetails}}
member is <var>usageDetails</var>.

<li>
<p>If there was an internal error while obtaining <var>usage</var> and <var>quota</var>, then
<p>If there was an internal error while obtaining any of the above, then
<a>queue a task</a> to reject <var>promise</var> with a {{TypeError}}.

<p class=note>Internal errors are supposed to be extremely rare and indicate some kind of
Expand Down

0 comments on commit 657ce68

Please sign in to comment.