Bug 924638 - use Services.jsm more in about:memory; r=njn

This commit is contained in:
Nathan Froyd 2013-10-08 16:28:21 -04:00
parent 7289391ff5
commit 5b278cdeed

View File

@ -50,10 +50,8 @@ let gMgr = Cc["@mozilla.org/memory-reporter-manager;1"]
// We need to know about "child-memory-reporter-update" events from child // We need to know about "child-memory-reporter-update" events from child
// processes. // processes.
let gOs = Cc["@mozilla.org/observer-service;1"] Services.obs.addObserver(updateAboutMemoryFromReporters,
.getService(Ci.nsIObserverService); "child-memory-reporter-update", false);
gOs.addObserver(updateAboutMemoryFromReporters,
"child-memory-reporter-update", false);
let gUnnamedProcessStr = "Main Process"; let gUnnamedProcessStr = "Main Process";
@ -122,8 +120,8 @@ function debug(x)
function onUnload() function onUnload()
{ {
gOs.removeObserver(updateAboutMemoryFromReporters, Services.obs.removeObserver(updateAboutMemoryFromReporters,
"child-memory-reporter-update"); "child-memory-reporter-update");
} }
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
@ -411,9 +409,7 @@ function onLoad()
function doGC() function doGC()
{ {
Cu.forceGC(); Cu.forceGC();
let os = Cc["@mozilla.org/observer-service;1"] Services.obs.notifyObservers(null, "child-gc-request", null);
.getService(Ci.nsIObserverService);
os.notifyObservers(null, "child-gc-request", null);
updateMainAndFooter("Garbage collection completed", HIDE_FOOTER); updateMainAndFooter("Garbage collection completed", HIDE_FOOTER);
} }
@ -422,9 +418,7 @@ function doCC()
window.QueryInterface(Ci.nsIInterfaceRequestor) window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils) .getInterface(Ci.nsIDOMWindowUtils)
.cycleCollect(); .cycleCollect();
let os = Cc["@mozilla.org/observer-service;1"] Services.obs.notifyObservers(null, "child-cc-request", null);
.getService(Ci.nsIObserverService);
os.notifyObservers(null, "child-cc-request", null);
updateMainAndFooter("Cycle collection completed", HIDE_FOOTER); updateMainAndFooter("Cycle collection completed", HIDE_FOOTER);
} }
@ -440,7 +434,7 @@ function doMeasure()
// update the page. If any reports come back from children, // update the page. If any reports come back from children,
// updateAboutMemoryFromReporters() will be called again and the page will // updateAboutMemoryFromReporters() will be called again and the page will
// regenerate. // regenerate.
gOs.notifyObservers(null, "child-memory-reporter-request", null); Services.obs.notifyObservers(null, "child-memory-reporter-request", null);
updateAboutMemoryFromReporters(); updateAboutMemoryFromReporters();
} }
@ -616,8 +610,6 @@ function updateAboutMemoryFromTwoFiles(aFilename1, aFilename2)
function updateAboutMemoryFromClipboard() function updateAboutMemoryFromClipboard()
{ {
// Get the clipboard's contents. // Get the clipboard's contents.
let cb = Cc["@mozilla.org/widget/clipboard;1"].
getService(Components.interfaces.nsIClipboard);
let transferable = Cc["@mozilla.org/widget/transferable;1"] let transferable = Cc["@mozilla.org/widget/transferable;1"]
.createInstance(Ci.nsITransferable); .createInstance(Ci.nsITransferable);
let loadContext = window.QueryInterface(Ci.nsIInterfaceRequestor) let loadContext = window.QueryInterface(Ci.nsIInterfaceRequestor)
@ -625,7 +617,7 @@ function updateAboutMemoryFromClipboard()
.QueryInterface(Ci.nsILoadContext); .QueryInterface(Ci.nsILoadContext);
transferable.init(loadContext); transferable.init(loadContext);
transferable.addDataFlavor('text/unicode'); transferable.addDataFlavor('text/unicode');
cb.getData(transferable, Ci.nsIClipboard.kGlobalClipboard); Services.clipboard.getData(transferable, Ci.nsIClipboard.kGlobalClipboard);
var cbData = {}; var cbData = {};
try { try {