Bug 1127570 - Include measurement origins in about:memory's title bar. r=mccr8.

This changes about:memory so that whenever measurements are shown, the origin
of those measurements is visible in the title bar.

- "about:memory (live measurement)" is used when you do "Measure".

- "about:memory (<filename>)" is used when you do "Load...".

- "about:memory (diff of <filename1> and <filename2>)" is used when you do
  "Load and diff...".

- "about:memory" is used in all other cases, e.g. when about:memory is first
  loaded, and after all non-measurement actions (GC, GC, etc.)

--HG--
extra : rebase_source : 4d1da88d17481916cda5018b7a8298e67c916274
This commit is contained in:
Nicholas Nethercote 2015-02-02 16:53:49 -08:00
parent b9f3319bd7
commit 5c982c8e46
2 changed files with 26 additions and 10 deletions

View File

@ -49,6 +49,9 @@ XPCOMUtils.defineLazyGetter(this, "nsGzipConverter",
let gMgr = Cc["@mozilla.org/memory-reporter-manager;1"]
.getService(Ci.nsIMemoryReporterManager);
const gPageName = 'about:memory';
document.title = gPageName;
const gUnnamedProcessStr = "Main Process";
let gIsDiff = false;
@ -133,12 +136,17 @@ let gVerbose;
// The "anonymize" checkbox.
let gAnonymize;
// Values for the second argument to updateMainAndFooter.
// Values for the |aFooterAction| argument to updateTitleMainAndFooter.
let HIDE_FOOTER = 0;
let SHOW_FOOTER = 1;
function updateMainAndFooter(aMsg, aFooterAction, aClassName)
function updateTitleMainAndFooter(aTitleNote, aMsg, aFooterAction, aClassName)
{
document.title = gPageName;
if (aTitleNote) {
document.title += " (" + aTitleNote + ")";
}
// Clear gMain by replacing it with an empty node.
let tmp = gMain.cloneNode(false);
gMain.parentNode.replaceChild(tmp, gMain);
@ -163,11 +171,16 @@ function updateMainAndFooter(aMsg, aFooterAction, aClassName)
switch (aFooterAction) {
case HIDE_FOOTER: gFooter.classList.add('hidden'); break;
case SHOW_FOOTER: gFooter.classList.remove('hidden'); break;
default: assertInput(false, "bad footer action in updateMainAndFooter");
default: assertInput(false, "bad footer action in updateTitleMainAndFooter");
}
return msgElement;
}
function updateMainAndFooter(aMsg, aFooterAction, aClassName)
{
return updateTitleMainAndFooter("", aMsg, aFooterAction, aClassName);
}
function appendTextNode(aP, aText)
{
let e = document.createTextNode(aText);
@ -504,7 +517,7 @@ function updateAboutMemoryFromReporters()
}
let displayReportsAndFooter = function() {
updateMainAndFooter("", SHOW_FOOTER);
updateTitleMainAndFooter("live measurement", "", SHOW_FOOTER);
aDisplayReports();
}
@ -610,10 +623,12 @@ function updateAboutMemoryFromJSONString(aStr)
*
* @param aFilename
* The name of the file being read from.
* @param aTitleNote
* A description to put in the page title upon completion.
* @param aFn
* The function to call and pass the read string to upon completion.
*/
function loadMemoryReportsFromFile(aFilename, aFn)
function loadMemoryReportsFromFile(aFilename, aTitleNote, aFn)
{
updateMainAndFooter("Loading...", HIDE_FOOTER);
@ -622,7 +637,8 @@ function loadMemoryReportsFromFile(aFilename, aFn)
reader.onerror = () => { throw "FileReader.onerror"; };
reader.onabort = () => { throw "FileReader.onabort"; };
reader.onload = (aEvent) => {
updateMainAndFooter("", SHOW_FOOTER); // Clear "Loading..." from above.
// Clear "Loading..." from above.
updateTitleMainAndFooter(aTitleNote, "", SHOW_FOOTER);
aFn(aEvent.target.result);
};
@ -672,7 +688,7 @@ function loadMemoryReportsFromFile(aFilename, aFn)
*/
function updateAboutMemoryFromFile(aFilename)
{
loadMemoryReportsFromFile(aFilename,
loadMemoryReportsFromFile(aFilename, /* title note */ aFilename,
updateAboutMemoryFromJSONString);
}
@ -687,8 +703,9 @@ function updateAboutMemoryFromFile(aFilename)
*/
function updateAboutMemoryFromTwoFiles(aFilename1, aFilename2)
{
loadMemoryReportsFromFile(aFilename1, function(aStr1) {
loadMemoryReportsFromFile(aFilename2, function(aStr2) {
let titleNote = "diff of " + aFilename1 + " and " + aFilename2;
loadMemoryReportsFromFile(aFilename1, titleNote, function(aStr1) {
loadMemoryReportsFromFile(aFilename2, titleNote, function(aStr2) {
try {
let obj1 = parseAndUnwrapIfCrashDump(aStr1);
let obj2 = parseAndUnwrapIfCrashDump(aStr2);

View File

@ -6,7 +6,6 @@
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>about:memory</title>
<meta name="viewport" content="width=device-width"/>
<link rel="stylesheet" href="chrome://global/skin/aboutMemory.css" type="text/css"/>
<script type="text/javascript;version=1.8" src="chrome://global/content/aboutMemory.js"/>