mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 1186783 (part 1) - Replace nsBaseHashtable::EnumerateRead() calls in netwerk/ with iterators. r=valentin.
This commit is contained in:
parent
6f9bc492d5
commit
7123371a1f
24
netwerk/cache/nsDiskCacheDeviceSQL.cpp
vendored
24
netwerk/cache/nsDiskCacheDeviceSQL.cpp
vendored
@ -1365,22 +1365,6 @@ nsOfflineCacheDevice::InitActiveCaches()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/* static */
|
||||
PLDHashOperator
|
||||
nsOfflineCacheDevice::ShutdownApplicationCache(const nsACString &key,
|
||||
nsIWeakReference *weakRef,
|
||||
void *ctx)
|
||||
{
|
||||
nsCOMPtr<nsIApplicationCache> obj = do_QueryReferent(weakRef);
|
||||
if (obj)
|
||||
{
|
||||
nsApplicationCache *appCache = static_cast<nsApplicationCache*>(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<nsIApplicationCache> obj = do_QueryReferent(iter.UserData());
|
||||
if (obj) {
|
||||
auto appCache = static_cast<nsApplicationCache*>(obj.get());
|
||||
appCache->MarkInvalid();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
|
4
netwerk/cache/nsDiskCacheDeviceSQL.h
vendored
4
netwerk/cache/nsDiskCacheDeviceSQL.h
vendored
@ -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; }
|
||||
|
@ -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<WalkMemoryCacheRunnable*>(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,
|
||||
|
Loading…
Reference in New Issue
Block a user