Quota API to query/request quota for offline storages (e.g. IndexedDB, FileSystem)

Hi,

Back then there has been a long thread [1] about how/whether we want to
allow web apps to request quotas for IndexedDB, or for any of the offline
storages (i.e. IndexedDB, FileSystem, appCache, localStorage and SQL DB).
In short there were two topics discussed:

  1) introducing (at least) two different storage categories,
  "temporary/evictable/transient" and "persistent/non-evictable".

  2) introducing a new app-facing API to request or query quota/usage.
  There were basically two API proposals, one is to "request more
  (persistent) storage quota" and the other is to "query the current
  quota and used amount".

As for 1) we seem to have roughly agreed on this. FileSystem API and
IndexedDB [2] are in that direction, and it was also discussed that
probably we could add "Persistent" storage option to other APIs. [3]

As for 2) we haven't had a concensus yet, but It sounds beneficial
for both webapps and UA to allow an app to request quotas up front,
as with the API neither webapps nor UA need to worry about quota
error/notification handling in the middle of storage operations.
Also we hear a lot of developers wanting to know "how much storage
our app can use?" information up front to make their apps more
usable with some storage constraints.

To reopen the quota API discussion, I'd like to propose following
asynchronous API that works across all the offline storage APIs:

  interface StorageInfo {
    // storage type
    const unsigned short TEMPORARY = 0;
    const unsigned short PERSISTENT = 1;

    // To query how much storage is available and currently in use.
    void queryUsage(unsigned short storageType,
                    UsageCallback usageCallback);

    // To request a new quota size.
    void requestQuota(unsigned short storageType,
                      unsigned long long newOriginQuotaInBytes,
                      QuotaCallback quotaCallback);
  };

  interface UsageCallback {
    void handleEvent(unsigned long long currentOriginUsageInBytes,
                     unsigned long long currentOriginQuotaInBytes);
  };

  interface QuotaCallback {
    void handleEvent(unsigned long long grantedOriginQuotaInBytes);
  };


With this API I assume multiple offline storage APIs share the same
single (persistent) quota and usage info per origin, but that detail
could be probably left up to UA.

Thanks in advance for any feedbacks/comments.

[1] http://lists.w3.org/Archives/Public/public-webapps/2010AprJun/thread.html#msg102
[2] http://www.w3.org/Bugs/Public/show_bug.cgi?id=11350
[3] http://lists.w3.org/Archives/Public/public-webapps/2010AprJun/0253.html

Received on Thursday, 3 February 2011 10:26:46 UTC