commit c6997731e99a78e873c30c7528b7582e94da4a30
parent ad5777e1a15536603825589db0b353adea9a95cc
Author: Andrew McCreight <continuation@gmail.com>
Date: Wed, 3 Dec 2025 13:53:36 +0000
Bug 2003609, part 3 - Remove nsISizeOf::SizeOfExcludingThis. r=necko-reviewers,xpcom-reviewers,nika,jesup
SizeOfExcludingThis is needed when an object is a part of a larger
object, but nsISizeOf is only used for refcounted objects, so this
situation will never come up. As seen in the previous patch, leaving
it around means people can mistakenly call it, so remove it.
Inline the definitions into SizeOfIncludingThis.
Differential Revision: https://phabricator.services.mozilla.com/D274835
Diffstat:
7 files changed, 12 insertions(+), 28 deletions(-)
diff --git a/netwerk/base/DefaultURI.cpp b/netwerk/base/DefaultURI.cpp
@@ -73,12 +73,8 @@ NS_IMETHODIMP DefaultURI::Write(nsIObjectOutputStream* aOutputStream) {
// nsISizeOf
//----------------------------------------------------------------------------
-size_t DefaultURI::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const {
- return mURL->SizeOf();
-}
-
size_t DefaultURI::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
- return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
+ return aMallocSizeOf(this) + mURL->SizeOf();
}
//----------------------------------------------------------------------------
diff --git a/netwerk/base/DefaultURI.h b/netwerk/base/DefaultURI.h
@@ -20,7 +20,6 @@ class DefaultURI : public nsIURI, public nsISerializable, public nsISizeOf {
NS_DECL_NSIURI
NS_DECL_NSISERIALIZABLE
- virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
class Mutator final : public nsIURIMutator, public nsISerializable {
diff --git a/netwerk/base/nsSimpleURI.cpp b/netwerk/base/nsSimpleURI.cpp
@@ -641,12 +641,9 @@ nsSimpleURI::GetAsciiHost(nsACString& result) {
// nsSimpleURI::nsISizeOf
//----------------------------------------------------------------------------
-size_t nsSimpleURI::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const {
- return mSpec.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
-}
-
size_t nsSimpleURI::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
- return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
+ return aMallocSizeOf(this) +
+ mSpec.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
}
NS_IMETHODIMP
diff --git a/netwerk/base/nsSimpleURI.h b/netwerk/base/nsSimpleURI.h
@@ -48,7 +48,6 @@ class nsSimpleURI : public nsIURI, public nsISerializable, public nsISizeOf {
// - nsJSURI: mBaseURI
// - nsSimpleNestedURI: mInnerURI
// - nsBlobURI: mPrincipal
- virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
protected:
diff --git a/netwerk/base/nsStandardURL.cpp b/netwerk/base/nsStandardURL.cpp
@@ -3691,19 +3691,16 @@ bool nsStandardURL::Deserialize(const URIParams& aParams) {
// nsStandardURL::nsISizeOf
//----------------------------------------------------------------------------
-size_t nsStandardURL::SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const {
- return mSpec.SizeOfExcludingThisIfUnshared(aMallocSizeOf) +
+size_t nsStandardURL::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
+ return aMallocSizeOf(this) +
+ mSpec.SizeOfExcludingThisIfUnshared(aMallocSizeOf) +
mDisplayHost.SizeOfExcludingThisIfUnshared(aMallocSizeOf);
- // Measurement of the following members may be added later if DMD finds it is
- // worthwhile:
+ // Measurement of the following members may be added later if DMD finds it
+ // is worthwhile:
// - mParser
// - mFile
}
-size_t nsStandardURL::SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
- return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
-}
-
} // namespace net
} // namespace mozilla
diff --git a/netwerk/base/nsStandardURL.h b/netwerk/base/nsStandardURL.h
@@ -133,7 +133,6 @@ class nsStandardURL : public nsIFileURL,
NS_DECL_NSISENSITIVEINFOHIDDENURI
// nsISizeOf
- virtual size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const override;
virtual size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const override;
static void InitGlobalObjects();
diff --git a/xpcom/base/nsISizeOf.h b/xpcom/base/nsISizeOf.h
@@ -18,13 +18,10 @@ class nsISizeOf : public nsISupports {
NS_INLINE_DECL_STATIC_IID(NS_ISIZEOF_IID)
/**
- * Measures the size of the things pointed to by the object.
- */
- virtual size_t SizeOfExcludingThis(
- mozilla::MallocSizeOf aMallocSizeOf) const = 0;
-
- /**
- * Like SizeOfExcludingThis, but also includes the size of the object itself.
+ * Measures the size of the object and the things that it points to.
+ * Be careful to not call this more than once on a particular object!
+ * SizeOfExcludingThis does not make sense here because this is a refcounted
+ * object.
*/
virtual size_t SizeOfIncludingThis(
mozilla::MallocSizeOf aMallocSizeOf) const = 0;