diff --git a/netwerk/cache/nsDiskCacheDeviceSQL.cpp b/netwerk/cache/nsDiskCacheDeviceSQL.cpp index 4d58556555ff..14899adfb780 100644 --- a/netwerk/cache/nsDiskCacheDeviceSQL.cpp +++ b/netwerk/cache/nsDiskCacheDeviceSQL.cpp @@ -1365,22 +1365,6 @@ nsOfflineCacheDevice::InitActiveCaches() return NS_OK; } -/* static */ -PLDHashOperator -nsOfflineCacheDevice::ShutdownApplicationCache(const nsACString &key, - nsIWeakReference *weakRef, - void *ctx) -{ - nsCOMPtr obj = do_QueryReferent(weakRef); - if (obj) - { - nsApplicationCache *appCache = static_cast(obj.get()); - appCache->MarkInvalid(); - } - - return PL_DHASH_NEXT; -} - nsresult nsOfflineCacheDevice::Shutdown() { @@ -1388,7 +1372,13 @@ nsOfflineCacheDevice::Shutdown() { MutexAutoLock lock(mLock); - mCaches.EnumerateRead(ShutdownApplicationCache, this); + for (auto iter = mCaches.Iter(); !iter.Done(); iter.Next()) { + nsCOMPtr obj = do_QueryReferent(iter.UserData()); + if (obj) { + auto appCache = static_cast(obj.get()); + appCache->MarkInvalid(); + } + } } { diff --git a/netwerk/cache/nsDiskCacheDeviceSQL.h b/netwerk/cache/nsDiskCacheDeviceSQL.h index 6dafdddecba9..fe2e6d642deb 100644 --- a/netwerk/cache/nsDiskCacheDeviceSQL.h +++ b/netwerk/cache/nsDiskCacheDeviceSQL.h @@ -199,10 +199,6 @@ private: friend class nsApplicationCache; - static PLDHashOperator ShutdownApplicationCache(const nsACString &key, - nsIWeakReference *weakRef, - void *ctx); - static bool GetStrictFileOriginPolicy(); bool Initialized() { return mDB != nullptr; } diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp index cd4abf3e8664..a7d953f33c85 100644 --- a/netwerk/cache2/CacheStorageService.cpp +++ b/netwerk/cache2/CacheStorageService.cpp @@ -1,3 +1,5 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ @@ -237,8 +239,24 @@ private: return NS_ERROR_NOT_INITIALIZED; CacheEntryTable* entries; - if (sGlobalEntryTables->Get(mContextKey, &entries)) - entries->EnumerateRead(&WalkMemoryCacheRunnable::WalkStorage, this); + if (sGlobalEntryTables->Get(mContextKey, &entries)) { + for (auto iter = entries->Iter(); !iter.Done(); iter.Next()) { + CacheEntry* entry = iter.UserData(); + + // Ignore disk entries + if (entry->IsUsingDisk()) { + continue; + } + + mSize += entry->GetMetadataMemoryConsumption(); + + int64_t size; + if (NS_SUCCEEDED(entry->GetDataSize(&size))) { + mSize += size; + } + mEntryArray.AppendElement(entry); + } + } // Next, we dispatch to the main thread } else if (NS_IsMainThread()) { @@ -287,28 +305,6 @@ private: ProxyReleaseMainThread(mCallback); } - static PLDHashOperator - WalkStorage(const nsACString& aKey, - CacheEntry* aEntry, - void* aClosure) - { - WalkMemoryCacheRunnable* walker = - static_cast(aClosure); - - // Ignore disk entries - if (aEntry->IsUsingDisk()) - return PL_DHASH_NEXT; - - walker->mSize += aEntry->GetMetadataMemoryConsumption(); - - int64_t size; - if (NS_SUCCEEDED(aEntry->GetDataSize(&size))) - walker->mSize += size; - - walker->mEntryArray.AppendElement(aEntry); - return PL_DHASH_NEXT; - } - virtual void OnEntryInfo(const nsACString & aURISpec, const nsACString & aIdEnhance, int64_t aDataSize, int32_t aFetchCount, uint32_t aLastModifiedTime, uint32_t aExpirationTime,