bool
DOMStorageDBParent::RecvAsyncGetUsage(const nsCString& aScope)
{
  DOMStorageDBBridge* db = DOMStorageCache::StartDatabase();
  if (!db) {
    return false;
  }

  // The object releases it self in LoadUsage method
  nsRefPtr<UsageParentBridge> usage = new UsageParentBridge(this, aScope);
  db->AsyncGetUsage(usage);
  return true;
}
Example #2
0
already_AddRefed<DOMStorageUsage>
DOMStorageManager::GetScopeUsage(const nsACString& aScope)
{
  RefPtr<DOMStorageUsage> usage;
  if (mUsages.Get(aScope, &usage)) {
    return usage.forget();
  }

  usage = new DOMStorageUsage(aScope);

  if (mType == LocalStorage) {
    DOMStorageDBBridge* db = DOMStorageCache::StartDatabase();
    if (db) {
      db->AsyncGetUsage(usage);
    }
  }

  mUsages.Put(aScope, usage);

  return usage.forget();
}