From 232f5a470531de975a45502e1d9889075540ea53 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Fri, 11 Feb 2022 13:20:09 +0000 Subject: [PATCH] [network] cache memory reporter cleanup --- netwerk/cache2/CacheIndex.cpp | 5 +++-- netwerk/cache2/CacheStorageService.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/netwerk/cache2/CacheIndex.cpp b/netwerk/cache2/CacheIndex.cpp index 0c46647c63..3bc07e5245 100644 --- a/netwerk/cache2/CacheIndex.cpp +++ b/netwerk/cache2/CacheIndex.cpp @@ -3649,7 +3649,7 @@ CacheIndex::SizeOfExcludingThisInternal(mozilla::MallocSizeOf mallocSizeOf) cons size_t CacheIndex::SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) { - sLock.AssertCurrentThreadOwns(); + StaticMutexAutoLock lock(sLock); if (!gInstance) return 0; @@ -3663,7 +3663,8 @@ CacheIndex::SizeOfIncludingThis(mozilla::MallocSizeOf mallocSizeOf) { StaticMutexAutoLock lock(sLock); - return mallocSizeOf(gInstance) + SizeOfExcludingThis(mallocSizeOf); + return mallocSizeOf(gInstance) + + (gInstance ? gInstance->SizeOfExcludingThisInternal(mallocSizeOf) : 0); } // static diff --git a/netwerk/cache2/CacheStorageService.cpp b/netwerk/cache2/CacheStorageService.cpp index 0ed854e916..c345429396 100644 --- a/netwerk/cache2/CacheStorageService.cpp +++ b/netwerk/cache2/CacheStorageService.cpp @@ -2031,6 +2031,8 @@ NS_IMETHODIMP CacheStorageService::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize) { + MutexAutoLock lock(mLock); + MOZ_COLLECT_REPORT( "explicit/network/cache2/io", KIND_HEAP, UNITS_BYTES, CacheFileIOManager::SizeOfIncludingThis(MallocSizeOf), @@ -2041,8 +2043,6 @@ CacheStorageService::CollectReports(nsIHandleReportCallback* aHandleReport, CacheIndex::SizeOfIncludingThis(MallocSizeOf), "Memory used by the cache index."); - MutexAutoLock lock(mLock); - // Report the service instance, this doesn't report entries, done lower MOZ_COLLECT_REPORT( "explicit/network/cache2/service", KIND_HEAP, UNITS_BYTES,