mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1010064 - Allow memory reports to be anonymized. r=bsmedberg.
--HG-- extra : rebase_source : 5eb756b17a97e751deb0f47e909fdb35533cb23b
This commit is contained in:
parent
95cc33a82f
commit
39f29c384a
@ -161,7 +161,7 @@ function reportMemoryUsage() {
|
||||
function logReporter(process, path, kind, units, amount, description) {
|
||||
print(((++count == 1) ? "\n" : "") + description + ": " + amount + "\n");
|
||||
}
|
||||
mgr.getReportsForThisProcess(logReporter, null);
|
||||
mgr.getReportsForThisProcess(logReporter, null, /* anonymize = */ false);
|
||||
|
||||
var weakrefs = [info.weakref.get()
|
||||
for each (info in memory.getObjects())];
|
||||
@ -380,7 +380,7 @@ function getPotentialLeaks() {
|
||||
|
||||
Cc["@mozilla.org/memory-reporter-manager;1"]
|
||||
.getService(Ci.nsIMemoryReporterManager)
|
||||
.getReportsForThisProcess(logReporter, null);
|
||||
.getReportsForThisProcess(logReporter, null, /* anonymize = */ false);
|
||||
|
||||
return { compartments: compartments, windows: windows };
|
||||
}
|
||||
|
@ -420,7 +420,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
// We don't measure the |EventListenerManager| objects pointed to by the
|
||||
// entries because those references are non-owning.
|
||||
|
@ -642,7 +642,7 @@ public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CollectReports(nsIMemoryReporterCallback *aCallback,
|
||||
nsISupports *aClosure)
|
||||
nsISupports *aClosure, bool aAnonymize)
|
||||
{
|
||||
typedef nsDOMMemoryFile::DataOwner DataOwner;
|
||||
|
||||
@ -662,8 +662,7 @@ public:
|
||||
|
||||
if (size < LARGE_OBJECT_MIN_SIZE) {
|
||||
smallObjectsTotal += size;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
SHA1Sum sha1;
|
||||
sha1.update(owner->mData, owner->mLength);
|
||||
uint8_t digest[SHA1Sum::HashSize]; // SHA1 digests are 20 bytes long.
|
||||
@ -678,7 +677,7 @@ public:
|
||||
/* process */ NS_LITERAL_CSTRING(""),
|
||||
nsPrintfCString(
|
||||
"explicit/dom/memory-file-data/large/file(length=%llu, sha1=%s)",
|
||||
owner->mLength, digestString.get()),
|
||||
owner->mLength, aAnonymize ? "<anonymized>" : digestString.get()),
|
||||
KIND_HEAP, UNITS_BYTES, size,
|
||||
nsPrintfCString(
|
||||
"Memory used to back a memory file of length %llu bytes. The file "
|
||||
|
@ -1330,7 +1330,7 @@ ReportReferentCount(const char* aManagerType,
|
||||
|
||||
NS_IMETHODIMP
|
||||
MessageManagerReporter::CollectReports(nsIMemoryReporterCallback* aCb,
|
||||
nsISupports* aClosure)
|
||||
nsISupports* aClosure, bool aAnonymize)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -37,7 +37,7 @@ class HostObjectURLsReporter MOZ_FINAL : public nsIMemoryReporter
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"host-object-urls", KIND_OTHER, UNITS_COUNT,
|
||||
@ -55,11 +55,12 @@ class BlobURLsReporter MOZ_FINAL : public nsIMemoryReporter
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aCallback,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
EnumArg env;
|
||||
env.mCallback = aCallback;
|
||||
env.mData = aData;
|
||||
env.mAnonymize = aAnonymize;
|
||||
|
||||
if (gDataTable) {
|
||||
gDataTable->EnumerateRead(CountCallback, &env);
|
||||
@ -134,6 +135,7 @@ class BlobURLsReporter MOZ_FINAL : public nsIMemoryReporter
|
||||
struct EnumArg {
|
||||
nsIHandleReportCallback* mCallback;
|
||||
nsISupports* mData;
|
||||
bool mAnonymize;
|
||||
nsDataHashtable<nsPtrHashKey<nsIDOMBlob>, uint32_t> mRefCounts;
|
||||
};
|
||||
|
||||
@ -190,16 +192,28 @@ class BlobURLsReporter MOZ_FINAL : public nsIMemoryReporter
|
||||
!owner.IsEmpty()) {
|
||||
owner.ReplaceChar('/', '\\');
|
||||
path += "owner(";
|
||||
path += owner;
|
||||
if (envp->mAnonymize) {
|
||||
path += "<anonymized>";
|
||||
} else {
|
||||
path += owner;
|
||||
}
|
||||
path += ")";
|
||||
} else {
|
||||
path += "owner unknown";
|
||||
}
|
||||
path += "/";
|
||||
path += aInfo->mStack;
|
||||
if (envp->mAnonymize) {
|
||||
path += "<anonymized-stack>";
|
||||
} else {
|
||||
path += aInfo->mStack;
|
||||
}
|
||||
url = aKey;
|
||||
url.ReplaceChar('/', '\\');
|
||||
path += url;
|
||||
if (envp->mAnonymize) {
|
||||
path += "<anonymized-url>";
|
||||
} else {
|
||||
path += url;
|
||||
}
|
||||
if (refCount > 1) {
|
||||
nsAutoCString addrStr;
|
||||
|
||||
|
@ -150,7 +150,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"canvas-2d-pixels", KIND_OTHER, UNITS_BYTES,
|
||||
|
@ -12,7 +12,7 @@ NS_IMPL_ISUPPORTS(WebGLMemoryPressureObserver, nsIObserver)
|
||||
|
||||
NS_IMETHODIMP
|
||||
WebGLMemoryTracker::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
#define REPORT(_path, _kind, _units, _amount, _desc) \
|
||||
do { \
|
||||
|
@ -1743,7 +1743,7 @@ MediaDecoder::IsAppleMP3Enabled()
|
||||
|
||||
NS_IMETHODIMP
|
||||
MediaMemoryTracker::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
int64_t video = 0, audio = 0;
|
||||
size_t resources = 0;
|
||||
|
@ -2751,7 +2751,7 @@ struct ArrayClearer
|
||||
|
||||
NS_IMETHODIMP
|
||||
MediaStreamGraphImpl::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
// Clears out the report array after we're done with it.
|
||||
ArrayClearer reportCleanup(mAudioStreamSizes);
|
||||
@ -2789,17 +2789,17 @@ MediaStreamGraphImpl::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
const char* const nodeType = usage.mNodeType.get();
|
||||
|
||||
nsPrintfCString domNodePath("explicit/webaudio/audio-node/%s/dom-nodes",
|
||||
nodeType);
|
||||
nodeType);
|
||||
REPORT(domNodePath, usage.mDomNode,
|
||||
"Memory used by AudioNode DOM objects (Web Audio).");
|
||||
|
||||
nsPrintfCString enginePath("explicit/webaudio/audio-node/%s/engine-objects",
|
||||
nodeType);
|
||||
nodeType);
|
||||
REPORT(enginePath, usage.mEngine,
|
||||
"Memory used by AudioNode engine objects (Web Audio).");
|
||||
|
||||
nsPrintfCString streamPath("explicit/webaudio/audio-node/%s/stream-objects",
|
||||
nodeType);
|
||||
nodeType);
|
||||
REPORT(streamPath, usage.mStream,
|
||||
"Memory used by AudioNode stream objects (Web Audio).");
|
||||
|
||||
|
@ -675,7 +675,7 @@ AudioContext::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const
|
||||
|
||||
NS_IMETHODIMP
|
||||
AudioContext::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
int64_t amount = SizeOfIncludingThis(MallocSizeOf);
|
||||
return MOZ_COLLECT_REPORT("explicit/webaudio/audiocontext", KIND_HEAP, UNITS_BYTES,
|
||||
|
@ -249,7 +249,7 @@ private:
|
||||
|
||||
size_t SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf) const;
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData);
|
||||
nsISupports* aData, bool aAnonymize);
|
||||
|
||||
friend struct ::mozilla::WebAudioDecodeJob;
|
||||
|
||||
|
@ -816,7 +816,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(ScriptNameSpaceManagerMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsScriptNameSpaceManager::CollectReports(
|
||||
nsIHandleReportCallback* aHandleReport, nsISupports* aData)
|
||||
nsIHandleReportCallback* aHandleReport, nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/script-namespace-manager", KIND_HEAP, UNITS_BYTES,
|
||||
|
@ -162,20 +162,24 @@ GetWindowURI(nsIDOMWindow *aWindow)
|
||||
}
|
||||
|
||||
static void
|
||||
AppendWindowURI(nsGlobalWindow *aWindow, nsACString& aStr)
|
||||
AppendWindowURI(nsGlobalWindow *aWindow, nsACString& aStr, bool aAnonymize)
|
||||
{
|
||||
nsCOMPtr<nsIURI> uri = GetWindowURI(aWindow);
|
||||
|
||||
if (uri) {
|
||||
nsCString spec;
|
||||
uri->GetSpec(spec);
|
||||
if (aAnonymize && !aWindow->IsChromeWindow()) {
|
||||
aStr.AppendPrintf("<anonymized-%d>", aWindow->WindowID());
|
||||
} else {
|
||||
nsCString spec;
|
||||
uri->GetSpec(spec);
|
||||
|
||||
// A hack: replace forward slashes with '\\' so they aren't
|
||||
// treated as path separators. Users of the reporters
|
||||
// (such as about:memory) have to undo this change.
|
||||
spec.ReplaceChar('/', '\\');
|
||||
// A hack: replace forward slashes with '\\' so they aren't
|
||||
// treated as path separators. Users of the reporters
|
||||
// (such as about:memory) have to undo this change.
|
||||
spec.ReplaceChar('/', '\\');
|
||||
|
||||
aStr += spec;
|
||||
aStr += spec;
|
||||
}
|
||||
} else {
|
||||
// If we're unable to find a URI, we're dealing with a chrome window with
|
||||
// no document in it (or somesuch), so we call this a "system window".
|
||||
@ -236,7 +240,8 @@ CollectWindowReports(nsGlobalWindow *aWindow,
|
||||
WindowPaths *aWindowPaths,
|
||||
WindowPaths *aTopWindowPaths,
|
||||
nsIMemoryReporterCallback *aCb,
|
||||
nsISupports *aClosure)
|
||||
nsISupports *aClosure,
|
||||
bool aAnonymize)
|
||||
{
|
||||
nsAutoCString windowPath("explicit/");
|
||||
|
||||
@ -260,6 +265,8 @@ CollectWindowReports(nsGlobalWindow *aWindow,
|
||||
bool ok;
|
||||
nsAutoCString id;
|
||||
if (NS_SUCCEEDED(addonManager->MapURIToAddonID(location, id, &ok)) && ok) {
|
||||
// Add-on names are not privacy-sensitive, so we can use them with
|
||||
// impunity.
|
||||
windowPath += NS_LITERAL_CSTRING("add-ons/") + id +
|
||||
NS_LITERAL_CSTRING("/");
|
||||
}
|
||||
@ -269,7 +276,7 @@ CollectWindowReports(nsGlobalWindow *aWindow,
|
||||
|
||||
if (top) {
|
||||
windowPath += NS_LITERAL_CSTRING("top(");
|
||||
AppendWindowURI(top, windowPath);
|
||||
AppendWindowURI(top, windowPath, aAnonymize);
|
||||
windowPath += NS_LITERAL_CSTRING(", id=");
|
||||
windowPath.AppendInt(top->WindowID());
|
||||
windowPath += NS_LITERAL_CSTRING(")");
|
||||
@ -287,7 +294,7 @@ CollectWindowReports(nsGlobalWindow *aWindow,
|
||||
}
|
||||
|
||||
windowPath += NS_LITERAL_CSTRING("window(");
|
||||
AppendWindowURI(aWindow, windowPath);
|
||||
AppendWindowURI(aWindow, windowPath, aAnonymize);
|
||||
windowPath += NS_LITERAL_CSTRING(")");
|
||||
|
||||
// Use |windowPath|, but replace "explicit/" with "event-counts/".
|
||||
@ -446,16 +453,17 @@ GetWindows(const uint64_t& aId, nsGlobalWindow*& aWindow, void* aClosure)
|
||||
|
||||
struct ReportGhostWindowsEnumeratorData
|
||||
{
|
||||
nsIMemoryReporterCallback* callback;
|
||||
nsISupports* closure;
|
||||
nsresult rv;
|
||||
nsIMemoryReporterCallback* mCallback;
|
||||
nsISupports* mData;
|
||||
bool mAnonymize;
|
||||
nsresult mRv;
|
||||
};
|
||||
|
||||
static PLDHashOperator
|
||||
ReportGhostWindowsEnumerator(nsUint64HashKey* aIDHashKey, void* aClosure)
|
||||
ReportGhostWindowsEnumerator(nsUint64HashKey* aIDHashKey, void* aData)
|
||||
{
|
||||
ReportGhostWindowsEnumeratorData *data =
|
||||
static_cast<ReportGhostWindowsEnumeratorData*>(aClosure);
|
||||
static_cast<ReportGhostWindowsEnumeratorData*>(aData);
|
||||
|
||||
nsGlobalWindow::WindowByIdTable* windowsById =
|
||||
nsGlobalWindow::GetWindowsTable();
|
||||
@ -472,19 +480,19 @@ ReportGhostWindowsEnumerator(nsUint64HashKey* aIDHashKey, void* aClosure)
|
||||
|
||||
nsAutoCString path;
|
||||
path.AppendLiteral("ghost-windows/");
|
||||
AppendWindowURI(window, path);
|
||||
AppendWindowURI(window, path, data->mAnonymize);
|
||||
|
||||
nsresult rv = data->callback->Callback(
|
||||
nsresult rv = data->mCallback->Callback(
|
||||
/* process = */ EmptyCString(),
|
||||
path,
|
||||
nsIMemoryReporter::KIND_OTHER,
|
||||
nsIMemoryReporter::UNITS_COUNT,
|
||||
/* amount = */ 1,
|
||||
/* description = */ NS_LITERAL_CSTRING("A ghost window."),
|
||||
data->closure);
|
||||
data->mData);
|
||||
|
||||
if (NS_FAILED(rv) && NS_SUCCEEDED(data->rv)) {
|
||||
data->rv = rv;
|
||||
if (NS_FAILED(rv) && NS_SUCCEEDED(data->mRv)) {
|
||||
data->mRv = rv;
|
||||
}
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
@ -492,7 +500,7 @@ ReportGhostWindowsEnumerator(nsUint64HashKey* aIDHashKey, void* aClosure)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsWindowMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
|
||||
nsISupports* aClosure)
|
||||
nsISupports* aClosure, bool aAnonymize)
|
||||
{
|
||||
nsGlobalWindow::WindowByIdTable* windowsById =
|
||||
nsGlobalWindow::GetWindowsTable();
|
||||
@ -508,10 +516,10 @@ nsWindowMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
|
||||
nsTHashtable<nsUint64HashKey> ghostWindows;
|
||||
CheckForGhostWindows(&ghostWindows);
|
||||
ReportGhostWindowsEnumeratorData reportGhostWindowsEnumData =
|
||||
{ aCb, aClosure, NS_OK };
|
||||
{ aCb, aClosure, aAnonymize, NS_OK };
|
||||
ghostWindows.EnumerateEntries(ReportGhostWindowsEnumerator,
|
||||
&reportGhostWindowsEnumData);
|
||||
nsresult rv = reportGhostWindowsEnumData.rv;
|
||||
nsresult rv = reportGhostWindowsEnumData.mRv;
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
WindowPaths windowPaths;
|
||||
@ -528,14 +536,14 @@ nsWindowMemoryReporter::CollectReports(nsIMemoryReporterCallback* aCb,
|
||||
rv = CollectWindowReports(windows[i], addonManager,
|
||||
&windowTotalSizes, &ghostWindows,
|
||||
&windowPaths, &topWindowPaths, aCb,
|
||||
aClosure);
|
||||
aClosure, aAnonymize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
// Report JS memory usage. We do this from here because the JS memory
|
||||
// reporter needs to be passed |windowPaths|.
|
||||
rv = xpc::JSReporter::CollectReports(&windowPaths, &topWindowPaths,
|
||||
aCb, aClosure);
|
||||
aCb, aClosure, aAnonymize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
#define REPORT(_path, _amount, _desc) \
|
||||
|
@ -173,7 +173,8 @@ private:
|
||||
static int64_t DistinguishedAmount();
|
||||
|
||||
NS_IMETHOD
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData)
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
|
||||
bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"ghost-windows", KIND_OTHER, UNITS_COUNT, DistinguishedAmount(),
|
||||
|
@ -190,18 +190,22 @@ class MemoryReportRequestChild : public PMemoryReportRequestChild,
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
MemoryReportRequestChild(uint32_t aGeneration, const nsAString& aDMDDumpIdent);
|
||||
MemoryReportRequestChild(uint32_t aGeneration, bool aAnonymize,
|
||||
const nsAString& aDMDDumpIdent);
|
||||
virtual ~MemoryReportRequestChild();
|
||||
NS_IMETHOD Run();
|
||||
private:
|
||||
uint32_t mGeneration;
|
||||
bool mAnonymize;
|
||||
nsString mDMDDumpIdent;
|
||||
};
|
||||
|
||||
NS_IMPL_ISUPPORTS(MemoryReportRequestChild, nsIRunnable)
|
||||
|
||||
MemoryReportRequestChild::MemoryReportRequestChild(uint32_t aGeneration, const nsAString& aDMDDumpIdent)
|
||||
: mGeneration(aGeneration), mDMDDumpIdent(aDMDDumpIdent)
|
||||
MemoryReportRequestChild::MemoryReportRequestChild(
|
||||
uint32_t aGeneration, bool aAnonymize, const nsAString& aDMDDumpIdent)
|
||||
: mGeneration(aGeneration), mAnonymize(aAnonymize),
|
||||
mDMDDumpIdent(aDMDDumpIdent)
|
||||
{
|
||||
MOZ_COUNT_CTOR(MemoryReportRequestChild);
|
||||
}
|
||||
@ -672,11 +676,13 @@ ContentChild::InitXPCOM()
|
||||
}
|
||||
|
||||
PMemoryReportRequestChild*
|
||||
ContentChild::AllocPMemoryReportRequestChild(const uint32_t& generation,
|
||||
const bool &minimizeMemoryUsage,
|
||||
ContentChild::AllocPMemoryReportRequestChild(const uint32_t& aGeneration,
|
||||
const bool &aAnonymize,
|
||||
const bool &aMinimizeMemoryUsage,
|
||||
const nsString& aDMDDumpIdent)
|
||||
{
|
||||
MemoryReportRequestChild *actor = new MemoryReportRequestChild(generation, aDMDDumpIdent);
|
||||
MemoryReportRequestChild *actor =
|
||||
new MemoryReportRequestChild(aGeneration, aAnonymize, aDMDDumpIdent);
|
||||
actor->AddRef();
|
||||
return actor;
|
||||
}
|
||||
@ -724,15 +730,17 @@ NS_IMPL_ISUPPORTS(
|
||||
|
||||
bool
|
||||
ContentChild::RecvPMemoryReportRequestConstructor(
|
||||
PMemoryReportRequestChild* child,
|
||||
const uint32_t& generation,
|
||||
const bool& minimizeMemoryUsage,
|
||||
PMemoryReportRequestChild* aChild,
|
||||
const uint32_t& aGeneration,
|
||||
const bool& aAnonymize,
|
||||
const bool& aMinimizeMemoryUsage,
|
||||
const nsString& aDMDDumpIdent)
|
||||
{
|
||||
MemoryReportRequestChild *actor = static_cast<MemoryReportRequestChild*>(child);
|
||||
MemoryReportRequestChild *actor =
|
||||
static_cast<MemoryReportRequestChild*>(aChild);
|
||||
nsresult rv;
|
||||
|
||||
if (minimizeMemoryUsage) {
|
||||
if (aMinimizeMemoryUsage) {
|
||||
nsCOMPtr<nsIMemoryReporterManager> mgr = do_GetService("@mozilla.org/memory-reporter-manager;1");
|
||||
rv = mgr->MinimizeMemoryUsage(actor);
|
||||
// mgr will eventually call actor->Run()
|
||||
@ -759,7 +767,8 @@ NS_IMETHODIMP MemoryReportRequestChild::Run()
|
||||
nsRefPtr<MemoryReportsWrapper> wrappedReports =
|
||||
new MemoryReportsWrapper(&reports);
|
||||
nsRefPtr<MemoryReportCallback> cb = new MemoryReportCallback(process);
|
||||
mgr->GetReportsForThisProcessExtended(cb, wrappedReports, mDMDDumpIdent);
|
||||
mgr->GetReportsForThisProcessExtended(cb, wrappedReports, mAnonymize,
|
||||
mDMDDumpIdent);
|
||||
|
||||
bool sent = Send__delete__(this, mGeneration, reports);
|
||||
return sent ? NS_OK : NS_ERROR_FAILURE;
|
||||
|
@ -152,16 +152,18 @@ public:
|
||||
virtual bool DeallocPIndexedDBChild(PIndexedDBChild* aActor) MOZ_OVERRIDE;
|
||||
|
||||
virtual PMemoryReportRequestChild*
|
||||
AllocPMemoryReportRequestChild(const uint32_t& generation,
|
||||
const bool &minimizeMemoryUsage,
|
||||
const nsString &aDMDDumpIdent) MOZ_OVERRIDE;
|
||||
AllocPMemoryReportRequestChild(const uint32_t& aGeneration,
|
||||
const bool& aAnonymize,
|
||||
const bool& aMinimizeMemoryUsage,
|
||||
const nsString& aDMDDumpIdent) MOZ_OVERRIDE;
|
||||
virtual bool
|
||||
DeallocPMemoryReportRequestChild(PMemoryReportRequestChild* actor) MOZ_OVERRIDE;
|
||||
|
||||
virtual bool
|
||||
RecvPMemoryReportRequestConstructor(PMemoryReportRequestChild* child,
|
||||
const uint32_t& generation,
|
||||
const bool &minimizeMemoryUsage,
|
||||
RecvPMemoryReportRequestConstructor(PMemoryReportRequestChild* aChild,
|
||||
const uint32_t& aGeneration,
|
||||
const bool& aAnonymize,
|
||||
const bool &aMinimizeMemoryUsage,
|
||||
const nsString &aDMDDumpIdent) MOZ_OVERRIDE;
|
||||
|
||||
virtual PCycleCollectWithLogsChild*
|
||||
|
@ -454,7 +454,8 @@ NS_IMPL_ISUPPORTS(ContentParentsMemoryReporter, nsIMemoryReporter)
|
||||
|
||||
NS_IMETHODIMP
|
||||
ContentParentsMemoryReporter::CollectReports(nsIMemoryReporterCallback* cb,
|
||||
nsISupports* aClosure)
|
||||
nsISupports* aClosure,
|
||||
bool aAnonymize)
|
||||
{
|
||||
nsAutoTArray<ContentParent*, 16> cps;
|
||||
ContentParent::GetAllEvenIfDead(cps);
|
||||
@ -464,7 +465,7 @@ ContentParentsMemoryReporter::CollectReports(nsIMemoryReporterCallback* cb,
|
||||
MessageChannel* channel = cp->GetIPCChannel();
|
||||
|
||||
nsString friendlyName;
|
||||
cp->FriendlyName(friendlyName);
|
||||
cp->FriendlyName(friendlyName, aAnonymize);
|
||||
|
||||
cp->AddRef();
|
||||
nsrefcnt refcnt = cp->Release();
|
||||
@ -2423,13 +2424,13 @@ ContentParent::Observe(nsISupports* aSubject,
|
||||
#endif
|
||||
if (!isNuwa) {
|
||||
unsigned generation;
|
||||
int minimize, identOffset = -1;
|
||||
int anonymize, minimize, identOffset = -1;
|
||||
nsDependentString msg(aData);
|
||||
NS_ConvertUTF16toUTF8 cmsg(msg);
|
||||
|
||||
if (sscanf(cmsg.get(),
|
||||
"generation=%x minimize=%d DMDident=%n",
|
||||
&generation, &minimize, &identOffset) < 2
|
||||
"generation=%x anonymize=%d minimize=%d DMDident=%n",
|
||||
&generation, &anonymize, &minimize, &identOffset) < 3
|
||||
|| identOffset < 0) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
@ -2437,7 +2438,8 @@ ContentParent::Observe(nsISupports* aSubject,
|
||||
// offset in identOffset should be correct as a char offset.
|
||||
MOZ_ASSERT(cmsg[identOffset - 1] == '=');
|
||||
unused << SendPMemoryReportRequestConstructor(
|
||||
generation, minimize, nsString(Substring(msg, identOffset)));
|
||||
generation, anonymize, minimize,
|
||||
nsString(Substring(msg, identOffset)));
|
||||
}
|
||||
}
|
||||
else if (!strcmp(aTopic, "child-gc-request")){
|
||||
@ -2678,7 +2680,7 @@ ContentParent::IsPreallocated()
|
||||
}
|
||||
|
||||
void
|
||||
ContentParent::FriendlyName(nsAString& aName)
|
||||
ContentParent::FriendlyName(nsAString& aName, bool aAnonymize)
|
||||
{
|
||||
aName.Truncate();
|
||||
#ifdef MOZ_NUWA_PROCESS
|
||||
@ -2690,6 +2692,8 @@ ContentParent::FriendlyName(nsAString& aName)
|
||||
aName.AssignLiteral("(Preallocated)");
|
||||
} else if (mIsForBrowser) {
|
||||
aName.AssignLiteral("Browser");
|
||||
} else if (aAnonymize) {
|
||||
aName.AssignLiteral("<anonymized-name>");
|
||||
} else if (!mAppName.IsEmpty()) {
|
||||
aName = mAppName;
|
||||
} else if (!mAppManifestURL.IsEmpty()) {
|
||||
@ -2777,8 +2781,9 @@ ContentParent::RecvPIndexedDBConstructor(PIndexedDBParent* aActor)
|
||||
}
|
||||
|
||||
PMemoryReportRequestParent*
|
||||
ContentParent::AllocPMemoryReportRequestParent(const uint32_t& generation,
|
||||
const bool &minimizeMemoryUsage,
|
||||
ContentParent::AllocPMemoryReportRequestParent(const uint32_t& aGeneration,
|
||||
const bool &aAnonymize,
|
||||
const bool &aMinimizeMemoryUsage,
|
||||
const nsString &aDMDDumpIdent)
|
||||
{
|
||||
MemoryReportRequestParent* parent = new MemoryReportRequestParent();
|
||||
|
@ -208,7 +208,7 @@ public:
|
||||
* etc. So please don't use this name to make any decisions about the
|
||||
* ContentParent based on the value returned here.
|
||||
*/
|
||||
void FriendlyName(nsAString& aName);
|
||||
void FriendlyName(nsAString& aName, bool aAnonymize = false);
|
||||
|
||||
virtual void OnChannelError() MOZ_OVERRIDE;
|
||||
|
||||
@ -418,8 +418,9 @@ private:
|
||||
virtual bool DeallocPIndexedDBParent(PIndexedDBParent* aActor) MOZ_OVERRIDE;
|
||||
|
||||
virtual PMemoryReportRequestParent*
|
||||
AllocPMemoryReportRequestParent(const uint32_t& generation,
|
||||
const bool &minimizeMemoryUsage,
|
||||
AllocPMemoryReportRequestParent(const uint32_t& aGeneration,
|
||||
const bool &aAnonymize,
|
||||
const bool &aMinimizeMemoryUsage,
|
||||
const nsString &aDMDDumpIdent) MOZ_OVERRIDE;
|
||||
virtual bool DeallocPMemoryReportRequestParent(PMemoryReportRequestParent* actor) MOZ_OVERRIDE;
|
||||
|
||||
|
@ -350,7 +350,8 @@ child:
|
||||
*/
|
||||
async SetProcessSandbox();
|
||||
|
||||
PMemoryReportRequest(uint32_t generation, bool minimizeMemoryUsage, nsString DMDDumpIdent);
|
||||
PMemoryReportRequest(uint32_t generation, bool anonymize,
|
||||
bool minimizeMemoryUsage, nsString DMDDumpIdent);
|
||||
|
||||
/**
|
||||
* Notify the AudioChannelService in the child processes.
|
||||
|
@ -385,7 +385,7 @@ SettingsManager.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
collectReports: function(aCallback, aData) {
|
||||
collectReports: function(aCallback, aData, aAnonymize) {
|
||||
for (var topic in this._callbacks) {
|
||||
let length = this._callbacks[topic].length;
|
||||
if (length == 0) {
|
||||
@ -396,7 +396,8 @@ SettingsManager.prototype = {
|
||||
if (length < 20) {
|
||||
path = "settings-observers";
|
||||
} else {
|
||||
path = "settings-observers-suspect/referent(topic=" + topic + ")";
|
||||
path = "settings-observers-suspect/referent(topic=" +
|
||||
(aAnonymize ? "<anonymized>" : topic) + ")";
|
||||
}
|
||||
|
||||
aCallback.callback("", path,
|
||||
|
@ -1758,6 +1758,8 @@ public:
|
||||
// This should never be used when reporting with workers (hence the "?!").
|
||||
extras->domPathPrefix.AssignLiteral("explicit/workers/?!/");
|
||||
|
||||
extras->location = nullptr;
|
||||
|
||||
aCompartmentStats->extra = extras;
|
||||
}
|
||||
};
|
||||
@ -1975,7 +1977,6 @@ class WorkerPrivate::MemoryReporter MOZ_FINAL : public nsIMemoryReporter
|
||||
|
||||
SharedMutex mMutex;
|
||||
WorkerPrivate* mWorkerPrivate;
|
||||
nsCString mRtPath;
|
||||
bool mAlreadyMappedToAddon;
|
||||
|
||||
public:
|
||||
@ -1985,45 +1986,52 @@ public:
|
||||
{
|
||||
aWorkerPrivate->AssertIsOnWorkerThread();
|
||||
|
||||
nsCString escapedDomain(aWorkerPrivate->Domain());
|
||||
escapedDomain.ReplaceChar('/', '\\');
|
||||
|
||||
NS_ConvertUTF16toUTF8 escapedURL(aWorkerPrivate->ScriptURL());
|
||||
escapedURL.ReplaceChar('/', '\\');
|
||||
|
||||
nsAutoCString addressString;
|
||||
addressString.AppendPrintf("0x%p", static_cast<void*>(aWorkerPrivate));
|
||||
|
||||
mRtPath = NS_LITERAL_CSTRING("explicit/workers/workers(") +
|
||||
escapedDomain + NS_LITERAL_CSTRING(")/worker(") +
|
||||
escapedURL + NS_LITERAL_CSTRING(", ") + addressString +
|
||||
NS_LITERAL_CSTRING(")/");
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
CollectReports(nsIMemoryReporterCallback* aCallback,
|
||||
nsISupports* aClosure)
|
||||
nsISupports* aClosure, bool aAnonymize)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
|
||||
// Assumes that WorkerJSRuntimeStats will hold a reference to mRtPath,
|
||||
// and not a copy, as TryToMapAddon() may later modify the string again.
|
||||
WorkerJSRuntimeStats rtStats(mRtPath);
|
||||
// Assumes that WorkerJSRuntimeStats will hold a reference to |path|, and
|
||||
// not a copy, as TryToMapAddon() may later modify if.
|
||||
nsCString path;
|
||||
WorkerJSRuntimeStats rtStats(path);
|
||||
|
||||
{
|
||||
MutexAutoLock lock(mMutex);
|
||||
|
||||
TryToMapAddon();
|
||||
path.AppendLiteral("explicit/workers/workers(");
|
||||
if (aAnonymize && !mWorkerPrivate->Domain().IsEmpty()) {
|
||||
path.AppendLiteral("<anonymized-domain>)/worker(<anonymized-url>");
|
||||
} else {
|
||||
nsCString escapedDomain(mWorkerPrivate->Domain());
|
||||
if (escapedDomain.IsEmpty()) {
|
||||
escapedDomain += "chrome";
|
||||
} else {
|
||||
escapedDomain.ReplaceChar('/', '\\');
|
||||
}
|
||||
path.Append(escapedDomain);
|
||||
path.AppendLiteral(")/worker(");
|
||||
NS_ConvertUTF16toUTF8 escapedURL(mWorkerPrivate->ScriptURL());
|
||||
escapedURL.ReplaceChar('/', '\\');
|
||||
path.Append(escapedURL);
|
||||
}
|
||||
path.AppendPrintf(", 0x%p)/", static_cast<void*>(mWorkerPrivate));
|
||||
|
||||
TryToMapAddon(path);
|
||||
|
||||
if (!mWorkerPrivate ||
|
||||
!mWorkerPrivate->BlockAndCollectRuntimeStats(&rtStats)) {
|
||||
!mWorkerPrivate->BlockAndCollectRuntimeStats(&rtStats, aAnonymize)) {
|
||||
// Returning NS_OK here will effectively report 0 memory.
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return xpc::ReportJSRuntimeExplicitTreeStats(rtStats, mRtPath,
|
||||
aCallback, aClosure);
|
||||
return xpc::ReportJSRuntimeExplicitTreeStats(rtStats, path,
|
||||
aCallback, aClosure,
|
||||
aAnonymize);
|
||||
}
|
||||
|
||||
private:
|
||||
@ -2042,7 +2050,7 @@ private:
|
||||
|
||||
// Only call this from the main thread and under mMutex lock.
|
||||
void
|
||||
TryToMapAddon()
|
||||
TryToMapAddon(nsACString &path)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
mMutex.AssertCurrentThreadOwns();
|
||||
@ -2078,7 +2086,7 @@ private:
|
||||
static const size_t explicitLength = strlen("explicit/");
|
||||
addonId.Insert(NS_LITERAL_CSTRING("add-ons/"), 0);
|
||||
addonId += "/";
|
||||
mRtPath.Insert(addonId, explicitLength);
|
||||
path.Insert(addonId, explicitLength);
|
||||
}
|
||||
};
|
||||
|
||||
@ -4301,7 +4309,8 @@ WorkerPrivate::ScheduleDeletion(WorkerRanOrNot aRanOrNot)
|
||||
}
|
||||
|
||||
bool
|
||||
WorkerPrivate::BlockAndCollectRuntimeStats(JS::RuntimeStats* aRtStats)
|
||||
WorkerPrivate::BlockAndCollectRuntimeStats(JS::RuntimeStats* aRtStats,
|
||||
bool aAnonymize)
|
||||
{
|
||||
AssertIsOnMainThread();
|
||||
mMutex.AssertCurrentThreadOwns();
|
||||
@ -4334,7 +4343,7 @@ WorkerPrivate::BlockAndCollectRuntimeStats(JS::RuntimeStats* aRtStats)
|
||||
if (mMemoryReporter) {
|
||||
// Don't hold the lock while doing the actual report.
|
||||
MutexAutoUnlock unlock(mMutex);
|
||||
succeeded = JS::CollectRuntimeStats(rt, aRtStats, nullptr);
|
||||
succeeded = JS::CollectRuntimeStats(rt, aRtStats, nullptr, aAnonymize);
|
||||
}
|
||||
|
||||
NS_ASSERTION(mMemoryReporterRunning, "This isn't possible!");
|
||||
|
@ -948,7 +948,7 @@ public:
|
||||
ScheduleDeletion(WorkerRanOrNot aRanOrNot);
|
||||
|
||||
bool
|
||||
BlockAndCollectRuntimeStats(JS::RuntimeStats* aRtStats);
|
||||
BlockAndCollectRuntimeStats(JS::RuntimeStats* aRtStats, bool aAnonymize);
|
||||
|
||||
#ifdef JS_GC_ZEAL
|
||||
void
|
||||
|
@ -103,7 +103,7 @@ public:
|
||||
nsresult ConvertCharset(const char16_t* aStr, char ** aDst);
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/spell-check", KIND_HEAP, UNITS_BYTES, HunspellAllocator::MemoryAllocated(),
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
int32_t tileWidth, int32_t tileHeight);
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"gfx-textures", KIND_OTHER, UNITS_BYTES, sAmount,
|
||||
|
@ -210,7 +210,7 @@ public:
|
||||
}
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/gfx/heap-textures", KIND_HEAP, UNITS_BYTES, sAmount,
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
map<base::ProcessId, SharedBufferManagerParent*>::iterator it;
|
||||
for (it = SharedBufferManagerParent::sManagers.begin(); it != SharedBufferManagerParent::sManagers.end(); it++) {
|
||||
|
@ -586,7 +586,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CollectReports(nsIMemoryReporterCallback *aCb,
|
||||
nsISupports *aClosure)
|
||||
nsISupports *aClosure, bool aAnonymize)
|
||||
{
|
||||
const size_t len = ArrayLength(sSurfaceMemoryReporterAttrs);
|
||||
for (size_t i = 0; i < len; i++) {
|
||||
|
@ -63,7 +63,7 @@ public:
|
||||
}
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/freetype", KIND_HEAP, UNITS_BYTES, MemoryAllocated(),
|
||||
|
@ -1740,9 +1740,8 @@ MOZ_DEFINE_MALLOC_SIZE_OF(FontCacheMallocSizeOf)
|
||||
NS_IMPL_ISUPPORTS(gfxFontCache::MemoryReporter, nsIMemoryReporter)
|
||||
|
||||
NS_IMETHODIMP
|
||||
gfxFontCache::MemoryReporter::CollectReports
|
||||
(nsIMemoryReporterCallback* aCb,
|
||||
nsISupports* aClosure)
|
||||
gfxFontCache::MemoryReporter::CollectReports(
|
||||
nsIMemoryReporterCallback* aCb, nsISupports* aClosure, bool aAnonymize)
|
||||
{
|
||||
FontCacheSizes sizes;
|
||||
|
||||
|
@ -128,9 +128,8 @@ MOZ_DEFINE_MALLOC_SIZE_OF(FontListMallocSizeOf)
|
||||
NS_IMPL_ISUPPORTS(gfxPlatformFontList::MemoryReporter, nsIMemoryReporter)
|
||||
|
||||
NS_IMETHODIMP
|
||||
gfxPlatformFontList::MemoryReporter::CollectReports
|
||||
(nsIMemoryReporterCallback* aCb,
|
||||
nsISupports* aClosure)
|
||||
gfxPlatformFontList::MemoryReporter::CollectReports(
|
||||
nsIMemoryReporterCallback* aCb, nsISupports* aClosure, bool aAnonymize)
|
||||
{
|
||||
FontListSizes sizes;
|
||||
sizes.mFontListSize = 0;
|
||||
@ -140,17 +139,20 @@ gfxPlatformFontList::MemoryReporter::CollectReports
|
||||
gfxPlatformFontList::PlatformFontList()->AddSizeOfIncludingThis(&FontListMallocSizeOf,
|
||||
&sizes);
|
||||
|
||||
aCb->Callback(EmptyCString(),
|
||||
NS_LITERAL_CSTRING("explicit/gfx/font-list"),
|
||||
KIND_HEAP, UNITS_BYTES, sizes.mFontListSize,
|
||||
NS_LITERAL_CSTRING("Memory used to manage the list of font families and faces."),
|
||||
aClosure);
|
||||
nsresult rv;
|
||||
rv = aCb->Callback(EmptyCString(),
|
||||
NS_LITERAL_CSTRING("explicit/gfx/font-list"),
|
||||
KIND_HEAP, UNITS_BYTES, sizes.mFontListSize,
|
||||
NS_LITERAL_CSTRING("Memory used to manage the list of font families and faces."),
|
||||
aClosure);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
aCb->Callback(EmptyCString(),
|
||||
NS_LITERAL_CSTRING("explicit/gfx/font-charmaps"),
|
||||
KIND_HEAP, UNITS_BYTES, sizes.mCharMapsSize,
|
||||
NS_LITERAL_CSTRING("Memory used to record the character coverage of individual fonts."),
|
||||
aClosure);
|
||||
rv = aCb->Callback(EmptyCString(),
|
||||
NS_LITERAL_CSTRING("explicit/gfx/font-charmaps"),
|
||||
KIND_HEAP, UNITS_BYTES, sizes.mCharMapsSize,
|
||||
NS_LITERAL_CSTRING("Memory used to record the character coverage of individual fonts."),
|
||||
aClosure);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (sizes.mFontTableCacheSize) {
|
||||
aCb->Callback(EmptyCString(),
|
||||
|
@ -87,7 +87,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -119,7 +119,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -175,7 +175,7 @@ public:
|
||||
|
||||
NS_IMETHOD
|
||||
CollectReports(nsIMemoryReporterCallback* aCb,
|
||||
nsISupports* aClosure)
|
||||
nsISupports* aClosure, bool aAnonymize)
|
||||
{
|
||||
HANDLE ProcessHandle = GetCurrentProcess();
|
||||
|
||||
@ -188,7 +188,7 @@ public:
|
||||
PFND3DKMTQS queryD3DKMTStatistics;
|
||||
|
||||
// GPU memory reporting is not available before Windows 7
|
||||
if (!IsWin7OrLater())
|
||||
if (!IsWin7OrLater())
|
||||
return NS_OK;
|
||||
|
||||
if (gdi32Handle = LoadLibrary(TEXT("gdi32.dll")))
|
||||
|
@ -366,7 +366,8 @@ public:
|
||||
}
|
||||
|
||||
NS_IMETHOD
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData)
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
|
||||
bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"imagelib-surface-cache", KIND_OTHER, UNITS_BYTES,
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CollectReports(nsIMemoryReporterCallback *aHandleReport,
|
||||
nsISupports *aData)
|
||||
nsISupports *aData, bool aAnonymize)
|
||||
{
|
||||
nsresult rv;
|
||||
ImageSizes chrome;
|
||||
@ -67,6 +67,8 @@ public:
|
||||
mKnownLoaders[i]->mCache.EnumerateRead(EntryImageSizes, &content);
|
||||
}
|
||||
|
||||
// Note that we only need to anonymize content image URIs.
|
||||
|
||||
rv = ReportInfoArray(aHandleReport, aData, chrome.mRasterUsedImageInfo,
|
||||
"images/chrome/raster/used");
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
@ -84,19 +86,19 @@ public:
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = ReportInfoArray(aHandleReport, aData, content.mRasterUsedImageInfo,
|
||||
"images/content/raster/used");
|
||||
"images/content/raster/used", aAnonymize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = ReportInfoArray(aHandleReport, aData, content.mRasterUnusedImageInfo,
|
||||
"images/content/raster/unused");
|
||||
"images/content/raster/unused", aAnonymize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = ReportInfoArray(aHandleReport, aData, content.mVectorUsedImageDocInfo,
|
||||
"images/content/vector/used/documents");
|
||||
"images/content/vector/used/documents", aAnonymize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
rv = ReportInfoArray(aHandleReport, aData, content.mVectorUnusedImageDocInfo,
|
||||
"images/content/vector/unused/documents");
|
||||
"images/content/vector/unused/documents", aAnonymize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
return NS_OK;
|
||||
@ -201,7 +203,7 @@ private:
|
||||
nsresult ReportInfoArray(nsIMemoryReporterCallback *aHandleReport,
|
||||
nsISupports *aData,
|
||||
const nsTArray<ImageInfo<Sizes> > &aInfoArray,
|
||||
const char *aPathPartStr)
|
||||
const char *aPathPartStr, bool aAnonymize = false)
|
||||
{
|
||||
nsresult rv;
|
||||
Sizes totalSizes;
|
||||
@ -214,14 +216,20 @@ private:
|
||||
// Report notable images, and compute total and non-notable aggregate sizes.
|
||||
for (uint32_t i = 0; i < aInfoArray.Length(); i++) {
|
||||
ImageInfo<Sizes> info = aInfoArray[i];
|
||||
// info.mURI can be a data: URI, and thus extremely long. Truncate if
|
||||
// necessary.
|
||||
static const size_t max = 256;
|
||||
if (info.mURI.Length() > max) {
|
||||
info.mURI.Truncate(max);
|
||||
info.mURI.AppendLiteral(" (truncated)");
|
||||
|
||||
if (aAnonymize) {
|
||||
info.mURI.Truncate();
|
||||
info.mURI.AppendPrintf("<anonymized-%u>", i);
|
||||
} else {
|
||||
// info.mURI can be a data: URI, and thus extremely long. Truncate if
|
||||
// necessary.
|
||||
static const size_t max = 256;
|
||||
if (info.mURI.Length() > max) {
|
||||
info.mURI.Truncate(max);
|
||||
info.mURI.AppendLiteral(" (truncated)");
|
||||
}
|
||||
info.mURI.ReplaceChar('/', '\\');
|
||||
}
|
||||
info.mURI.ReplaceChar('/', '\\');
|
||||
|
||||
totalSizes.add(info.mSizes);
|
||||
|
||||
|
@ -30,7 +30,7 @@ window.onload = function() {
|
||||
amount += aAmount;
|
||||
}
|
||||
|
||||
mgr.getReportsForThisProcess(handleReport, null);
|
||||
mgr.getReportsForThisProcess(handleReport, null, /* anonymize = */ false);
|
||||
|
||||
ok(amount > 0, "we should be using a nonzero amount of memory");
|
||||
ok(true, "yay, didn't crash!");
|
||||
|
@ -23,7 +23,8 @@ public:
|
||||
NS_DECL_THREADSAFE_ISUPPORTS
|
||||
|
||||
NS_IMETHOD
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData)
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
|
||||
bool aAnonymize)
|
||||
{
|
||||
nsresult rv;
|
||||
rv = MOZ_COLLECT_REPORT(
|
||||
|
@ -635,7 +635,7 @@ class ObjectPrivateVisitor
|
||||
};
|
||||
|
||||
extern JS_PUBLIC_API(bool)
|
||||
CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats, ObjectPrivateVisitor *opv);
|
||||
CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats, ObjectPrivateVisitor *opv, bool anonymize);
|
||||
|
||||
extern JS_PUBLIC_API(size_t)
|
||||
SystemCompartmentCount(JSRuntime *rt);
|
||||
|
@ -196,7 +196,14 @@ struct StatsClosure
|
||||
RuntimeStats *rtStats;
|
||||
ObjectPrivateVisitor *opv;
|
||||
SourceSet seenSources;
|
||||
StatsClosure(RuntimeStats *rt, ObjectPrivateVisitor *v) : rtStats(rt), opv(v) {}
|
||||
bool anonymize;
|
||||
|
||||
StatsClosure(RuntimeStats *rt, ObjectPrivateVisitor *v, bool anon)
|
||||
: rtStats(rt),
|
||||
opv(v),
|
||||
anonymize(anon)
|
||||
{}
|
||||
|
||||
bool init() {
|
||||
return seenSources.init();
|
||||
}
|
||||
@ -287,9 +294,13 @@ GetCompartmentStats(JSCompartment *comp)
|
||||
return static_cast<CompartmentStats *>(comp->compartmentStats);
|
||||
}
|
||||
|
||||
// FineGrained is used for normal memory reporting. CoarseGrained is used by
|
||||
// AddSizeOfTab(), which aggregates all the measurements into a handful of
|
||||
// high-level numbers, which means that fine-grained reporting would be a waste
|
||||
// of effort.
|
||||
enum Granularity {
|
||||
FineGrained, // Corresponds to CollectRuntimeStats()
|
||||
CoarseGrained // Corresponds to AddSizeOfTab()
|
||||
FineGrained,
|
||||
CoarseGrained
|
||||
};
|
||||
|
||||
// The various kinds of hashing are expensive, and the results are unused when
|
||||
@ -336,7 +347,10 @@ StatsCellCallback(JSRuntime *rt, void *data, void *thing, JSGCTraceKind traceKin
|
||||
|
||||
zStats->stringInfo.add(info);
|
||||
|
||||
if (granularity == FineGrained) {
|
||||
// The primary use case for anonymization is automated crash submission
|
||||
// (to help detect OOM crashes). In that case, we don't want to pay the
|
||||
// memory cost required to do notable string detection.
|
||||
if (granularity == FineGrained && !closure->anonymize) {
|
||||
ZoneStats::StringsHashMap::AddPtr p = zStats->allStrings->lookupForAdd(str);
|
||||
if (!p) {
|
||||
// Ignore failure -- we just won't record the string as notable.
|
||||
@ -532,7 +546,8 @@ FindNotableScriptSources(JS::RuntimeSizes &runtime)
|
||||
}
|
||||
|
||||
JS_PUBLIC_API(bool)
|
||||
JS::CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats, ObjectPrivateVisitor *opv)
|
||||
JS::CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats, ObjectPrivateVisitor *opv,
|
||||
bool anonymize)
|
||||
{
|
||||
if (!rtStats->compartmentStatsVector.reserve(rt->numCompartments))
|
||||
return false;
|
||||
@ -550,11 +565,14 @@ JS::CollectRuntimeStats(JSRuntime *rt, RuntimeStats *rtStats, ObjectPrivateVisit
|
||||
DecommittedArenasChunkCallback);
|
||||
|
||||
// Take the per-compartment measurements.
|
||||
StatsClosure closure(rtStats, opv);
|
||||
StatsClosure closure(rtStats, opv, anonymize);
|
||||
if (!closure.init())
|
||||
return false;
|
||||
IterateZonesCompartmentsArenasCells(rt, &closure, StatsZoneCallback, StatsCompartmentCallback,
|
||||
StatsArenaCallback, StatsCellCallback<FineGrained>);
|
||||
IterateZonesCompartmentsArenasCells(rt, &closure,
|
||||
StatsZoneCallback,
|
||||
StatsCompartmentCallback,
|
||||
StatsArenaCallback,
|
||||
StatsCellCallback<FineGrained>);
|
||||
|
||||
// Take the "explicit/js/runtime/" measurements.
|
||||
rt->addSizeOfIncludingThis(rtStats->mallocSizeOf_, &rtStats->runtime);
|
||||
@ -674,8 +692,9 @@ AddSizeOfTab(JSRuntime *rt, HandleObject obj, MallocSizeOf mallocSizeOf, ObjectP
|
||||
if (!rtStats.zoneStatsVector.reserve(1))
|
||||
return false;
|
||||
|
||||
// Take the per-compartment measurements.
|
||||
StatsClosure closure(&rtStats, opv);
|
||||
// Take the per-compartment measurements. No need to anonymize because
|
||||
// these measurements will be aggregated.
|
||||
StatsClosure closure(&rtStats, opv, /* anonymize = */ false);
|
||||
if (!closure.init())
|
||||
return false;
|
||||
IterateZoneCompartmentsArenasCells(rt, zone, &closure, StatsZoneCallback,
|
||||
|
@ -24,7 +24,8 @@ public:
|
||||
static nsresult CollectReports(WindowPaths *windowPaths,
|
||||
WindowPaths *topWindowPaths,
|
||||
nsIMemoryReporterCallback *cb,
|
||||
nsISupports *closure);
|
||||
nsISupports *closure,
|
||||
bool anonymize);
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1457,6 +1457,7 @@ XPCJSRuntime::CustomOutOfMemoryCallback()
|
||||
|
||||
// If this fails, it fails silently.
|
||||
dumper->DumpMemoryInfoToTempDir(NS_LITERAL_STRING("due-to-JS-OOM"),
|
||||
/* anonymize = */ false,
|
||||
/* minimizeMemoryUsage = */ false);
|
||||
}
|
||||
|
||||
@ -1681,11 +1682,17 @@ XPCJSRuntime::~XPCJSRuntime()
|
||||
Preferences::UnregisterCallback(ReloadPrefsCallback, JS_OPTIONS_DOT_STR, this);
|
||||
}
|
||||
|
||||
// If |*anonymizeID| is non-zero and this is a user compartment, the name will
|
||||
// be anonymized.
|
||||
static void
|
||||
GetCompartmentName(JSCompartment *c, nsCString &name, bool replaceSlashes)
|
||||
GetCompartmentName(JSCompartment *c, nsCString &name, int *anonymizeID,
|
||||
bool replaceSlashes)
|
||||
{
|
||||
if (js::IsAtomsCompartment(c)) {
|
||||
name.AssignLiteral("atoms");
|
||||
} else if (*anonymizeID && !js::IsSystemCompartment(c)) {
|
||||
name.AppendPrintf("<anonymized-%d>", *anonymizeID);
|
||||
*anonymizeID += 1;
|
||||
} else if (JSPrincipals *principals = JS_GetCompartmentPrincipals(c)) {
|
||||
nsJSPrincipals::get(principals)->GetScriptLocation(name);
|
||||
|
||||
@ -1702,6 +1709,31 @@ GetCompartmentName(JSCompartment *c, nsCString &name, bool replaceSlashes)
|
||||
}
|
||||
}
|
||||
|
||||
// We might have a file:// URL that includes paths from the local
|
||||
// filesystem, which should be omitted if we're anonymizing.
|
||||
if (*anonymizeID) {
|
||||
static const char *filePrefix = "file://";
|
||||
int filePos = name.Find(filePrefix);
|
||||
if (filePos >= 0) {
|
||||
int pathPos = filePos + strlen(filePrefix);
|
||||
int lastSlashPos = -1;
|
||||
for (int i = pathPos; i < int(name.Length()); i++) {
|
||||
if (name[i] == '/' || name[i] == '\\') {
|
||||
lastSlashPos = i;
|
||||
}
|
||||
}
|
||||
if (lastSlashPos != -1) {
|
||||
name.ReplaceASCII(pathPos, lastSlashPos - pathPos,
|
||||
"<anonymized>");
|
||||
} else {
|
||||
// Something went wrong. Anonymize the entire path to be
|
||||
// safe.
|
||||
name.Truncate(pathPos);
|
||||
name += "<anonymized?!>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A hack: replace forward slashes with '\\' so they aren't
|
||||
// treated as path separators. Users of the reporters
|
||||
// (such as about:memory) have to undo this change.
|
||||
@ -1747,7 +1779,7 @@ class JSMainRuntimeTemporaryPeakReporter MOZ_FINAL : public nsIMemoryReporter
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT("js-main-runtime-temporary-peak",
|
||||
KIND_OTHER, UNITS_BYTES,
|
||||
@ -1850,7 +1882,9 @@ static nsresult
|
||||
ReportZoneStats(const JS::ZoneStats &zStats,
|
||||
const xpc::ZoneStatsExtras &extras,
|
||||
nsIMemoryReporterCallback *cb,
|
||||
nsISupports *closure, size_t *gcTotalOut = nullptr)
|
||||
nsISupports *closure,
|
||||
bool anonymize,
|
||||
size_t *gcTotalOut = nullptr)
|
||||
{
|
||||
const nsAutoCString& pathPrefix = extras.pathPrefix;
|
||||
size_t gcTotal = 0, sundriesGCHeap = 0, sundriesMallocHeap = 0;
|
||||
@ -1906,6 +1940,11 @@ ReportZoneStats(const JS::ZoneStats &zStats,
|
||||
|
||||
MOZ_ASSERT(!zStats.isTotals);
|
||||
|
||||
// We don't do notable string detection when anonymizing, because
|
||||
// there's a good chance its for crash submission, and the memory
|
||||
// required for notable string detection is high.
|
||||
MOZ_ASSERT(!anonymize);
|
||||
|
||||
nsDependentCString notableString(info.buffer);
|
||||
|
||||
// Viewing about:memory generates many notable strings which contain
|
||||
@ -1949,7 +1988,7 @@ ReportZoneStats(const JS::ZoneStats &zStats,
|
||||
}
|
||||
|
||||
nsCString nonNotablePath = pathPrefix;
|
||||
nonNotablePath += zStats.isTotals
|
||||
nonNotablePath += (zStats.isTotals || anonymize)
|
||||
? NS_LITERAL_CSTRING("strings/")
|
||||
: NS_LITERAL_CSTRING("strings/string(<non-notable strings>)/");
|
||||
|
||||
@ -2273,7 +2312,9 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats,
|
||||
const nsACString &rtPath,
|
||||
amIAddonManager* addonManager,
|
||||
nsIMemoryReporterCallback *cb,
|
||||
nsISupports *closure, size_t *rtTotalOut)
|
||||
nsISupports *closure,
|
||||
bool anonymize,
|
||||
size_t *rtTotalOut)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
@ -2283,7 +2324,7 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats,
|
||||
const JS::ZoneStats &zStats = rtStats.zoneStatsVector[i];
|
||||
const xpc::ZoneStatsExtras *extras =
|
||||
static_cast<const xpc::ZoneStatsExtras*>(zStats.extra);
|
||||
rv = ReportZoneStats(zStats, *extras, cb, closure, &gcTotal);
|
||||
rv = ReportZoneStats(zStats, *extras, cb, closure, anonymize, &gcTotal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -2356,9 +2397,14 @@ ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats,
|
||||
// count as path separators. Consumers of memory reporters (e.g.
|
||||
// about:memory) will convert them back to / after doing path
|
||||
// splitting.
|
||||
nsDependentCString filename(scriptSourceInfo.filename_);
|
||||
nsCString escapedFilename(filename);
|
||||
escapedFilename.ReplaceSubstring("/", "\\");
|
||||
nsCString escapedFilename;
|
||||
if (anonymize) {
|
||||
escapedFilename.AppendPrintf("<anonymized-source-%d>", int(i));
|
||||
} else {
|
||||
nsDependentCString filename(scriptSourceInfo.filename_);
|
||||
escapedFilename.Append(filename);
|
||||
escapedFilename.ReplaceSubstring("/", "\\");
|
||||
}
|
||||
|
||||
nsCString notablePath = rtPath +
|
||||
nsPrintfCString("runtime/script-sources/source(scripts=%d, %s)/",
|
||||
@ -2474,15 +2520,17 @@ nsresult
|
||||
ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats,
|
||||
const nsACString &rtPath,
|
||||
nsIMemoryReporterCallback *cb,
|
||||
nsISupports *closure, size_t *rtTotalOut)
|
||||
nsISupports *closure,
|
||||
bool anonymize,
|
||||
size_t *rtTotalOut)
|
||||
{
|
||||
nsCOMPtr<amIAddonManager> am;
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Default) {
|
||||
// Only try to access the service from the main process.
|
||||
am = do_GetService("@mozilla.org/addons/integration;1");
|
||||
}
|
||||
return ReportJSRuntimeExplicitTreeStats(rtStats, rtPath, am.get(), cb,
|
||||
closure, rtTotalOut);
|
||||
return ReportJSRuntimeExplicitTreeStats(rtStats, rtPath, am.get(),
|
||||
cb, closure, anonymize, rtTotalOut);
|
||||
}
|
||||
|
||||
|
||||
@ -2493,37 +2541,37 @@ class JSMainRuntimeCompartmentsReporter MOZ_FINAL : public nsIMemoryReporter
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
typedef js::Vector<nsCString, 0, js::SystemAllocPolicy> Paths;
|
||||
struct Data {
|
||||
int anonymizeID;
|
||||
js::Vector<nsCString, 0, js::SystemAllocPolicy> paths;
|
||||
};
|
||||
|
||||
static void CompartmentCallback(JSRuntime *rt, void* data, JSCompartment *c) {
|
||||
static void CompartmentCallback(JSRuntime *rt, void* vdata, JSCompartment *c) {
|
||||
// silently ignore OOM errors
|
||||
Paths *paths = static_cast<Paths *>(data);
|
||||
Data *data = static_cast<Data *>(vdata);
|
||||
nsCString path;
|
||||
GetCompartmentName(c, path, true);
|
||||
GetCompartmentName(c, path, &data->anonymizeID, /* replaceSlashes = */ true);
|
||||
path.Insert(js::IsSystemCompartment(c)
|
||||
? NS_LITERAL_CSTRING("js-main-runtime-compartments/system/")
|
||||
: NS_LITERAL_CSTRING("js-main-runtime-compartments/user/"),
|
||||
0);
|
||||
paths->append(path);
|
||||
data->paths.append(path);
|
||||
}
|
||||
|
||||
NS_IMETHOD CollectReports(nsIMemoryReporterCallback *cb,
|
||||
nsISupports *closure)
|
||||
nsISupports *closure, bool anonymize)
|
||||
{
|
||||
// First we collect the compartment paths. Then we report them. Doing
|
||||
// the two steps interleaved is a bad idea, because calling |cb|
|
||||
// from within CompartmentCallback() leads to all manner of assertions.
|
||||
|
||||
// Collect.
|
||||
|
||||
Paths paths;
|
||||
Data data;
|
||||
data.anonymizeID = anonymize ? 1 : 0;
|
||||
JS_IterateCompartments(nsXPConnect::GetRuntimeInstance()->Runtime(),
|
||||
&paths, CompartmentCallback);
|
||||
&data, CompartmentCallback);
|
||||
|
||||
// Report.
|
||||
for (size_t i = 0; i < paths.length(); i++)
|
||||
// These ones don't need a description, hence the "".
|
||||
REPORT(nsCString(paths[i]), KIND_OTHER, UNITS_COUNT, 1,
|
||||
for (size_t i = 0; i < data.paths.length(); i++)
|
||||
REPORT(nsCString(data.paths[i]), KIND_OTHER, UNITS_COUNT, 1,
|
||||
"A live compartment in the main JSRuntime.");
|
||||
|
||||
return NS_OK;
|
||||
@ -2593,14 +2641,16 @@ class XPCJSRuntimeStats : public JS::RuntimeStats
|
||||
WindowPaths *mWindowPaths;
|
||||
WindowPaths *mTopWindowPaths;
|
||||
bool mGetLocations;
|
||||
int mAnonymizeID;
|
||||
|
||||
public:
|
||||
XPCJSRuntimeStats(WindowPaths *windowPaths, WindowPaths *topWindowPaths,
|
||||
bool getLocations)
|
||||
bool getLocations, bool anonymize)
|
||||
: JS::RuntimeStats(JSMallocSizeOf),
|
||||
mWindowPaths(windowPaths),
|
||||
mTopWindowPaths(topWindowPaths),
|
||||
mGetLocations(getLocations)
|
||||
mGetLocations(getLocations),
|
||||
mAnonymizeID(anonymize ? 1 : 0)
|
||||
{}
|
||||
|
||||
~XPCJSRuntimeStats() {
|
||||
@ -2646,7 +2696,7 @@ class XPCJSRuntimeStats : public JS::RuntimeStats
|
||||
{
|
||||
xpc::CompartmentStatsExtras *extras = new xpc::CompartmentStatsExtras;
|
||||
nsCString cName;
|
||||
GetCompartmentName(c, cName, true);
|
||||
GetCompartmentName(c, cName, &mAnonymizeID, /* replaceSlashes = */ true);
|
||||
if (mGetLocations) {
|
||||
CompartmentPrivate *cp = GetCompartmentPrivate(c);
|
||||
if (cp)
|
||||
@ -2717,7 +2767,8 @@ nsresult
|
||||
JSReporter::CollectReports(WindowPaths *windowPaths,
|
||||
WindowPaths *topWindowPaths,
|
||||
nsIMemoryReporterCallback *cb,
|
||||
nsISupports *closure)
|
||||
nsISupports *closure,
|
||||
bool anonymize)
|
||||
{
|
||||
XPCJSRuntime *xpcrt = nsXPConnect::GetRuntimeInstance();
|
||||
|
||||
@ -2733,10 +2784,14 @@ JSReporter::CollectReports(WindowPaths *windowPaths,
|
||||
addonManager = do_GetService("@mozilla.org/addons/integration;1");
|
||||
}
|
||||
bool getLocations = !!addonManager;
|
||||
XPCJSRuntimeStats rtStats(windowPaths, topWindowPaths, getLocations);
|
||||
XPCJSRuntimeStats rtStats(windowPaths, topWindowPaths, getLocations,
|
||||
anonymize);
|
||||
OrphanReporter orphanReporter(XPCConvert::GetISupportsFromJSObject);
|
||||
if (!JS::CollectRuntimeStats(xpcrt->Runtime(), &rtStats, &orphanReporter))
|
||||
if (!JS::CollectRuntimeStats(xpcrt->Runtime(), &rtStats, &orphanReporter,
|
||||
anonymize))
|
||||
{
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
size_t xpconnect = xpcrt->SizeOfIncludingThis(JSMallocSizeOf);
|
||||
|
||||
@ -2754,7 +2809,7 @@ JSReporter::CollectReports(WindowPaths *windowPaths,
|
||||
rv = xpc::ReportJSRuntimeExplicitTreeStats(rtStats,
|
||||
NS_LITERAL_CSTRING("explicit/js-non-window/"),
|
||||
addonManager, cb, closure,
|
||||
&rtTotal);
|
||||
anonymize, &rtTotal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Report the sums of the compartment numbers.
|
||||
@ -2767,7 +2822,7 @@ JSReporter::CollectReports(WindowPaths *windowPaths,
|
||||
|
||||
xpc::ZoneStatsExtras zExtrasTotal;
|
||||
zExtrasTotal.pathPrefix.AssignLiteral("js-main-runtime/zones/");
|
||||
rv = ReportZoneStats(rtStats.zTotals, zExtrasTotal, cb, closure);
|
||||
rv = ReportZoneStats(rtStats.zTotals, zExtrasTotal, cb, closure, anonymize);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Report the sum of the runtime/ numbers.
|
||||
@ -2923,7 +2978,10 @@ CompartmentNameCallback(JSRuntime *rt, JSCompartment *comp,
|
||||
char *buf, size_t bufsize)
|
||||
{
|
||||
nsCString name;
|
||||
GetCompartmentName(comp, name, false);
|
||||
// This is called via the JSAPI and isn't involved in memory reporting, so
|
||||
// we don't need to anonymize compartment names.
|
||||
int anonymizeID = 0;
|
||||
GetCompartmentName(comp, name, &anonymizeID, /* replaceSlashes = */ false);
|
||||
if (name.Length() >= bufsize)
|
||||
name.Truncate(bufsize - 1);
|
||||
memcpy(buf, name.get(), name.Length() + 1);
|
||||
|
@ -400,7 +400,9 @@ nsresult
|
||||
ReportJSRuntimeExplicitTreeStats(const JS::RuntimeStats &rtStats,
|
||||
const nsACString &rtPath,
|
||||
nsIMemoryReporterCallback *cb,
|
||||
nsISupports *closure, size_t *rtTotal = nullptr);
|
||||
nsISupports *closure,
|
||||
bool anonymize,
|
||||
size_t *rtTotal = nullptr);
|
||||
|
||||
/**
|
||||
* Throws an exception on cx and returns false.
|
||||
|
@ -289,7 +289,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(StyleSheetServiceMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsStyleSheetService::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/layout/style-sheet-service", KIND_HEAP, UNITS_BYTES,
|
||||
|
@ -248,7 +248,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(LayoutStylesheetCacheMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLayoutStylesheetCache::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/layout/style-sheet-cache", KIND_HEAP, UNITS_BYTES,
|
||||
|
@ -66,6 +66,7 @@ var MemoryObserver = {
|
||||
|
||||
dumpMemoryStats: function(aLabel) {
|
||||
let memDumper = Cc["@mozilla.org/memory-info-dumper;1"].getService(Ci.nsIMemoryInfoDumper);
|
||||
memDumper.dumpMemoryInfoToTempDir(aLabel, /* minimize = */ false);
|
||||
memDumper.dumpMemoryInfoToTempDir(aLabel, /* anonymize = */ false,
|
||||
/* minimize = */ false);
|
||||
},
|
||||
};
|
||||
|
@ -293,7 +293,8 @@ MOZ_DEFINE_MALLOC_SIZE_OF(PreferenceServiceMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
PreferenceServiceReporter::CollectReports(nsIMemoryReporterCallback* aCb,
|
||||
nsISupports* aClosure)
|
||||
nsISupports* aClosure,
|
||||
bool aAnonymize)
|
||||
{
|
||||
#define REPORT(_path, _kind, _units, _amount, _desc) \
|
||||
do { \
|
||||
|
2
netwerk/cache/nsCacheService.cpp
vendored
2
netwerk/cache/nsCacheService.cpp
vendored
@ -3268,7 +3268,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(DiskCacheDeviceMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCacheService::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
size_t disk = 0;
|
||||
if (mDiskDevice) {
|
||||
|
@ -1745,7 +1745,9 @@ PLDHashOperator ReportStorageMemory(const nsACString& aKey,
|
||||
CacheStorageService::MallocSizeOf,
|
||||
aTable);
|
||||
|
||||
ReportStorageMemoryData& data = *static_cast<ReportStorageMemoryData*>(aClosure);
|
||||
ReportStorageMemoryData& data =
|
||||
*static_cast<ReportStorageMemoryData*>(aClosure);
|
||||
// These key names are not privacy-sensitive.
|
||||
data.mHandleReport->Callback(
|
||||
EmptyCString(),
|
||||
nsPrintfCString("explicit/network/cache2/%s-storage(%s)",
|
||||
@ -1763,7 +1765,8 @@ PLDHashOperator ReportStorageMemory(const nsACString& aKey,
|
||||
} // anon
|
||||
|
||||
NS_IMETHODIMP
|
||||
CacheStorageService::CollectReports(nsIMemoryReporterCallback* aHandleReport, nsISupports* aData)
|
||||
CacheStorageService::CollectReports(nsIMemoryReporterCallback* aHandleReport,
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -4360,7 +4360,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(CookieServiceMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCookieService::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/cookie-service", KIND_HEAP, UNITS_BYTES,
|
||||
|
@ -963,7 +963,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(DNSServiceMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDNSService::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/network/dns-service", KIND_HEAP, UNITS_BYTES,
|
||||
|
@ -111,7 +111,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(EffectiveTLDServiceMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsEffectiveTLDService::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/xpcom/effective-TLD-service", KIND_HEAP, UNITS_BYTES,
|
||||
|
@ -28,7 +28,8 @@ SpdyZlibReporter::Free(void*, void* p)
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
SpdyZlibReporter::CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData)
|
||||
SpdyZlibReporter::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/network/spdy-zlib-buffers", KIND_HEAP, UNITS_BYTES, sAmount,
|
||||
|
@ -44,7 +44,8 @@ private:
|
||||
MOZ_DEFINE_MALLOC_SIZE_OF_ON_FREE(MallocSizeOfOnFree)
|
||||
|
||||
NS_IMETHODIMP
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData);
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
|
||||
bool aAnonymize);
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
@ -56,7 +56,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(StartupCacheMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
StartupCache::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
#define REPORT(_path, _kind, _amount, _desc) \
|
||||
do { \
|
||||
|
@ -124,7 +124,7 @@ ReportConn(nsIHandleReportCallback *aHandleReport,
|
||||
// any delays in that case aren't so bad.
|
||||
NS_IMETHODIMP
|
||||
Service::CollectReports(nsIHandleReportCallback *aHandleReport,
|
||||
nsISupports *aData)
|
||||
nsISupports *aData, bool aAnonymize)
|
||||
{
|
||||
nsresult rv;
|
||||
size_t totalConnSize = 0;
|
||||
@ -143,6 +143,7 @@ Service::CollectReports(nsIHandleReportCallback *aHandleReport,
|
||||
}
|
||||
|
||||
nsCString pathHead("explicit/storage/sqlite/");
|
||||
// This filename isn't privacy-sensitive, and so is never anonymized.
|
||||
pathHead.Append(conn->getFilename());
|
||||
pathHead.Append('/');
|
||||
|
||||
|
@ -90,7 +90,7 @@ MemoryStats.dump = function (dumpFn,
|
||||
"nsIMemoryInfoDumper");
|
||||
md.dumpMemoryReportsToNamedFile(dumpfile, function () {
|
||||
dumpFn("TEST-INFO | " + testURL + " | MEMDUMP-END");
|
||||
}, null);
|
||||
}, null, /* anonymize = */ false);
|
||||
|
||||
}
|
||||
|
||||
|
@ -26,6 +26,7 @@ const CC = Components.Constructor;
|
||||
const KIND_NONHEAP = Ci.nsIMemoryReporter.KIND_NONHEAP;
|
||||
const KIND_HEAP = Ci.nsIMemoryReporter.KIND_HEAP;
|
||||
const KIND_OTHER = Ci.nsIMemoryReporter.KIND_OTHER;
|
||||
|
||||
const UNITS_BYTES = Ci.nsIMemoryReporter.UNITS_BYTES;
|
||||
const UNITS_COUNT = Ci.nsIMemoryReporter.UNITS_COUNT;
|
||||
const UNITS_COUNT_CUMULATIVE = Ci.nsIMemoryReporter.UNITS_COUNT_CUMULATIVE;
|
||||
@ -131,6 +132,9 @@ let gFooter;
|
||||
// The "verbose" checkbox.
|
||||
let gVerbose;
|
||||
|
||||
// The "anonymize" checkbox.
|
||||
let gAnonymize;
|
||||
|
||||
// Values for the second argument to updateMainAndFooter.
|
||||
let HIDE_FOOTER = 0;
|
||||
let SHOW_FOOTER = 1;
|
||||
@ -303,14 +307,13 @@ function onLoad()
|
||||
|
||||
let row1 = appendElement(ops, "div", "opsRow");
|
||||
|
||||
let labelDiv =
|
||||
let labelDiv1 =
|
||||
appendElementWithText(row1, "div", "opsRowLabel", "Show memory reports");
|
||||
let label = appendElementWithText(labelDiv, "label", "");
|
||||
gVerbose = appendElement(label, "input", "");
|
||||
let label1 = appendElementWithText(labelDiv1, "label", "");
|
||||
gVerbose = appendElement(label1, "input", "");
|
||||
gVerbose.type = "checkbox";
|
||||
gVerbose.id = "verbose"; // used for testing
|
||||
|
||||
appendTextNode(label, "verbose");
|
||||
appendTextNode(label1, "verbose");
|
||||
|
||||
const kEllipsis = "\u2026";
|
||||
|
||||
@ -324,9 +327,16 @@ function onLoad()
|
||||
|
||||
let row2 = appendElement(ops, "div", "opsRow");
|
||||
|
||||
appendElementWithText(row2, "div", "opsRowLabel", "Save memory reports");
|
||||
let labelDiv2 =
|
||||
appendElementWithText(row2, "div", "opsRowLabel", "Save memory reports");
|
||||
appendButton(row2, SvDesc, saveReportsToFile, "Measure and save" + kEllipsis);
|
||||
|
||||
// XXX njn: still not happy with the placement of this checkbox
|
||||
let label2 = appendElementWithText(labelDiv2, "label", "");
|
||||
gAnonymize = appendElement(label2, "input", "");
|
||||
gAnonymize.type = "checkbox";
|
||||
appendTextNode(label2, "anonymize");
|
||||
|
||||
let row3 = appendElement(ops, "div", "opsRow");
|
||||
|
||||
appendElementWithText(row3, "div", "opsRowLabel", "Free memory");
|
||||
@ -493,8 +503,8 @@ function updateAboutMemoryFromReporters()
|
||||
aDisplayReports();
|
||||
}
|
||||
|
||||
gMgr.getReports(handleReport, null,
|
||||
displayReportsAndFooter, null);
|
||||
gMgr.getReports(handleReport, null, displayReportsAndFooter, null,
|
||||
gAnonymize.checked);
|
||||
}
|
||||
|
||||
// Process the reports from the live memory reporters.
|
||||
@ -1962,7 +1972,8 @@ function saveReportsToFile()
|
||||
updateMainAndFooter("Saved reports to " + file.path, HIDE_FOOTER);
|
||||
}
|
||||
|
||||
dumper.dumpMemoryReportsToNamedFile(file.path, finishDumping, null);
|
||||
dumper.dumpMemoryReportsToNamedFile(file.path, finishDumping, null,
|
||||
gAnonymize.checked);
|
||||
}
|
||||
|
||||
let fpCallback = function(aResult) {
|
||||
|
@ -43,7 +43,7 @@
|
||||
const PERCENTAGE = Ci.nsIMemoryReporter.UNITS_PERCENTAGE;
|
||||
|
||||
let fakeReporters = [
|
||||
{ collectReports: function(aCbObj, aClosure) {
|
||||
{ collectReports: function(aCbObj, aClosure, aAnonymize) {
|
||||
function f(aP, aK, aU, aA) {
|
||||
aCbObj.callback("", aP, aK, aU, aA, "Desc.", aClosure);
|
||||
}
|
||||
@ -80,7 +80,7 @@
|
||||
f("compartments/system/foo", OTHER, COUNT, 1);
|
||||
}
|
||||
},
|
||||
{ collectReports: function(aCbObj, aClosure) {
|
||||
{ collectReports: function(aCbObj, aClosure, aAnonymize) {
|
||||
function f(aP, aK, aU, aA) {
|
||||
aCbObj.callback("", aP, aK, aU, aA, "Desc.", aClosure);
|
||||
}
|
||||
@ -95,7 +95,7 @@
|
||||
f("explicit/f/g/h/j", HEAP, BYTES, 10 * MB);
|
||||
}
|
||||
},
|
||||
{ collectReports: function(aCbObj, aClosure) {
|
||||
{ collectReports: function(aCbObj, aClosure, aAnonymize) {
|
||||
function f(aP, aK, aU, aA) {
|
||||
aCbObj.callback("", aP, aK, aU, aA, "Desc.", aClosure);
|
||||
}
|
||||
@ -106,7 +106,7 @@
|
||||
f("compartments/user/https:\\\\very-long-url.com\\very-long\\oh-so-long\\really-quite-long.html?a=2&b=3&c=4&d=5&e=abcdefghijklmnopqrstuvwxyz&f=123456789123456789123456789", OTHER, COUNT, 1);
|
||||
}
|
||||
},
|
||||
{ collectReports: function(aCbObj, aClosure) {
|
||||
{ collectReports: function(aCbObj, aClosure, aAnonymize) {
|
||||
function f(aP) {
|
||||
aCbObj.callback("", aP, OTHER, COUNT, 1, "Desc.", aClosure);
|
||||
}
|
||||
@ -139,7 +139,7 @@
|
||||
// the largest). Processes without a |resident| memory reporter are saved
|
||||
// for the end.
|
||||
let fakeReporters2 = [
|
||||
{ collectReports: function(aCbObj, aClosure) {
|
||||
{ collectReports: function(aCbObj, aClosure, aAnonymize) {
|
||||
function f(aP1, aP2, aK, aU, aA) {
|
||||
aCbObj.callback(aP1, aP2, aK, aU, aA, "Desc.", aClosure);
|
||||
}
|
||||
|
@ -38,7 +38,7 @@
|
||||
let jk2Path = "explicit/j/k2";
|
||||
|
||||
let fakeReporters = [
|
||||
{ collectReports: function(aCbObj, aClosure) {
|
||||
{ collectReports: function(aCbObj, aClosure, aAnonymize) {
|
||||
function f(aP, aK, aA) {
|
||||
aCbObj.callback("", aP, aK, BYTES, aA, "Desc.", aClosure);
|
||||
}
|
||||
|
@ -33,7 +33,7 @@
|
||||
const BYTES = Ci.nsIMemoryReporter.UNITS_BYTES;
|
||||
|
||||
let fakeReporters = [
|
||||
{ collectReports: function(aCbObj, aClosure) {
|
||||
{ collectReports: function(aCbObj, aClosure, aAnonymize) {
|
||||
function f(aP, aK, aA, aD) {
|
||||
aCbObj.callback("", aP, aK, BYTES, aA, aD, aClosure);
|
||||
}
|
||||
@ -140,7 +140,8 @@
|
||||
if (aDumpFirst) {
|
||||
let dumper = Cc["@mozilla.org/memory-info-dumper;1"].
|
||||
getService(Ci.nsIMemoryInfoDumper);
|
||||
dumper.dumpMemoryReportsToNamedFile(filePath, loadAndCheck, null);
|
||||
dumper.dumpMemoryReportsToNamedFile(filePath, loadAndCheck, null,
|
||||
/* anonymize = */ false);
|
||||
} else {
|
||||
loadAndCheck();
|
||||
}
|
||||
|
@ -85,7 +85,8 @@
|
||||
|
||||
let dumper = Cc["@mozilla.org/memory-info-dumper;1"].
|
||||
getService(Ci.nsIMemoryInfoDumper);
|
||||
dumper.dumpMemoryReportsToNamedFile(filePath, loadAndCheck, null);
|
||||
dumper.dumpMemoryReportsToNamedFile(filePath, loadAndCheck, null,
|
||||
/* anonymize = */ false);
|
||||
|
||||
function loadAndCheck() {
|
||||
// Load the file.
|
||||
|
@ -16,6 +16,10 @@
|
||||
<marquee>Marquee</marquee>
|
||||
</body>
|
||||
|
||||
<!-- some URIs that should be anonymized in anonymous mode -->
|
||||
<iframe id="amFrame" height="200" src="http://example.org:80"></iframe>
|
||||
<iframe id="amFrame" height="200" src="https://example.com:443"></iframe>
|
||||
|
||||
<!-- test code goes here -->
|
||||
<script type="application/javascript">
|
||||
<![CDATA[
|
||||
@ -67,7 +71,8 @@
|
||||
let mySandbox = Components.utils.Sandbox(document.nodePrincipal,
|
||||
{ sandboxName: "this-is-a-sandbox-name" });
|
||||
|
||||
function handleReport(aProcess, aPath, aKind, aUnits, aAmount, aDescription)
|
||||
function handleReportNormal(aProcess, aPath, aKind, aUnits, aAmount,
|
||||
aDescription)
|
||||
{
|
||||
// Record the values of some notable reporters.
|
||||
if (aPath === "vsize") {
|
||||
@ -105,6 +110,25 @@
|
||||
} else if (aPath.contains("@)(*&")) {
|
||||
present.smallString2 = true;
|
||||
}
|
||||
|
||||
// Shouldn't get any anonymized paths.
|
||||
if (aPath.contains('<anonymized')) {
|
||||
present.anonymizedWhenUnnecessary = true;
|
||||
}
|
||||
}
|
||||
|
||||
function handleReportAnonymized(aProcess, aPath, aKind, aUnits, aAmount,
|
||||
aDescription)
|
||||
{
|
||||
// Shouldn't get http: or https: in any paths.
|
||||
if (aPath.contains('http:')) {
|
||||
present.httpWhenAnonymized = true;
|
||||
}
|
||||
|
||||
// file: URLs should have their path anonymized.
|
||||
if (aPath.search('file:..[^<]') !== -1) {
|
||||
present.unanonymizedFilePathWhenAnonymized = true;
|
||||
}
|
||||
}
|
||||
|
||||
let mgr = Cc["@mozilla.org/memory-reporter-manager;1"].
|
||||
@ -171,7 +195,11 @@
|
||||
domSize, styleSize, otherSize, totalSize,
|
||||
jsMilliseconds, nonJSMilliseconds);
|
||||
|
||||
mgr.getReportsForThisProcess(handleReport, null);
|
||||
mgr.getReportsForThisProcess(handleReportNormal, null,
|
||||
/* anonymize = */ false);
|
||||
|
||||
mgr.getReportsForThisProcess(handleReportAnonymized, null,
|
||||
/* anonymize = */ true);
|
||||
|
||||
function checkSpecialReport(aName, aAmounts, aCanBeUnreasonable)
|
||||
{
|
||||
@ -202,6 +230,10 @@
|
||||
ok(present.smallString1, "small string 1 is present");
|
||||
ok(present.smallString2, "small string 2 is present");
|
||||
|
||||
ok(!present.anonymizedWhenUnnecessary, "anonymized paths are not present when unnecessary");
|
||||
ok(!present.httpWhenAnonymized, "http URLs are anonymized when necessary");
|
||||
ok(!present.unanonymizedFilePathWhenAnonymized,
|
||||
"file URLs are anonymized when necessary");
|
||||
|
||||
// Reporter registration tests
|
||||
|
||||
@ -245,7 +277,7 @@
|
||||
}
|
||||
},
|
||||
// nsIMemoryReporter
|
||||
collectReports: function(callback, data) {
|
||||
collectReports: function(callback, data, anonymize) {
|
||||
for (let path of Object.keys(this.tests)) {
|
||||
try {
|
||||
let test = this.tests[path];
|
||||
@ -294,7 +326,8 @@
|
||||
mgr.registerStrongReporter(reporterAndCallback);
|
||||
|
||||
// Check the generated reports.
|
||||
mgr.getReportsForThisProcess(reporterAndCallback, null);
|
||||
mgr.getReportsForThisProcess(reporterAndCallback, null,
|
||||
/* anonymize = */ false);
|
||||
reporterAndCallback.finish();
|
||||
|
||||
// Unregistration works.
|
||||
@ -302,7 +335,8 @@
|
||||
|
||||
// The reporter was unregistered, hence there shouldn't be any reports from
|
||||
// the test reporter.
|
||||
mgr.getReportsForThisProcess(reporterAndCallback, null);
|
||||
mgr.getReportsForThisProcess(reporterAndCallback, null,
|
||||
/* anonymize = */ false);
|
||||
reporterAndCallback.finish(0);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@
|
||||
// won't be used.)
|
||||
mgr.getReports(
|
||||
() => ok(false, "handleReport called for nested getReports() call"),
|
||||
null, null, null
|
||||
null, null, null, /* anonymize = */ false
|
||||
);
|
||||
|
||||
// Close the remote processes.
|
||||
@ -97,7 +97,8 @@
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
mgr.getReports(handleReport, null, processReports, null);
|
||||
mgr.getReports(handleReport, null, processReports, null,
|
||||
/* anonymize = */ false);
|
||||
}
|
||||
|
||||
]]></script>
|
||||
|
@ -40,7 +40,7 @@
|
||||
// them. It shouldn't crash.
|
||||
let mgr = Cc["@mozilla.org/memory-reporter-manager;1"].
|
||||
getService(Ci.nsIMemoryReporterManager);
|
||||
mgr.getReportsForThisProcess(function(){}, null);
|
||||
mgr.getReportsForThisProcess(function(){}, null, /* anonymize = */ false);
|
||||
|
||||
// If we haven't crashed, we've passed, but the test harness requires that
|
||||
// we explicitly check something.
|
||||
|
@ -2234,7 +2234,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(HistoryMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
History::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/history-links-hashtable", KIND_HEAP, UNITS_BYTES,
|
||||
|
@ -664,7 +664,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(TelemetryMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
TelemetryImpl::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/telemetry", KIND_HEAP, UNITS_BYTES,
|
||||
|
@ -249,7 +249,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(UrlClassifierMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsUrlClassifierPrefixSet::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return aHandleReport->Callback(
|
||||
EmptyCString(), mMemoryReportPath, KIND_HEAP, UNITS_BYTES,
|
||||
|
@ -344,7 +344,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
nsresult rv;
|
||||
|
||||
|
@ -136,8 +136,13 @@ public:
|
||||
REPORT_WITH_CLEANUP(_path, UNITS_BYTES, _amount, _desc, (void)0)
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
// There is lots of privacy-sensitive data in /proc. Just skip this
|
||||
// reporter entirely when anonymization is required.
|
||||
if (aAnonymize)
|
||||
return NS_OK;
|
||||
|
||||
if (!Preferences::GetBool("memory.system_memory_reporter")) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3269,7 +3269,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(CycleCollectorMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCycleCollector::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
size_t objectSize, graphNodesSize, graphEdgesSize, weakMapsSize,
|
||||
purpleBufferSize;
|
||||
|
@ -44,7 +44,7 @@ interface nsIDumpGCAndCCLogsCallback : nsISupports
|
||||
void onFinish();
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(a156fda4-aea0-4da2-9daa-9858430fade9)]
|
||||
[scriptable, builtinclass, uuid(48541b74-47ee-4a62-9557-7f4b809bda5c)]
|
||||
interface nsIMemoryInfoDumper : nsISupports
|
||||
{
|
||||
/**
|
||||
@ -53,6 +53,12 @@ interface nsIMemoryInfoDumper : nsISupports
|
||||
*
|
||||
* @param aFilename The output file.
|
||||
*
|
||||
* @param aFinishDumping The callback called on completion.
|
||||
*
|
||||
* @param aFinishDumpingData The environment for the callback.
|
||||
*
|
||||
* @param aAnonymize Should the reports be anonymized?
|
||||
*
|
||||
* Sample output:
|
||||
*
|
||||
* {
|
||||
@ -123,7 +129,8 @@ interface nsIMemoryInfoDumper : nsISupports
|
||||
*/
|
||||
void dumpMemoryReportsToNamedFile(in AString aFilename,
|
||||
in nsIFinishDumpingCallback aFinishDumping,
|
||||
in nsISupports aFinishDumpingData);
|
||||
in nsISupports aFinishDumpingData,
|
||||
in boolean aAnonymize);
|
||||
|
||||
/**
|
||||
* Similar to dumpMemoryReportsToNamedFile, this method dumps gzipped memory
|
||||
@ -144,13 +151,16 @@ interface nsIMemoryInfoDumper : nsISupports
|
||||
* processes. For example, the implementation may set |aIdentifier| to the
|
||||
* number of seconds since the epoch.
|
||||
*
|
||||
* @param aAnonymize Should the reports be anonymized?
|
||||
*
|
||||
* @param aMinimizeMemoryUsage indicates whether we should run a series of
|
||||
* gc/cc's in an attempt to reduce our memory usage before collecting our
|
||||
* memory report.
|
||||
*/
|
||||
void dumpMemoryInfoToTempDir(
|
||||
in AString aIdentifier,
|
||||
in bool aMinimizeMemoryUsage);
|
||||
in boolean aAnonymize,
|
||||
in boolean aMinimizeMemoryUsage);
|
||||
|
||||
/**
|
||||
* Dump GC and CC logs to files in the OS's temp directory (or in
|
||||
|
@ -147,24 +147,47 @@ interface nsIMemoryReporterCallback : nsISupports
|
||||
* sentences (i.e. start with a capital letter and end with a period, or
|
||||
* similar).
|
||||
*/
|
||||
[scriptable, uuid(0884cd0f-5829-4381-979b-0f53904030ed)]
|
||||
[scriptable, uuid(92a36db1-46bd-4fe6-988e-47db47236d8b)]
|
||||
interface nsIMemoryReporter : nsISupports
|
||||
{
|
||||
/*
|
||||
* Run the reporter.
|
||||
*
|
||||
* If |anonymize| is true, the memory reporter should anonymize any
|
||||
* privacy-sensitive details in memory report paths, by replacing them with a
|
||||
* string such as "<anonymized>". Anonymized memory reports may be sent
|
||||
* automatically via crash reports or telemetry.
|
||||
*
|
||||
* The following things are considered privacy-sensitive.
|
||||
*
|
||||
* - Content domains and URLs, and information derived from them.
|
||||
* - Content data, such as strings.
|
||||
* - Details about content code, such as filenames, function names or stack
|
||||
* traces.
|
||||
* - Details about or data from the user's system, such as filenames.
|
||||
* - Running apps.
|
||||
*
|
||||
* In short, anything that could identify parts of the user's browsing
|
||||
* history is considered privacy-sensitive.
|
||||
*
|
||||
* The following thing are not considered privacy-sensitive.
|
||||
*
|
||||
* - Chrome domains and URLs.
|
||||
* - Information about installed extensions.
|
||||
*/
|
||||
void collectReports(in nsIMemoryReporterCallback callback,
|
||||
in nsISupports data);
|
||||
in nsISupports data,
|
||||
in boolean anonymize);
|
||||
|
||||
/*
|
||||
* Kinds. See the |kind| comment in nsIMemoryReporterCallback.
|
||||
* Kinds. See the |kind| comment in nsIMemoryReporterCallback.
|
||||
*/
|
||||
const int32_t KIND_NONHEAP = 0;
|
||||
const int32_t KIND_HEAP = 1;
|
||||
const int32_t KIND_OTHER = 2;
|
||||
|
||||
/*
|
||||
* Units. See the |units| comment in nsIMemoryReporterCallback.
|
||||
* Units. See the |units| comment in nsIMemoryReporterCallback.
|
||||
*/
|
||||
const int32_t UNITS_BYTES = 0;
|
||||
const int32_t UNITS_COUNT = 1;
|
||||
@ -236,11 +259,15 @@ interface nsIMemoryReporterManager : nsISupports
|
||||
* finished invoking |finishReporting|. The silent abort is because the
|
||||
* in-flight request will finish soon, and the caller would very likely just
|
||||
* catch and ignore any error anyway.
|
||||
*
|
||||
* If |anonymize| is true, it indicates that the memory reporters should
|
||||
* anonymize any privacy-sensitive data (see above).
|
||||
*/
|
||||
void getReports(in nsIMemoryReporterCallback handleReport,
|
||||
in nsISupports handleReportData,
|
||||
in nsIFinishReportingCallback finishReporting,
|
||||
in nsISupports finishReportingData);
|
||||
in nsISupports finishReportingData,
|
||||
in boolean anonymize);
|
||||
|
||||
/*
|
||||
* As above, but: If |minimizeMemoryUsage| is true, then each process will
|
||||
@ -254,6 +281,7 @@ interface nsIMemoryReporterManager : nsISupports
|
||||
in nsISupports handleReportData,
|
||||
in nsIFinishReportingCallback finishReporting,
|
||||
in nsISupports finishReportingData,
|
||||
in boolean anonymize,
|
||||
in boolean minimizeMemoryUsage,
|
||||
in AString DMDDumpIdent);
|
||||
|
||||
@ -262,7 +290,8 @@ interface nsIMemoryReporterManager : nsISupports
|
||||
* for each report.
|
||||
*/
|
||||
void getReportsForThisProcess(in nsIMemoryReporterCallback handleReport,
|
||||
in nsISupports handleReportData);
|
||||
in nsISupports handleReportData,
|
||||
in boolean anonymize);
|
||||
|
||||
/*
|
||||
* As above, but if DMD is enabled and |DMDDumpIdent| is non-empty
|
||||
@ -272,6 +301,7 @@ interface nsIMemoryReporterManager : nsISupports
|
||||
[noscript] void
|
||||
getReportsForThisProcessExtended(in nsIMemoryReporterCallback handleReport,
|
||||
in nsISupports handleReportData,
|
||||
in boolean anonymize,
|
||||
in AString DMDDumpIdent);
|
||||
|
||||
/*
|
||||
@ -552,9 +582,10 @@ namespace mozilla {
|
||||
// {
|
||||
// ...
|
||||
// NS_IMETHODIMP
|
||||
// CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData)
|
||||
// CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
// nsISupports* aData, bool aAnonymize)
|
||||
// {
|
||||
// return MOZ_COLLECT_REPORTER(
|
||||
// return MOZ_COLLECT_REPORT(
|
||||
// "explicit/path/to/somewhere", KIND_HEAP, UNITS_BYTES,
|
||||
// MemoryAllocated(),
|
||||
// "A description of what we are reporting."
|
||||
|
@ -56,8 +56,9 @@ class DumpMemoryInfoToTempDirRunnable : public nsRunnable
|
||||
{
|
||||
public:
|
||||
DumpMemoryInfoToTempDirRunnable(const nsAString& aIdentifier,
|
||||
bool aMinimizeMemoryUsage)
|
||||
bool aAnonymize, bool aMinimizeMemoryUsage)
|
||||
: mIdentifier(aIdentifier)
|
||||
, mAnonymize(aAnonymize)
|
||||
, mMinimizeMemoryUsage(aMinimizeMemoryUsage)
|
||||
{
|
||||
}
|
||||
@ -66,12 +67,14 @@ public:
|
||||
{
|
||||
nsCOMPtr<nsIMemoryInfoDumper> dumper =
|
||||
do_GetService("@mozilla.org/memory-info-dumper;1");
|
||||
dumper->DumpMemoryInfoToTempDir(mIdentifier, mMinimizeMemoryUsage);
|
||||
dumper->DumpMemoryInfoToTempDir(mIdentifier, mAnonymize,
|
||||
mMinimizeMemoryUsage);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
private:
|
||||
const nsString mIdentifier;
|
||||
const bool mAnonymize;
|
||||
const bool mMinimizeMemoryUsage;
|
||||
};
|
||||
|
||||
@ -157,11 +160,12 @@ static uint8_t sGCAndCCDumpSignum; // SIGRTMIN + 2
|
||||
void doMemoryReport(const uint8_t aRecvSig)
|
||||
{
|
||||
// Dump our memory reports (but run this on the main thread!).
|
||||
bool doMMUFirst = aRecvSig == sDumpAboutMemoryAfterMMUSignum;
|
||||
bool minimize = aRecvSig == sDumpAboutMemoryAfterMMUSignum;
|
||||
LOG("SignalWatcher(sig %d) dispatching memory report runnable.", aRecvSig);
|
||||
nsRefPtr<DumpMemoryInfoToTempDirRunnable> runnable =
|
||||
new DumpMemoryInfoToTempDirRunnable(/* identifier = */ EmptyString(),
|
||||
doMMUFirst);
|
||||
/* anonymize = */ false,
|
||||
minimize);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
}
|
||||
|
||||
@ -186,11 +190,12 @@ namespace {
|
||||
void
|
||||
doMemoryReport(const nsCString& aInputStr)
|
||||
{
|
||||
bool doMMUMemoryReport = aInputStr.EqualsLiteral("minimize memory report");
|
||||
bool minimize = aInputStr.EqualsLiteral("minimize memory report");
|
||||
LOG("FifoWatcher(command:%s) dispatching memory report runnable.", aInputStr.get());
|
||||
nsRefPtr<DumpMemoryInfoToTempDirRunnable> runnable =
|
||||
new DumpMemoryInfoToTempDirRunnable(/* identifier = */ EmptyString(),
|
||||
doMMUMemoryReport);
|
||||
/* anonymize = */ false,
|
||||
minimize);
|
||||
NS_DispatchToMainThread(runnable);
|
||||
}
|
||||
|
||||
@ -593,6 +598,7 @@ NS_IMPL_ISUPPORTS(TempDirMemoryFinishCallback, nsIFinishReportingCallback)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryInfoDumper::DumpMemoryInfoToTempDir(const nsAString& aIdentifier,
|
||||
bool aAnonymize,
|
||||
bool aMinimizeMemoryUsage)
|
||||
{
|
||||
nsString identifier(aIdentifier);
|
||||
@ -658,6 +664,7 @@ nsMemoryInfoDumper::DumpMemoryInfoToTempDir(const nsAString& aIdentifier,
|
||||
new TempDirMemoryFinishCallback(mrWriter, mrTmpFile, mrFilename, identifier);
|
||||
rv = mgr->GetReportsExtended(dumpReport, nullptr,
|
||||
finishReport, nullptr,
|
||||
aAnonymize,
|
||||
aMinimizeMemoryUsage,
|
||||
identifier);
|
||||
return rv;
|
||||
@ -826,7 +833,8 @@ NS_IMETHODIMP
|
||||
nsMemoryInfoDumper::DumpMemoryReportsToNamedFile(
|
||||
const nsAString& aFilename,
|
||||
nsIFinishDumpingCallback* aFinishDumping,
|
||||
nsISupports* aFinishDumpingData)
|
||||
nsISupports* aFinishDumpingData,
|
||||
bool aAnonymize)
|
||||
{
|
||||
MOZ_ASSERT(!aFilename.IsEmpty());
|
||||
|
||||
@ -875,7 +883,8 @@ nsMemoryInfoDumper::DumpMemoryReportsToNamedFile(
|
||||
new FinishReportingCallback(aFinishDumping, aFinishDumpingData);
|
||||
nsCOMPtr<nsIMemoryReporterManager> mgr =
|
||||
do_GetService("@mozilla.org/memory-reporter-manager;1");
|
||||
return mgr->GetReports(dumpReport, nullptr, finishReporting, mrWriter);
|
||||
return mgr->GetReports(dumpReport, nullptr, finishReporting, mrWriter,
|
||||
aAnonymize);
|
||||
}
|
||||
|
||||
#undef DUMP
|
||||
|
@ -122,7 +122,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
int64_t amount = 0;
|
||||
nsresult rv = ResidentUniqueDistinguishedAmount(&amount);
|
||||
@ -519,7 +519,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
int64_t amount;
|
||||
nsresult rv = VsizeMaxContiguousDistinguishedAmount(&amount);
|
||||
@ -540,7 +540,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
int64_t amount;
|
||||
nsresult rv = PrivateDistinguishedAmount(&amount);
|
||||
@ -562,7 +562,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
int64_t amount;
|
||||
nsresult rv = VsizeDistinguishedAmount(&amount);
|
||||
@ -587,7 +587,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
int64_t amount;
|
||||
nsresult rv = ResidentDistinguishedAmount(&amount);
|
||||
@ -619,7 +619,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
struct rusage usage;
|
||||
int err = getrusage(RUSAGE_SELF, &usage);
|
||||
@ -661,7 +661,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
int64_t amount = 0;
|
||||
nsresult rv = PageFaultsHardDistinguishedAmount(&amount);
|
||||
@ -708,7 +708,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
jemalloc_stats_t stats;
|
||||
jemalloc_stats(&stats);
|
||||
@ -812,7 +812,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_METHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/atom-tables", KIND_HEAP, UNITS_BYTES,
|
||||
@ -833,7 +833,7 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
|
||||
NS_IMETHOD CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
dmd::Sizes sizes;
|
||||
dmd::SizeOf(&sizes);
|
||||
@ -991,10 +991,12 @@ nsMemoryReporterManager::GetReports(
|
||||
nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aHandleReportData,
|
||||
nsIFinishReportingCallback* aFinishReporting,
|
||||
nsISupports* aFinishReportingData)
|
||||
nsISupports* aFinishReportingData,
|
||||
bool aAnonymize)
|
||||
{
|
||||
return GetReportsExtended(aHandleReport, aHandleReportData,
|
||||
aFinishReporting, aFinishReportingData,
|
||||
aAnonymize,
|
||||
/* minimize = */ false,
|
||||
/* DMDident = */ nsString());
|
||||
}
|
||||
@ -1005,6 +1007,7 @@ nsMemoryReporterManager::GetReportsExtended(
|
||||
nsISupports* aHandleReportData,
|
||||
nsIFinishReportingCallback* aFinishReporting,
|
||||
nsISupports* aFinishReportingData,
|
||||
bool aAnonymize,
|
||||
bool aMinimize,
|
||||
const nsAString& aDMDDumpIdent)
|
||||
{
|
||||
@ -1037,8 +1040,8 @@ nsMemoryReporterManager::GetReportsExtended(
|
||||
do_GetService("@mozilla.org/observer-service;1");
|
||||
NS_ENSURE_STATE(obs);
|
||||
|
||||
nsPrintfCString genStr("generation=%x minimize=%d DMDident=",
|
||||
generation, aMinimize ? 1 : 0);
|
||||
nsPrintfCString genStr("generation=%x anonymize=%d minimize=%d DMDident=",
|
||||
generation, aAnonymize ? 1 : 0, aMinimize ? 1 : 0);
|
||||
nsAutoString msg = NS_ConvertUTF8toUTF16(genStr);
|
||||
msg += aDMDDumpIdent;
|
||||
|
||||
@ -1053,6 +1056,7 @@ nsMemoryReporterManager::GetReportsExtended(
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mGetReportsState = new GetReportsState(generation,
|
||||
aAnonymize,
|
||||
timer,
|
||||
mNumChildProcesses,
|
||||
aHandleReport,
|
||||
@ -1062,6 +1066,7 @@ nsMemoryReporterManager::GetReportsExtended(
|
||||
aDMDDumpIdent);
|
||||
} else {
|
||||
mGetReportsState = new GetReportsState(generation,
|
||||
aAnonymize,
|
||||
nullptr,
|
||||
/* mNumChildProcesses = */ 0,
|
||||
aHandleReport,
|
||||
@ -1086,7 +1091,7 @@ nsMemoryReporterManager::StartGettingReports()
|
||||
|
||||
// Get reports for this process.
|
||||
GetReportsForThisProcessExtended(s->mHandleReport, s->mHandleReportData,
|
||||
s->mDMDDumpIdent);
|
||||
s->mAnonymize, s->mDMDDumpIdent);
|
||||
s->mParentDone = true;
|
||||
|
||||
// If there are no remaining child processes, we can finish up immediately.
|
||||
@ -1116,18 +1121,16 @@ WeakEnumerator(nsPtrHashKey<nsIMemoryReporter>* aElem, void* aData)
|
||||
NS_IMETHODIMP
|
||||
nsMemoryReporterManager::GetReportsForThisProcess(
|
||||
nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aHandleReportData)
|
||||
nsISupports* aHandleReportData, bool aAnonymize)
|
||||
{
|
||||
return GetReportsForThisProcessExtended(aHandleReport,
|
||||
aHandleReportData,
|
||||
nsString());
|
||||
return GetReportsForThisProcessExtended(aHandleReport, aHandleReportData,
|
||||
aAnonymize, nsString());
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsMemoryReporterManager::GetReportsForThisProcessExtended(
|
||||
nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aHandleReportData,
|
||||
const nsAString& aDMDDumpIdent)
|
||||
nsIHandleReportCallback* aHandleReport, nsISupports* aHandleReportData,
|
||||
bool aAnonymize, const nsAString& aDMDDumpIdent)
|
||||
{
|
||||
// Memory reporters are not necessarily threadsafe, so this function must
|
||||
// be called from the main thread.
|
||||
@ -1150,7 +1153,8 @@ nsMemoryReporterManager::GetReportsForThisProcessExtended(
|
||||
mWeakReporters->EnumerateEntries(WeakEnumerator, &allReporters);
|
||||
}
|
||||
for (uint32_t i = 0; i < allReporters.Length(); i++) {
|
||||
allReporters[i]->CollectReports(aHandleReport, aHandleReportData);
|
||||
allReporters[i]->CollectReports(aHandleReport, aHandleReportData,
|
||||
aAnonymize);
|
||||
}
|
||||
|
||||
#ifdef MOZ_DMD
|
||||
@ -1497,7 +1501,11 @@ nsMemoryReporterManager::GetExplicit(int64_t* aAmount)
|
||||
nsRefPtr<ExplicitCallback> handleReport = new ExplicitCallback();
|
||||
nsRefPtr<Int64Wrapper> wrappedExplicitSize = new Int64Wrapper();
|
||||
|
||||
GetReportsForThisProcess(handleReport, wrappedExplicitSize);
|
||||
// Anonymization doesn't matter here, because we're only summing all the
|
||||
// reported values. Enable it anyway because it's slightly faster, since it
|
||||
// doesn't have to get URLs, find notable strings, etc.
|
||||
GetReportsForThisProcess(handleReport, wrappedExplicitSize,
|
||||
/* anonymize = */ true);
|
||||
|
||||
*aAmount = wrappedExplicitSize->mValue;
|
||||
|
||||
@ -1979,7 +1987,7 @@ RunReportersForThisProcess()
|
||||
|
||||
nsRefPtr<DoNothingCallback> doNothing = new DoNothingCallback();
|
||||
|
||||
mgr->GetReportsForThisProcess(doNothing, nullptr);
|
||||
mgr->GetReportsForThisProcess(doNothing, nullptr, /* anonymize = */ false);
|
||||
}
|
||||
|
||||
} // namespace dmd
|
||||
|
@ -193,6 +193,7 @@ private:
|
||||
struct GetReportsState
|
||||
{
|
||||
uint32_t mGeneration;
|
||||
bool mAnonymize;
|
||||
nsCOMPtr<nsITimer> mTimer;
|
||||
uint32_t mNumChildProcesses;
|
||||
uint32_t mNumChildProcessesCompleted;
|
||||
@ -203,7 +204,7 @@ private:
|
||||
nsCOMPtr<nsISupports> mFinishReportingData;
|
||||
nsString mDMDDumpIdent;
|
||||
|
||||
GetReportsState(uint32_t aGeneration, nsITimer* aTimer,
|
||||
GetReportsState(uint32_t aGeneration, bool aAnonymize, nsITimer* aTimer,
|
||||
uint32_t aNumChildProcesses,
|
||||
nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aHandleReportData,
|
||||
@ -211,6 +212,7 @@ private:
|
||||
nsISupports* aFinishReportingData,
|
||||
const nsAString& aDMDDumpIdent)
|
||||
: mGeneration(aGeneration)
|
||||
, mAnonymize(aAnonymize)
|
||||
, mTimer(aTimer)
|
||||
, mNumChildProcesses(aNumChildProcesses)
|
||||
, mNumChildProcessesCompleted(0)
|
||||
|
@ -373,7 +373,8 @@ public:
|
||||
|
||||
private:
|
||||
NS_IMETHODIMP
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData)
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
|
||||
bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/icu", KIND_HEAP, UNITS_BYTES, MemoryAllocated(),
|
||||
@ -393,7 +394,8 @@ public:
|
||||
|
||||
private:
|
||||
NS_IMETHODIMP
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData)
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
|
||||
bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/media/libogg", KIND_HEAP, UNITS_BYTES, MemoryAllocated(),
|
||||
@ -414,7 +416,8 @@ public:
|
||||
|
||||
private:
|
||||
NS_IMETHODIMP
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData)
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
|
||||
bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/media/libvpx", KIND_HEAP, UNITS_BYTES, MemoryAllocated(),
|
||||
@ -436,7 +439,8 @@ public:
|
||||
|
||||
private:
|
||||
NS_IMETHODIMP
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData)
|
||||
CollectReports(nsIHandleReportCallback* aHandleReport, nsISupports* aData,
|
||||
bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/media/libnestegg", KIND_HEAP, UNITS_BYTES, MemoryAllocated(),
|
||||
|
@ -479,7 +479,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(CategoryManagerMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCategoryManager::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/xpcom/category-manager", KIND_HEAP, UNITS_BYTES,
|
||||
|
@ -1689,7 +1689,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(ComponentManagerMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsComponentManagerImpl::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
return MOZ_COLLECT_REPORT(
|
||||
"explicit/xpcom/component-manager", KIND_HEAP, UNITS_BYTES,
|
||||
|
@ -108,11 +108,12 @@ nsObserverService::CountReferents(nsObserverList* aObserverList,
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsObserverService::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
ObserverServiceReferentCount referentCount;
|
||||
mObserverTopicTable.EnumerateEntries(CountReferents, &referentCount);
|
||||
|
||||
// These aren't privacy-sensitive and so don't need anonymizing.
|
||||
nsresult rv;
|
||||
for (uint32_t i = 0; i < referentCount.suspectObservers.Length(); i++) {
|
||||
SuspectObserver& suspect = referentCount.suspectObservers[i];
|
||||
|
@ -45,7 +45,7 @@ MOZ_DEFINE_MALLOC_SIZE_OF(XPTIMallocSizeOf)
|
||||
|
||||
NS_IMETHODIMP
|
||||
XPTInterfaceInfoManager::CollectReports(nsIHandleReportCallback* aHandleReport,
|
||||
nsISupports* aData)
|
||||
nsISupports* aData, bool aAnonymize)
|
||||
{
|
||||
size_t amount = SizeOfIncludingThis(XPTIMallocSizeOf);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user