diff options
Diffstat (limited to 'dom/storage/DOMStorageCache.cpp')
-rw-r--r-- | dom/storage/DOMStorageCache.cpp | 65 |
1 files changed, 13 insertions, 52 deletions
diff --git a/dom/storage/DOMStorageCache.cpp b/dom/storage/DOMStorageCache.cpp index 811f79fd3..ee9a22e96 100644 --- a/dom/storage/DOMStorageCache.cpp +++ b/dom/storage/DOMStorageCache.cpp @@ -85,7 +85,6 @@ DOMStorageCache::DOMStorageCache(const nsACString* aOriginNoSuffix) , mInitialized(false) , mPersistent(false) , mSessionOnlyDataSetActive(false) -, mPreloadTelemetryRecorded(false) { MOZ_COUNT_CTOR(DOMStorageCache); } @@ -178,7 +177,7 @@ DOMStorageCache::DataSet(const DOMStorage* aStorage) // Session only data set is demanded but not filled with // current data set, copy to session only set now. - WaitForPreload(Telemetry::LOCALDOMSTORAGE_SESSIONONLY_PRELOAD_BLOCKING_MS); + WaitForPreload(); Data& defaultSet = mData[kDefaultSet]; Data& sessionSet = mData[kSessionSet]; @@ -206,11 +205,6 @@ DOMStorageCache::ProcessUsageDelta(const DOMStorage* aStorage, int64_t aDelta) bool DOMStorageCache::ProcessUsageDelta(uint32_t aGetDataSetIndex, const int64_t aDelta) { - // Check if we are in a low disk space situation - if (aDelta > 0 && mManager && mManager->IsLowDiskSpace()) { - return false; - } - // Check limit per this origin Data& data = mData[aGetDataSetIndex]; uint64_t newOriginUsage = data.mOriginQuotaUsage + aDelta; @@ -298,49 +292,18 @@ DOMStorageCache::KeepAlive() mKeepAliveTimer.swap(timer); } -namespace { - -// The AutoTimer provided by telemetry headers is only using static, -// i.e. compile time known ID, but here we know the ID only at run time. -// Hence a new class. -class TelemetryAutoTimer -{ -public: - explicit TelemetryAutoTimer(Telemetry::ID aId) - : id(aId), start(TimeStamp::Now()) {} - ~TelemetryAutoTimer() - { Telemetry::AccumulateDelta_impl<Telemetry::Millisecond>::compute(id, start); } -private: - Telemetry::ID id; - const TimeStamp start; -}; - -} // namespace - void -DOMStorageCache::WaitForPreload(Telemetry::ID aTelemetryID) +DOMStorageCache::WaitForPreload() { if (!mPersistent) { return; } bool loaded = mLoaded; - - // Telemetry of rates of pending preloads - if (!mPreloadTelemetryRecorded) { - mPreloadTelemetryRecorded = true; - Telemetry::Accumulate( - Telemetry::LOCALDOMSTORAGE_PRELOAD_PENDING_ON_FIRST_ACCESS, - !loaded); - } - if (loaded) { return; } - // Measure which operation blocks and for how long - TelemetryAutoTimer timer(aTelemetryID); - // If preload already started (i.e. we got some first data, but not all) // SyncPreload will just wait for it to finish rather then synchronously // read from the database. It seems to me more optimal. @@ -357,7 +320,7 @@ nsresult DOMStorageCache::GetLength(const DOMStorage* aStorage, uint32_t* aRetval) { if (Persist(aStorage)) { - WaitForPreload(Telemetry::LOCALDOMSTORAGE_GETLENGTH_BLOCKING_MS); + WaitForPreload(); if (NS_FAILED(mLoadResult)) { return mLoadResult; } @@ -375,7 +338,7 @@ DOMStorageCache::GetKey(const DOMStorage* aStorage, uint32_t aIndex, nsAString& // maybe we need to have a lazily populated key array here or // something? if (Persist(aStorage)) { - WaitForPreload(Telemetry::LOCALDOMSTORAGE_GETKEY_BLOCKING_MS); + WaitForPreload(); if (NS_FAILED(mLoadResult)) { return mLoadResult; } @@ -397,7 +360,7 @@ void DOMStorageCache::GetKeys(const DOMStorage* aStorage, nsTArray<nsString>& aKeys) { if (Persist(aStorage)) { - WaitForPreload(Telemetry::LOCALDOMSTORAGE_GETALLKEYS_BLOCKING_MS); + WaitForPreload(); } if (NS_FAILED(mLoadResult)) { @@ -414,7 +377,7 @@ DOMStorageCache::GetItem(const DOMStorage* aStorage, const nsAString& aKey, nsAString& aRetval) { if (Persist(aStorage)) { - WaitForPreload(Telemetry::LOCALDOMSTORAGE_GETVALUE_BLOCKING_MS); + WaitForPreload(); if (NS_FAILED(mLoadResult)) { return mLoadResult; } @@ -439,7 +402,7 @@ DOMStorageCache::SetItem(const DOMStorage* aStorage, const nsAString& aKey, int64_t delta = 0; if (Persist(aStorage)) { - WaitForPreload(Telemetry::LOCALDOMSTORAGE_SETVALUE_BLOCKING_MS); + WaitForPreload(); if (NS_FAILED(mLoadResult)) { return mLoadResult; } @@ -488,7 +451,7 @@ DOMStorageCache::RemoveItem(const DOMStorage* aStorage, const nsAString& aKey, nsString& aOld) { if (Persist(aStorage)) { - WaitForPreload(Telemetry::LOCALDOMSTORAGE_REMOVEKEY_BLOCKING_MS); + WaitForPreload(); if (NS_FAILED(mLoadResult)) { return mLoadResult; } @@ -527,9 +490,8 @@ DOMStorageCache::Clear(const DOMStorage* aStorage) // We need to preload all data (know the size) before we can proceeed // to correctly decrease cached usage number. // XXX as in case of unload, this is not technically needed now, but - // after super-scope quota introduction we have to do this. Get telemetry - // right now. - WaitForPreload(Telemetry::LOCALDOMSTORAGE_CLEAR_BLOCKING_MS); + // after super-scope quota introduction we have to do this. + WaitForPreload(); if (NS_FAILED(mLoadResult)) { // When we failed to load data from the database, force delete of the // scope data and make use of the storage possible again. @@ -599,9 +561,8 @@ DOMStorageCache::UnloadItems(uint32_t aUnloadFlags) // Must wait for preload to pass correct usage to ProcessUsageDelta // XXX this is not technically needed right now since there is just // per-origin isolated quota handling, but when we introduce super- - // -scope quotas, we have to do this. Better to start getting - // telemetry right now. - WaitForPreload(Telemetry::LOCALDOMSTORAGE_UNLOAD_BLOCKING_MS); + // -scope quotas, we have to do this. + WaitForPreload(); mData[kDefaultSet].mKeys.Clear(); ProcessUsageDelta(kDefaultSet, -mData[kDefaultSet].mOriginQuotaUsage); @@ -620,7 +581,7 @@ DOMStorageCache::UnloadItems(uint32_t aUnloadFlags) #ifdef DOM_STORAGE_TESTS if (aUnloadFlags & kTestReload) { - WaitForPreload(Telemetry::LOCALDOMSTORAGE_UNLOAD_BLOCKING_MS); + WaitForPreload(); mData[kDefaultSet].mKeys.Clear(); mLoaded = false; // This is only used in testing code |