From f74aea380ecf98bb930221519e850dd72e53185e Mon Sep 17 00:00:00 2001 From: Jarryd Goodman Date: Mon, 22 Apr 2019 14:07:11 -0700 Subject: [PATCH] Add UsageDetails dictionary. squash 47187f6 Address style nits from domenic. squash 0fd3b44 Explicitly define each storage system's usage. --- storage.bs | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 4 deletions(-) diff --git a/storage.bs b/storage.bs index 79497f6..7ed13bf 100644 --- a/storage.bs +++ b/storage.bs @@ -18,7 +18,7 @@ these APIs by defining:

Traditionally, as the user runs out of storage space on their device, the data stored with these @@ -178,7 +178,27 @@ larger site storage quota. Factors such as navigation frequency, recency bookmarking, and permission for {{"persistent-storage"}} can be used as indications of "popularity". +The application cache site storage usage for an origin +origin is a rough estimate of the amount of bytes used in Application Cache +in origin's site storage unit. Application Cache can contain cross-origin +opaque responses, thus it is important to obfuscate the size for security reasons. The +solution for this is to artificially pad the size of cross-origin responses (see [[#padding]]). +[[!HTML]] +The caches site storage usage for an origin +origin is a rough estimate of the amount of bytes used in {{CacheStorage}} API +in origin's site storage unit. Caches can contain cross-origin +opaque responses, thus it is important to obfuscate the size for security reasons. The +solution for this is to artificially pad the size of cross-origin responses (see [[#padding]]). +[[!SERVICE-WORKERS]] + +The indexedDB site storage usage for an origin +origin is a rough estimate of the amount of bytes used in IndexedDB +in origin's site storage unit. [[!IndexedDB]] + +The service worker registration site storage usage for an +origin origin is a rough estimate of the amount of bytes +used in service worker registrations in origin's site storage unit. [[!SERVICE-WORKERS]]

User Interface Guidelines

@@ -234,7 +254,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; }; + The persisted() method, when invoked, must run @@ -331,11 +360,40 @@ must run these steps:
  • Let quota be site storage quota for origin. -

  • Let dictionary be a new {{StorageEstimate}} dictionary whose {{usage}} member - is usage and {{quota}} member is quota. +

  • Let applicationCache be application cache site storage usage + for origin. + +

  • Let indexedDB be indexedDB site storage usage for origin. + +

  • Let caches be caches site storage usage for origin. + +

  • Let serviceWorkerRegistrations be service worker registration + site storage usage for origin. + +

  • Let usageDetails be a new {{StorageUsageDetails}} dictionary. + +

  • If applicationCache is greater than 0, set the + {{StorageUsageDetails/applicationCache}} member of usageDetails to + applicationCache. + +

  • If indexedDB is greater than 0, set the + {{StorageUsageDetails/indexedDB}} member of usageDetails to + indexedDB. + +

  • If caches is greater than 0, set the + {{StorageUsageDetails/caches}} member of usageDetails to + caches. + +

  • If serviceWorkerRegistrations is greater than 0, set the + {{StorageUsageDetails/serviceWorkerRegistrations}} member of usageDetails to + serviceWorkerRegistrations. + +

  • Let dictionary be a new {{StorageEstimate}} dictionary whose {{StorageEstimate/usage}} member + is usage, {{StorageEstimate/quota}} member is quota and {{StorageEstimate/usageDetails}} + member is usageDetails.

  • -

    If there was an internal error while obtaining usage and quota, then +

    If there was an internal error while obtaining any of the above, then queue a task to reject promise with a {{TypeError}}.

    Internal errors are supposed to be extremely rare and indicate some kind of @@ -348,7 +406,21 @@ must run these steps:

  • Return promise. +

    Padding Opaque Responses

    +Exposing the size of opaque responses can expose sensitive information. Because of this, it is +recommended that implementers obfuscate this size by artificially padding the size of opaque responses +when stored. An example set of steps might look like: +
      +
    1. Let response be a new {{Response}} from an opaque origin to + be stored in Application Cache or {{CacheStorage}}. +

    2. Let size be the size, in bytes, of response. +

    3. Let padding size be a randomly generated padding size, in bytes. + size. +

    4. Store padding size along with the size as metadata alongside + response in Application Cache or {{CacheStorage}}. +

    5. When queried about size, return the sum of size and padding size +

    Acknowledgments