Bug 934321 - Add MemoryMultiReporter, a helper class that reduces some boilerplate, and convert all existing multi-reporters to use it. r=wchen.

--HG--
extra : rebase_source : a6110c3558c571b7908b63e8cc7ca21103098d0d
This commit is contained in:
Nicholas Nethercote 2013-11-06 14:58:20 +11:00
parent d6887b15cb
commit d8a3b0f0bb
21 changed files with 170 additions and 254 deletions

View File

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 2; 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/. */
@ -645,15 +646,12 @@ nsDOMMemoryFile::DataOwner::sMemoryReporterRegistered;
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(DOMMemoryFileDataOwnerMallocSizeOf)
class nsDOMMemoryFileDataOwnerMemoryReporter MOZ_FINAL
: public nsIMemoryReporter
: public MemoryMultiReporter
{
NS_DECL_THREADSAFE_ISUPPORTS
NS_IMETHOD GetName(nsACString& aName)
{
aName.AssignASCII("dom-memory-file-data-owner");
return NS_OK;
}
public:
nsDOMMemoryFileDataOwnerMemoryReporter()
: MemoryMultiReporter("dom-memory-file-data-owner")
{}
NS_IMETHOD CollectReports(nsIMemoryReporterCallback *aCallback,
nsISupports *aClosure)
@ -728,9 +726,6 @@ class nsDOMMemoryFileDataOwnerMemoryReporter MOZ_FINAL
}
};
NS_IMPL_ISUPPORTS1(nsDOMMemoryFileDataOwnerMemoryReporter,
nsIMemoryReporter)
/* static */ void
nsDOMMemoryFile::DataOwner::EnsureMemoryReporterRegistered()
{

View File

@ -1080,11 +1080,15 @@ struct MessageManagerReferentCount
namespace mozilla {
namespace dom {
class MessageManagerReporter MOZ_FINAL : public nsIMemoryReporter
class MessageManagerReporter MOZ_FINAL : public MemoryMultiReporter
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMEMORYREPORTER
MessageManagerReporter()
: MemoryMultiReporter("message-manager")
{}
NS_IMETHOD CollectReports(nsIMemoryReporterCallback* aCallback,
nsISupports* aData);
static const size_t kSuspectReferentCount = 300;
protected:
@ -1092,8 +1096,6 @@ protected:
MessageManagerReferentCount* aReferentCount);
};
NS_IMPL_ISUPPORTS1(MessageManagerReporter, nsIMemoryReporter)
static PLDHashOperator
CollectMessageListenerData(const nsAString& aKey,
nsAutoTObserverArray<nsMessageListenerInfo, 1>* aListeners,
@ -1153,13 +1155,6 @@ MessageManagerReporter::CountReferents(nsFrameMessageManager* aMessageManager,
}
}
NS_IMETHODIMP
MessageManagerReporter::GetName(nsACString& aName)
{
aName.AssignLiteral("message-manager");
return NS_OK;
}
static nsresult
ReportReferentCount(const char* aManagerType,
const MessageManagerReferentCount& aReferentCount,

View File

@ -11,22 +11,17 @@ using namespace mozilla;
NS_IMPL_ISUPPORTS1(WebGLMemoryPressureObserver, nsIObserver)
class WebGLMemoryReporter MOZ_FINAL : public nsIMemoryReporter
class WebGLMemoryReporter MOZ_FINAL : public MemoryMultiReporter
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMEMORYREPORTER
public:
WebGLMemoryReporter()
: MemoryMultiReporter("webgl")
{}
NS_IMETHOD CollectReports(nsIMemoryReporterCallback* aCb,
nsISupports* aClosure);
};
NS_IMPL_ISUPPORTS1(WebGLMemoryReporter, nsIMemoryReporter)
NS_IMETHODIMP
WebGLMemoryReporter::GetName(nsACString &aName)
{
aName.AssignLiteral("webgl");
return NS_OK;
}
NS_IMETHODIMP
WebGLMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
nsISupports* aClosure)

View File

@ -1763,16 +1763,12 @@ MediaDecoder::IsAppleMP3Enabled()
}
#endif
class MediaReporter MOZ_FINAL : public nsIMemoryReporter
class MediaReporter MOZ_FINAL : public MemoryMultiReporter
{
public:
NS_DECL_ISUPPORTS
NS_IMETHOD GetName(nsACString& aName)
{
aName.AssignLiteral("media");
return NS_OK;
}
MediaReporter()
: MemoryMultiReporter("media")
{}
NS_IMETHOD CollectReports(nsIMemoryReporterCallback* aCb,
nsISupports* aClosure)
@ -1800,8 +1796,6 @@ public:
}
};
NS_IMPL_ISUPPORTS1(MediaReporter, nsIMemoryReporter)
MediaDecoderOwner*
MediaDecoder::GetOwner()
{

View File

@ -196,28 +196,20 @@ MemoryReportRequestParent::~MemoryReportRequestParent()
MOZ_COUNT_DTOR(MemoryReportRequestParent);
}
/**
* A memory reporter for ContentParent objects themselves.
*/
class ContentParentMemoryReporter MOZ_FINAL : public nsIMemoryReporter
// A memory reporter for ContentParent objects themselves.
class ContentParentsMemoryReporter MOZ_FINAL : public MemoryMultiReporter
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMEMORYREPORTER
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(MallocSizeOf)
ContentParentsMemoryReporter()
: MemoryMultiReporter("content-parents")
{}
NS_IMETHOD CollectReports(nsIMemoryReporterCallback* cb,
nsISupports* aClosure);
};
NS_IMPL_ISUPPORTS1(ContentParentMemoryReporter, nsIMemoryReporter)
NS_IMETHODIMP
ContentParentMemoryReporter::GetName(nsACString& aName)
{
aName.AssignLiteral("ContentParents");
return NS_OK;
}
NS_IMETHODIMP
ContentParentMemoryReporter::CollectReports(nsIMemoryReporterCallback* cb,
ContentParentsMemoryReporter::CollectReports(nsIMemoryReporterCallback* cb,
nsISupports* aClosure)
{
nsAutoTArray<ContentParent*, 16> cps;
@ -468,8 +460,7 @@ ContentParent::StartUp()
return;
}
nsRefPtr<ContentParentMemoryReporter> mr = new ContentParentMemoryReporter();
NS_RegisterMemoryReporter(mr);
NS_RegisterMemoryReporter(new ContentParentsMemoryReporter());
sCanLaunchSubprocesses = true;

View File

@ -1950,7 +1950,7 @@ struct WorkerPrivate::TimeoutInfo
bool mCanceled;
};
class WorkerPrivate::MemoryReporter MOZ_FINAL : public nsIMemoryReporter
class WorkerPrivate::MemoryReporter MOZ_FINAL : public MemoryMultiReporter
{
friend class WorkerPrivate;
@ -1960,10 +1960,9 @@ class WorkerPrivate::MemoryReporter MOZ_FINAL : public nsIMemoryReporter
bool mAlreadyMappedToAddon;
public:
NS_DECL_THREADSAFE_ISUPPORTS
MemoryReporter(WorkerPrivate* aWorkerPrivate)
: mMutex(aWorkerPrivate->mMutex), mWorkerPrivate(aWorkerPrivate),
: MemoryMultiReporter("workers"),
mMutex(aWorkerPrivate->mMutex), mWorkerPrivate(aWorkerPrivate),
mAlreadyMappedToAddon(false)
{
aWorkerPrivate->AssertIsOnWorkerThread();
@ -1983,13 +1982,6 @@ public:
NS_LITERAL_CSTRING(")/");
}
NS_IMETHOD
GetName(nsACString& aName)
{
aName.AssignLiteral("workers");
return NS_OK;
}
NS_IMETHOD
CollectReports(nsIMemoryReporterCallback* aCallback,
nsISupports* aClosure)
@ -2072,8 +2064,6 @@ private:
}
};
NS_IMPL_ISUPPORTS1(WorkerPrivate::MemoryReporter, nsIMemoryReporter)
template <class Derived>
WorkerPrivateParent<Derived>::WorkerPrivateParent(
JSContext* aCx,

View File

@ -631,21 +631,13 @@ PR_STATIC_ASSERT(uint32_t(CAIRO_SURFACE_TYPE_SKIA) ==
static int64_t gSurfaceMemoryUsed[gfxSurfaceTypeMax] = { 0 };
class SurfaceMemoryReporter MOZ_FINAL :
public nsIMemoryReporter
class SurfaceMemoryReporter MOZ_FINAL : public MemoryMultiReporter
{
public:
SurfaceMemoryReporter()
: MemoryMultiReporter("gfx-surface")
{ }
NS_DECL_ISUPPORTS
NS_IMETHOD GetName(nsACString &name)
{
name.AssignLiteral("gfx-surface");
return NS_OK;
}
NS_IMETHOD CollectReports(nsIMemoryReporterCallback *aCb,
nsISupports *aClosure)
{
@ -673,8 +665,6 @@ public:
}
};
NS_IMPL_ISUPPORTS1(SurfaceMemoryReporter, nsIMemoryReporter)
void
gfxASurface::RecordMemoryUsedForSurfaceType(gfxSurfaceType aType,
int32_t aBytes)

View File

@ -1360,17 +1360,8 @@ gfxFontFamily::AddSizeOfIncludingThis(MallocSizeOf aMallocSizeOf,
* shaped-word caches to free up memory.
*/
NS_IMPL_ISUPPORTS1(gfxFontCache::MemoryReporter, nsIMemoryReporter)
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(FontCacheMallocSizeOf)
NS_IMETHODIMP
gfxFontCache::MemoryReporter::GetName(nsACString &aName)
{
aName.AssignLiteral("font-cache");
return NS_OK;
}
NS_IMETHODIMP
gfxFontCache::MemoryReporter::CollectReports
(nsIMemoryReporterCallback* aCb,

View File

@ -950,12 +950,15 @@ public:
FontCacheSizes* aSizes) const;
protected:
class MemoryReporter MOZ_FINAL
: public nsIMemoryReporter
class MemoryReporter MOZ_FINAL : public mozilla::MemoryMultiReporter
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMEMORYREPORTER
MemoryReporter()
: MemoryMultiReporter("font-cache")
{}
NS_IMETHOD CollectReports(nsIMemoryReporterCallback* aCb,
nsISupports* aClosure);
};
// Observer for notifications that the font cache cares about

View File

@ -71,16 +71,11 @@ gfxFontListPrefObserver::Observe(nsISupports *aSubject,
return NS_OK;
}
NS_IMPL_ISUPPORTS1(gfxPlatformFontList::MemoryReporter, nsIMemoryReporter)
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(FontListMallocSizeOf)
NS_IMETHODIMP
gfxPlatformFontList::MemoryReporter::GetName(nsACString &aName)
{
aName.AssignLiteral("font-list");
return NS_OK;
}
gfxPlatformFontList::MemoryReporter::MemoryReporter()
: MemoryMultiReporter("font-list")
{}
NS_IMETHODIMP
gfxPlatformFontList::MemoryReporter::CollectReports

View File

@ -178,12 +178,12 @@ public:
void RemoveCmap(const gfxCharacterMap *aCharMap);
protected:
class MemoryReporter MOZ_FINAL
: public nsIMemoryReporter
class MemoryReporter MOZ_FINAL : public mozilla::MemoryMultiReporter
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMEMORYREPORTER
MemoryReporter();
NS_IMETHOD CollectReports(nsIMemoryReporterCallback *aCb,
nsISupports *aClosure);
};
gfxPlatformFontList(bool aNeedFullnamePostscriptNames = true);

View File

@ -207,8 +207,8 @@ typedef HRESULT (WINAPI*D3D11CreateDeviceFunc)(
ID3D11DeviceContext *ppImmediateContext
);
class GPUAdapterReporter : public nsIMemoryReporter {
class GPUAdapterReporter : public MemoryMultiReporter
{
// Callers must Release the DXGIAdapter after use or risk mem-leak
static bool GetDXGIAdapter(IDXGIAdapter **DXGIAdapter)
{
@ -227,17 +227,10 @@ class GPUAdapterReporter : public nsIMemoryReporter {
}
public:
NS_DECL_ISUPPORTS
GPUAdapterReporter()
: MemoryMultiReporter("gpu-adapter")
{}
// nsIMemoryReporter abstract method implementation
NS_IMETHOD
GetName(nsACString &aName)
{
aName.AssignLiteral("gpuadapter");
return NS_OK;
}
// nsIMemoryReporter abstract method implementation
NS_IMETHOD
CollectReports(nsIMemoryReporterCallback* aCb,
nsISupports* aClosure)
@ -348,7 +341,6 @@ public:
return NS_OK;
}
};
NS_IMPL_ISUPPORTS1(GPUAdapterReporter, nsIMemoryReporter)
static __inline void
BuildKeyNameFromFontName(nsAString &aName)

View File

@ -50,21 +50,12 @@ using namespace mozilla::image;
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(ImagesMallocSizeOf)
class imgMemoryReporter MOZ_FINAL :
public nsIMemoryReporter
class imgMemoryReporter MOZ_FINAL : public MemoryMultiReporter
{
public:
imgMemoryReporter()
{
}
NS_DECL_ISUPPORTS
NS_IMETHOD GetName(nsACString &name)
{
name.Assign("images");
return NS_OK;
}
: MemoryMultiReporter("images")
{}
NS_IMETHOD CollectReports(nsIMemoryReporterCallback *callback,
nsISupports *closure)
@ -223,8 +214,6 @@ private:
}
};
NS_IMPL_ISUPPORTS1(imgMemoryReporter, nsIMemoryReporter)
NS_IMPL_ISUPPORTS3(nsProgressNotificationProxy,
nsIProgressEventSink,
nsIChannelEventSink,

View File

@ -2398,15 +2398,12 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats,
} // namespace xpc
class JSMainRuntimeCompartmentsReporter MOZ_FINAL : public nsIMemoryReporter
class JSMainRuntimeCompartmentsReporter MOZ_FINAL : public MemoryMultiReporter
{
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_IMETHOD GetName(nsACString &name) {
name.AssignLiteral("js-main-runtime-compartments");
return NS_OK;
}
JSMainRuntimeCompartmentsReporter()
: MemoryMultiReporter("js-main-runtime-compartments")
{}
typedef js::Vector<nsCString, 0, js::SystemAllocPolicy> Paths;
@ -2445,8 +2442,6 @@ class JSMainRuntimeCompartmentsReporter MOZ_FINAL : public nsIMemoryReporter
}
};
NS_IMPL_ISUPPORTS1(JSMainRuntimeCompartmentsReporter, nsIMemoryReporter)
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(OrphanMallocSizeOf)
namespace xpc {

View File

@ -208,13 +208,16 @@ Preferences::SizeOfIncludingThisAndOtherStuff(mozilla::MallocSizeOf aMallocSizeO
return n;
}
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(PreferencesMallocSizeOf)
class PreferencesReporter MOZ_FINAL : public nsIMemoryReporter
class PreferenceServiceReporter MOZ_FINAL : public MemoryMultiReporter
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMEMORYREPORTER
PreferenceServiceReporter()
: MemoryMultiReporter("preference-service")
{}
NS_IMETHOD CollectReports(nsIMemoryReporterCallback* aCallback,
nsISupports* aData);
protected:
static const uint32_t kSuspectReferentCount = 1000;
static PLDHashOperator CountReferents(PrefCallback* aKey,
@ -222,15 +225,6 @@ protected:
void* aClosure);
};
NS_IMPL_ISUPPORTS1(PreferencesReporter, nsIMemoryReporter)
NS_IMETHODIMP
PreferencesReporter::GetName(nsACString& aName)
{
aName.AssignLiteral("preference-service");
return NS_OK;
}
struct PreferencesReferentCount {
PreferencesReferentCount() : numStrong(0), numWeakAlive(0), numWeakDead(0) {}
size_t numStrong;
@ -242,7 +236,7 @@ struct PreferencesReferentCount {
};
PLDHashOperator
PreferencesReporter::CountReferents(PrefCallback* aKey,
PreferenceServiceReporter::CountReferents(PrefCallback* aKey,
nsAutoPtr<PrefCallback>& aCallback,
void* aClosure)
{
@ -279,7 +273,7 @@ PreferencesReporter::CountReferents(PrefCallback* aKey,
}
NS_IMETHODIMP
PreferencesReporter::CollectReports(nsIMemoryReporterCallback* aCb,
PreferenceServiceReporter::CollectReports(nsIMemoryReporterCallback* aCb,
nsISupports* aClosure)
{
#define REPORT(_path, _kind, _units, _amount, _desc) \
@ -293,7 +287,7 @@ PreferencesReporter::CollectReports(nsIMemoryReporterCallback* aCb,
REPORT(NS_LITERAL_CSTRING("explicit/preferences"),
nsIMemoryReporter::KIND_HEAP, nsIMemoryReporter::UNITS_BYTES,
Preferences::SizeOfIncludingThisAndOtherStuff(PreferencesMallocSizeOf),
Preferences::SizeOfIncludingThisAndOtherStuff(MallocSizeOf),
"Memory used by the preferences system.");
nsPrefBranch* rootBranch =
@ -347,7 +341,7 @@ class AddPreferencesMemoryReporterRunnable : public nsRunnable
{
NS_IMETHOD Run()
{
return NS_RegisterMemoryReporter(new PreferencesReporter());
return NS_RegisterMemoryReporter(new PreferenceServiceReporter());
}
};
} // anonymous namespace

View File

@ -24,13 +24,13 @@
#include "mozilla/MemoryReporting.h"
namespace mozilla {
class PreferencesReporter;
class PreferenceServiceReporter;
} // namespace mozilla;
class nsPrefBranch;
class PrefCallback : public PLDHashEntryHdr {
friend class mozilla::PreferencesReporter;
friend class mozilla::PreferenceServiceReporter;
public:
typedef PrefCallback* KeyType;
@ -178,7 +178,7 @@ class nsPrefBranch : public nsIPrefBranchInternal,
public nsIObserver,
public nsSupportsWeakReference
{
friend class mozilla::PreferencesReporter;
friend class mozilla::PreferenceServiceReporter;
public:
NS_DECL_THREADSAFE_ISUPPORTS
NS_DECL_NSIPREFBRANCH

View File

@ -59,7 +59,7 @@ StorageSQLiteDistinguishedAmount()
return ::sqlite3_memory_used();
}
class StorageSQLiteReporter MOZ_FINAL : public nsIMemoryReporter
class StorageSQLiteReporter MOZ_FINAL : public MemoryMultiReporter
{
private:
Service *mService; // a weakref because Service contains a strongref to this
@ -68,10 +68,9 @@ private:
nsCString mSchemaDesc;
public:
NS_DECL_THREADSAFE_ISUPPORTS
StorageSQLiteReporter(Service *aService)
: mService(aService)
: MemoryMultiReporter("storage-sqlite")
, mService(aService)
{
mStmtDesc = NS_LITERAL_CSTRING(
"Memory (approximate) used by all prepared statements used by "
@ -86,12 +85,6 @@ public:
"associated with connections to this database.");
}
NS_IMETHOD GetName(nsACString &aName)
{
aName.AssignLiteral("storage-sqlite-multi");
return NS_OK;
}
// Warning: To get a Connection's measurements requires holding its lock.
// There may be a delay getting the lock if another thread is accessing the
// Connection. This isn't very nice if CollectReports is called from the
@ -204,11 +197,6 @@ private:
}
};
NS_IMPL_ISUPPORTS1(
StorageSQLiteReporter,
nsIMemoryReporter
)
////////////////////////////////////////////////////////////////////////////////
//// Service

View File

@ -2387,21 +2387,14 @@ nsCycleCollector::CollectWhite()
// Memory reporter
////////////////////////
class CycleCollectorReporter MOZ_FINAL : public nsIMemoryReporter
class CycleCollectorReporter MOZ_FINAL : public MemoryMultiReporter
{
public:
CycleCollectorReporter(nsCycleCollector* aCollector)
: mCollector(aCollector)
: MemoryMultiReporter("cycle-collector"),
mCollector(aCollector)
{}
NS_DECL_ISUPPORTS
NS_IMETHOD GetName(nsACString& name)
{
name.AssignLiteral("cycle-collector");
return NS_OK;
}
NS_IMETHOD CollectReports(nsIMemoryReporterCallback* aCb,
nsISupports* aClosure)
{
@ -2461,8 +2454,6 @@ class CycleCollectorReporter MOZ_FINAL : public nsIMemoryReporter
nsCycleCollector* mCollector;
};
NS_IMPL_ISUPPORTS1(CycleCollectorReporter, nsIMemoryReporter)
////////////////////////////////////////////////////////////////////////
// Collector implementation

View File

@ -492,18 +492,18 @@ namespace mozilla {
// memory uni-reporters. You just need to provide the following.
// - The constant values: nameAndPath (which serves as both the reporters name,
// and the path in its single report), kind, units, and description. They
// are passed to the MemoryUniReporter constructor.
// - A (private) Amount() or (public) GetAmount() method. It can use the
// are arguments to the MemoryUniReporter constructor.
// - A private Amount() or public GetAmount() method. It can use the
// MallocSizeOf method if necessary. (There is also
// MallocSizeOfOn{Alloc,Free}, which can be useful.) Use Amount() if the
// reporter is infallible, and GetAmount() otherwise. (If you fail to
// provide one or the other, you'll get assertion failures when the memory
// reporter runs.)
//
// The class name of subclasses should match the path, minus the "explicit"
// (if present), and with "Reporter" at the end. For example:
// - "explicit/dom/xyzzy" --> DOMXyzzyReporter
// - "js-compartments/system" --> JSCompartmentsSystemReporter
// The class name of subclasses should match the nameAndPath, minus the
// "explicit" (if present), and with "Reporter" at the end. For example:
// - nameAndPath == "explicit/dom/xyzzy" --> DOMXyzzyReporter
// - nameAndPath == "js-compartments/system" --> JSCompartmentsSystemReporter
//
class MemoryUniReporter : public nsIMemoryReporter
{
@ -561,6 +561,46 @@ protected:
const nsCString mDescription;
};
// The following base class reduces the amount of boilerplate code required for
// memory multi-reporters. You just need to provide the following.
// - The constant value: name. It is an argument to the MemoryMultiReporter
// constructor. The name of each multi-reporter should be unique.
// - A public CollectReports() method. It can use the MallocSizeOf method if
// necessary. (There is also MallocSizeOfOn{Alloc,Free}, which can be
// useful.)
//
// The class name of subclasses should match the name, with "Reporter" at
// the end. For example:
// - name == "foo" --> FooMultiReporter
//
class MemoryMultiReporter : public nsIMemoryReporter
{
public:
MemoryMultiReporter(const char* aName)
: mName(aName)
{}
virtual ~MemoryMultiReporter() {}
NS_DECL_THREADSAFE_ISUPPORTS
NS_IMETHOD GetName(nsACString& aName)
{
aName.Assign(mName);
return NS_OK;
}
NS_IMETHOD CollectReports(nsIMemoryReporterCallback* aCb,
nsISupports* aClosure) = 0;
protected:
NS_MEMORY_REPORTER_MALLOC_SIZEOF_FUN(MallocSizeOf)
NS_MEMORY_REPORTER_MALLOC_SIZEOF_ON_ALLOC_FUN(MallocSizeOfOnAlloc)
NS_MEMORY_REPORTER_MALLOC_SIZEOF_ON_FREE_FUN(MallocSizeOfOnFree)
const nsCString mName;
};
} // namespace mozilla
%}

View File

@ -667,20 +667,13 @@ private:
namespace mozilla {
namespace dmd {
class DMDReporter MOZ_FINAL : public nsIMemoryReporter
class DMDReporter MOZ_FINAL : public MemoryMultiReporter
{
public:
DMDReporter()
: MemoryMultiReporter("dmd")
{}
NS_DECL_ISUPPORTS
NS_IMETHOD GetName(nsACString& aName)
{
aName.Assign("dmd");
return NS_OK;
}
NS_IMETHOD CollectReports(nsIHandleReport* aHandleReport,
nsISupports* aData)
{
@ -721,8 +714,6 @@ public:
}
};
NS_IMPL_ISUPPORTS1(DMDReporter, nsIMemoryReporter)
} // namespace dmd
} // namespace mozilla
@ -1542,6 +1533,7 @@ nsMemoryReporterManager::SizeOfTab(nsIDOMWindow* aTopWindow,
// thread-safe just to be safe. Memory reporters are created and destroyed
// infrequently enough that the performance cost should be negligible.
NS_IMPL_ISUPPORTS1(MemoryUniReporter, nsIMemoryReporter)
NS_IMPL_ISUPPORTS1(MemoryMultiReporter, nsIMemoryReporter)
nsresult
NS_RegisterMemoryReporter(nsIMemoryReporter* aReporter)

View File

@ -42,26 +42,22 @@ GetObserverServiceLog()
namespace mozilla {
class ObserverServiceReporter MOZ_FINAL : public nsIMemoryReporter
class ObserverServiceReporter MOZ_FINAL : public MemoryMultiReporter
{
public:
NS_DECL_ISUPPORTS
NS_DECL_NSIMEMORYREPORTER
ObserverServiceReporter()
: MemoryMultiReporter("observer-service")
{}
NS_IMETHOD CollectReports(nsIMemoryReporterCallback *aCb,
nsISupports *aClosure);
protected:
static const size_t kSuspectReferentCount = 100;
static PLDHashOperator CountReferents(nsObserverList* aObserverList,
void* aClosure);
};
NS_IMPL_ISUPPORTS1(ObserverServiceReporter, nsIMemoryReporter)
NS_IMETHODIMP
ObserverServiceReporter::GetName(nsACString& aName)
{
aName.AssignLiteral("observer-service");
return NS_OK;
}
struct SuspectObserver {
SuspectObserver(const char* aTopic, size_t aReferentCount)
: topic(aTopic), referentCount(aReferentCount) {}