Bug 752381 - Merge System Principal compartments in about:memory. r=jlebar.

This commit is contained in:
Nicholas Nethercote 2012-05-06 22:05:16 -07:00
parent d573b50a05
commit f1e81b0077

View File

@ -1197,7 +1197,7 @@ XPCJSRuntime::~XPCJSRuntime()
}
static void
GetCompartmentName(JSCompartment *c, bool getAddress, nsCString &name)
GetCompartmentName(JSCompartment *c, nsCString &name)
{
if (js::IsAtomsCompartment(c)) {
name.AssignLiteral("atoms");
@ -1205,9 +1205,6 @@ GetCompartmentName(JSCompartment *c, bool getAddress, nsCString &name)
nsJSPrincipals::get(principals)->GetScriptLocation(name);
// For system compartments we append the location, if there is one.
// And we append the address if |getAddress| is true, so that
// multiple system compartments (and there can be many) can be
// distinguished.
if (js::IsSystemCompartment(c)) {
xpc::CompartmentPrivate *compartmentPrivate =
static_cast<xpc::CompartmentPrivate*>(JS_GetCompartmentPrivate(c));
@ -1215,12 +1212,6 @@ GetCompartmentName(JSCompartment *c, bool getAddress, nsCString &name)
name.AppendLiteral(", ");
name.Append(compartmentPrivate->location);
}
if (getAddress) {
// ample; 64-bit address max is 18 chars
nsPrintfCString address(", 0x%llx", PRUint64(c));
name.Append(address);
}
}
// A hack: replace forward slashes with '\\' so they aren't
@ -1641,7 +1632,7 @@ class JSCompartmentsMultiReporter : public nsIMemoryMultiReporter
// silently ignore OOM errors
Paths *paths = static_cast<Paths *>(data);
nsCString path;
GetCompartmentName(c, /* getAddress = */ false, path);
GetCompartmentName(c, path);
path.Insert(js::IsSystemCompartment(c)
? NS_LITERAL_CSTRING("compartments/system/")
: NS_LITERAL_CSTRING("compartments/user/"),
@ -1698,7 +1689,7 @@ struct XPCJSRuntimeStats : public JS::RuntimeStats {
virtual void initExtraCompartmentStats(JSCompartment *c,
JS::CompartmentStats *cstats) MOZ_OVERRIDE {
nsCAutoString name;
GetCompartmentName(c, /* getAddress = */ true, name);
GetCompartmentName(c, name);
cstats->extra = strdup(name.get());
}
};