commit 1e71b78835d44acbda502918b2fc8dd0da8abe33
parent 5fd8f62d62034715acb81fe9b7294222d3790a52
Author: Andrew McCreight <continuation@gmail.com>
Date: Tue, 2 Dec 2025 13:54:56 +0000
Bug 2003396 - Remove the uses of nsISizeOf from netwerk/cache2/. r=necko-reviewers,valentin
The only implementation of nsISizeOf are various nsIURI implementations,
so nsITimer and nsIFile will never implement it, which is what all of
these fields are.
Also remove a few other references to nsISizeOf that I don't think
are too useful.
Differential Revision: https://phabricator.services.mozilla.com/D274676
Diffstat:
4 files changed, 14 insertions(+), 41 deletions(-)
diff --git a/netwerk/cache2/CacheEntry.cpp b/netwerk/cache2/CacheEntry.cpp
@@ -22,7 +22,6 @@
#include "nsIInputStream.h"
#include "nsIOutputStream.h"
#include "nsISeekableStream.h"
-#include "nsISizeOf.h"
#include "nsIURI.h"
#include "nsNetCID.h"
#include "nsProxyRelease.h"
@@ -1992,7 +1991,7 @@ size_t CacheEntry::SizeOfExcludingThis(mozilla::MallocSizeOf mallocSizeOf) {
// mWriter is one of many handles we create, but (intentionally) not keep
// any reference to, so those unfortunately cannot be reported. Handles are
// small, though.
- // mSecurityInfo doesn't impl nsISizeOf.
+ // mSecurityInfo doesn't implement memory reporting.
return n;
}
diff --git a/netwerk/cache2/CacheFileIOManager.cpp b/netwerk/cache2/CacheFileIOManager.cpp
@@ -20,7 +20,6 @@
#include "nsIDirectoryEnumerator.h"
#include "nsEffectiveTLDService.h"
#include "nsIObserverService.h"
-#include "nsISizeOf.h"
#include "mozilla/net/MozURL.h"
#include "mozilla/glean/NetwerkCache2Metrics.h"
#include "mozilla/DebugOnly.h"
@@ -297,13 +296,6 @@ bool CacheFileHandle::SetPinned(bool aPinned) {
size_t CacheFileHandle::SizeOfExcludingThis(
mozilla::MallocSizeOf mallocSizeOf) const {
size_t n = 0;
- nsCOMPtr<nsISizeOf> sizeOf;
-
- sizeOf = do_QueryInterface(mFile);
- if (sizeOf) {
- n += sizeOf->SizeOfIncludingThis(mallocSizeOf);
- }
-
n += mallocSizeOf(mFD);
n += mKey.SizeOfExcludingThisIfUnshared(mallocSizeOf);
return n;
@@ -4635,15 +4627,13 @@ class SizeOfHandlesRunnable : public Runnable {
public:
SizeOfHandlesRunnable(mozilla::MallocSizeOf mallocSizeOf,
CacheFileHandles const& handles,
- nsTArray<CacheFileHandle*> const& specialHandles,
- nsCOMPtr<nsITimer> const& metadataWritesTimer)
+ nsTArray<CacheFileHandle*> const& specialHandles)
: Runnable("net::SizeOfHandlesRunnable"),
mMonitor("SizeOfHandlesRunnable.mMonitor"),
mMonitorNotified(false),
mMallocSizeOf(mallocSizeOf),
mHandles(handles),
mSpecialHandles(specialHandles),
- mMetadataWritesTimer(metadataWritesTimer),
mSize(0) {}
size_t Get(CacheIOThread* thread) {
@@ -4675,10 +4665,6 @@ class SizeOfHandlesRunnable : public Runnable {
for (uint32_t i = 0; i < mSpecialHandles.Length(); ++i) {
mSize += mSpecialHandles[i]->SizeOfIncludingThis(mMallocSizeOf);
}
- nsCOMPtr<nsISizeOf> sizeOf = do_QueryInterface(mMetadataWritesTimer);
- if (sizeOf) {
- mSize += sizeOf->SizeOfIncludingThis(mMallocSizeOf);
- }
mMonitorNotified = true;
mon.Notify();
@@ -4691,7 +4677,6 @@ class SizeOfHandlesRunnable : public Runnable {
mozilla::MallocSizeOf mMallocSizeOf;
CacheFileHandles const& mHandles;
nsTArray<CacheFileHandle*> const& mSpecialHandles;
- nsCOMPtr<nsITimer> const& mMetadataWritesTimer;
size_t mSize;
};
@@ -4700,29 +4685,27 @@ class SizeOfHandlesRunnable : public Runnable {
size_t CacheFileIOManager::SizeOfExcludingThisInternal(
mozilla::MallocSizeOf mallocSizeOf) const {
size_t n = 0;
- nsCOMPtr<nsISizeOf> sizeOf;
if (mIOThread) {
n += mIOThread->SizeOfIncludingThis(mallocSizeOf);
- // mHandles, mSpecialHandles and mMetadataWritesTimer must be accessed
- // only on the I/O thread, must sync dispatch.
+ // mHandles and mSpecialHandles must be accessed only on the I/O thread,
+ // must sync dispatch.
RefPtr<SizeOfHandlesRunnable> sizeOfHandlesRunnable =
- new SizeOfHandlesRunnable(mallocSizeOf, mHandles, mSpecialHandles,
- mMetadataWritesTimer);
+ new SizeOfHandlesRunnable(mallocSizeOf, mHandles, mSpecialHandles);
n += sizeOfHandlesRunnable->Get(mIOThread);
}
// mHandlesByLastUsed just refers handles reported by mHandles.
- sizeOf = do_QueryInterface(mCacheDirectory);
- if (sizeOf) n += sizeOf->SizeOfIncludingThis(mallocSizeOf);
+ // mCacheDirectory is an nsIFile which we don't have reporting for.
+
+ // mMetadataWritesTimer is an nsITimer which we don't have reporting for.
+ // Note that it would need to be accessed on the I/O thread.
- sizeOf = do_QueryInterface(mTrashTimer);
- if (sizeOf) n += sizeOf->SizeOfIncludingThis(mallocSizeOf);
+ // mTrashTimer is an nsITimer which we don't have reporting for.
- sizeOf = do_QueryInterface(mTrashDir);
- if (sizeOf) n += sizeOf->SizeOfIncludingThis(mallocSizeOf);
+ // mTrashDir is an nsIFile which we don't have reporting for.
for (uint32_t i = 0; i < mFailedTrashDirs.Length(); ++i) {
n += mFailedTrashDirs[i].SizeOfExcludingThisIfUnshared(mallocSizeOf);
diff --git a/netwerk/cache2/CacheIOThread.cpp b/netwerk/cache2/CacheIOThread.cpp
@@ -506,8 +506,7 @@ size_t CacheIOThread::SizeOfExcludingThis(
for (const auto& event : mEventQueue) {
n += event.ShallowSizeOfExcludingThis(mallocSizeOf);
// Events referenced by the queues are arbitrary objects we cannot be sure
- // are reported elsewhere as well as probably not implementing nsISizeOf
- // interface. Deliberatly omitting them from reporting here.
+ // aren't reported elsewhere. Deliberately omitting them from reporting.
}
return n;
diff --git a/netwerk/cache2/CacheIndex.cpp b/netwerk/cache2/CacheIndex.cpp
@@ -11,7 +11,6 @@
#include "CacheIndexIterator.h"
#include "CacheIndexContextIterator.h"
#include "nsThreadUtils.h"
-#include "nsISizeOf.h"
#include "nsPrintfCString.h"
#include "mozilla/DebugOnly.h"
#include "prinrval.h"
@@ -3803,21 +3802,14 @@ size_t CacheIndex::SizeOfExcludingThisInternal(
sLock.AssertCurrentThreadOwns();
size_t n = 0;
- nsCOMPtr<nsISizeOf> sizeOf;
// mIndexHandle and mJournalHandle are reported via SizeOfHandlesRunnable
// in CacheFileIOManager::SizeOfExcludingThisInternal as part of special
// handles array.
- sizeOf = do_QueryInterface(mCacheDirectory);
- if (sizeOf) {
- n += sizeOf->SizeOfIncludingThis(mallocSizeOf);
- }
+ // mCacheDirectory is an nsIFile which we don't have reporting for.
- sizeOf = do_QueryInterface(mUpdateTimer);
- if (sizeOf) {
- n += sizeOf->SizeOfIncludingThis(mallocSizeOf);
- }
+ // mUpdateTimer is an nsITimer which we don't have reporting for.
n += mallocSizeOf(mRWBuf);
n += mallocSizeOf(mRWHash);