Search code examples
htmlgoogle-chromegoogle-chrome-extensionfileapihtml5-filesystem

What are the details can be obtained from webkitStorageInfo.queryUsageAndQuota()


webkitStorageInfo.queryUsageAndQuota() is used to find out the usage stats of the files that have been stored in the file system using the HTML5 file system API I suppose. Can anyone give me the details that can be obtained in the callback provided to this function.

window.webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.PERSISTENT, function() {
   //what all details can be obtained in this function as its arguments?
})

Solution

  • Replace function(){...} with console.log.bind(console), and you will find out.

    > window.webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.PERSISTENT, console.log.bind(console))
    undefined  // Return value of ^
    0 0        // Printed results, argument 0 and argument 1
    

    The explanation of the callback is found here:

    interface StorageInfo { 
      ....
      // Queries the current quota and how much data is stored for the host. 
      void queryUsageAndQuota( 
          unsigned short storageType, 
          optional StorageInfoUsageCallback successCallback, 
          optional StorageInfoErrorCallback errorCallback); 
      ...
    
    [NoInterfaceObject, Callback=FunctionOnly] 
    interface StorageInfoUsageCallback { 
      void handleEvent(unsigned long long currentUsageInBytes, 
                       unsigned long long currentQuotaInBytes); 
    };

    So, the first number indicates how many bytes are used,
    the second number shows the quota's size.