Bug 1264873 - Ensure exposing memory actor for the browser content toolbox. r=yulia draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 18 Jul 2018 09:00:44 -0700
changeset 820396 df20aa17e2920b56b309c1bf8bee0d5d1a73d075
parent 820343 183ee39bf309cd8463d8db5b5c8eb232cd0dac53
child 820402 5e7f1683d87dbbf7edadec28ce62179a5d9c49bf
push id116809
push userbmo:poirot.alex@gmail.com
push dateThu, 19 Jul 2018 14:01:15 +0000
reviewersyulia
bugs1264873
milestone63.0a1
Bug 1264873 - Ensure exposing memory actor for the browser content toolbox. r=yulia MozReview-Commit-ID: 3duHXef13M4
devtools/server/actors/targets/content-process.js
devtools/server/performance/memory.js
--- 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;