Bug 1264873 - Ensure exposing memory actor for the browser content toolbox. r=yulia
MozReview-Commit-ID: 3duHXef13M4
--- a/devtools/server/actors/targets/content-process.js
+++ b/devtools/server/actors/targets/content-process.js
@@ -17,16 +17,17 @@ const Services = require("Services");
const { ChromeDebuggerActor } = require("devtools/server/actors/thread");
const { WebConsoleActor } = require("devtools/server/actors/webconsole");
const makeDebugger = require("devtools/server/actors/utils/make-debugger");
const { ActorPool } = require("devtools/server/actors/common");
const { assert } = require("devtools/shared/DevToolsUtils");
const { TabSources } = require("devtools/server/actors/utils/TabSources");
loader.lazyRequireGetter(this, "WorkerTargetActorList", "devtools/server/actors/worker/worker-list", true);
+loader.lazyRequireGetter(this, "MemoryActor", "devtools/server/actors/memory", true);
function ContentProcessTargetActor(connection) {
this.conn = connection;
this._contextPool = new ActorPool(this.conn);
this.conn.addActorPool(this._contextPool);
this.threadActor = null;
// Use a see-everything debugger
@@ -99,23 +100,27 @@ ContentProcessTargetActor.prototype = {
this._consoleActor = new WebConsoleActor(this.conn, this);
this._contextPool.addActor(this._consoleActor);
}
if (!this.threadActor) {
this.threadActor = new ChromeDebuggerActor(this.conn, this);
this._contextPool.addActor(this.threadActor);
}
-
+ if (!this.memoryActor) {
+ this.memoryActor = new MemoryActor(this.conn, this);
+ this._contextPool.addActor(this.memoryActor);
+ }
return {
actor: this.actorID,
name: "Content process",
consoleActor: this._consoleActor.actorID,
chromeDebugger: this.threadActor.actorID,
+ memoryActor: this.memoryActor.actorID,
traits: {
highlightable: false,
networkMonitor: false,
},
};
},
--- a/devtools/server/performance/memory.js
+++ b/devtools/server/performance/memory.js
@@ -413,14 +413,20 @@ Memory.prototype = {
this.emit("allocations", this.getAllocations());
this._poller.arm();
},
/**
* Accesses the docshell to return the current process time.
*/
_getCurrentTime: function() {
- return (this.parent.isRootActor ? this.parent.docShell :
- this.parent.originalDocShell).now();
+ const docShell = this.parent.isRootActor ? this.parent.docShell :
+ this.parent.originalDocShell;
+ if (docShell) {
+ return docShell.now();
+ }
+ // When used from the ContentProcessTargetActor, parent has no docShell,
+ // so fallback to Cu.now
+ return Cu.now();
},
};
exports.Memory = Memory;