Bug 751034 part 3 - Send notifications through remote debugging protocol when the profiler starts/stops. r=past
authorMike Hommey <mh+mozilla@glandium.org>
Thu, 13 Sep 2012 00:14:12 +0200
changeset 107365 f0a944193de7d52a41846f43652658c6896f486e
parent 107364 f11a44846f265dea7c7fb64dd231b58218d7b037
child 107491 2208b83cc81d7ea02fa30f27a03c9f3f5b766155
push id1096
push userpastithas@mozilla.com
push dateThu, 20 Sep 2012 06:50:38 +0000
treeherderfx-team@f0a944193de7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspast
bugs751034
milestone18.0a1
Bug 751034 part 3 - Send notifications through remote debugging protocol when the profiler starts/stops. r=past
toolkit/devtools/debugger/dbg-client.jsm
toolkit/devtools/debugger/server/dbg-profiler-actors.js
--- a/toolkit/devtools/debugger/dbg-client.jsm
+++ b/toolkit/devtools/debugger/dbg-client.jsm
@@ -161,17 +161,18 @@ const ThreadStateTypes = {
 
 /**
  * Set of protocol messages that are sent by the server without a prior request
  * by the client.
  */
 const UnsolicitedNotifications = {
   "newScript": "newScript",
   "tabDetached": "tabDetached",
-  "tabNavigated": "tabNavigated"
+  "tabNavigated": "tabNavigated",
+  "profilerStateChanged": "profilerStateChanged"
 };
 
 /**
  * Set of pause types that are sent by the server and not as an immediate
  * response to a client request.
  */
 const UnsolicitedPauses = {
   "resumeLimit": "resumeLimit",
--- a/toolkit/devtools/debugger/server/dbg-profiler-actors.js
+++ b/toolkit/devtools/debugger/server/dbg-profiler-actors.js
@@ -3,20 +3,25 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 /**
  * Creates a ProfilerActor. ProfilerActor provides remote access to the
  * built-in profiler module.
  */
-function ProfilerActor()
+function ProfilerActor(aConnection)
 {
+  this._conn = aConnection;
   this._profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler);
   this._started = false;
+
+  Cu.import("resource://gre/modules/Services.jsm");
+  Services.obs.addObserver(this, "profiler-started", false);
+  Services.obs.addObserver(this, "profiler-stopped", false);
 }
 
 ProfilerActor.prototype = {
   actorPrefix: "profiler",
 
   disconnect: function() {
     if (this._profiler && this._started) {
       this._profiler.StopProfiler();
@@ -53,17 +58,24 @@ ProfilerActor.prototype = {
   },
   onGetFeatures: function(aRequest) {
     var features = this._profiler.GetFeatures([]);
     return { "features": features }
   },
   onGetSharedLibraryInformation: function(aRequest) {
     var sharedLibraries = this._profiler.getSharedLibraryInformation();
     return { "sharedLibraryInformation": sharedLibraries }
-  }
+  },
+  observe: function(aSubject, aTopic, aData) {
+    if (aTopic == "profiler-started") {
+      this.conn.send({ from: this.actorID, type: "profilerStateChanged", isActive: true });
+    } else if (aTopic == "profiler-stopped") {
+      this.conn.send({ from: this.actorID, type: "profilerStateChanged", isActive: false });
+    }
+  },
 };
 
 /**
  * The request types this actor can handle.
  */
 ProfilerActor.prototype.requestTypes = {
   "startProfiler": ProfilerActor.prototype.onStartProfiler,
   "stopProfiler": ProfilerActor.prototype.onStopProfiler,