Bug 1265727 - Decouple EventLoopLagFront from EventLoopActor. r=fitzgen
authorEddy Bruel <ejpbruel@mozilla.com
Thu, 21 Jul 2016 12:52:30 +0200
changeset 306095 cab3629ad5fd8f7d6c960bdf966b14cfb06e7eb3
parent 306094 17409ee90c864e7e982a43e2026e6814a0797e4d
child 306096 e28e856b987380f55d699092f11f6997378f79a6
child 306223 d8a5ea157504793ff2bb2b5161103154a31f08e3
push id79765
push usercbook@mozilla.com
push dateThu, 21 Jul 2016 14:26:34 +0000
treeherdermozilla-inbound@ab54bfc55266 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfitzgen
bugs1265727
milestone50.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1265727 - Decouple EventLoopLagFront from EventLoopActor. r=fitzgen
b2g/chrome/content/devtools/hud.js
devtools/server/actors/eventlooplag.js
devtools/server/tests/unit/test_eventlooplag_actor.js
devtools/shared/fronts/eventlooplag.js
devtools/shared/fronts/moz.build
devtools/shared/specs/eventlooplag.js
devtools/shared/specs/moz.build
--- a/b2g/chrome/content/devtools/hud.js
+++ b/b2g/chrome/content/devtools/hud.js
@@ -20,17 +20,17 @@ XPCOMUtils.defineLazyGetter(this, 'Debug
   return devtools.require('devtools/shared/client/main').DebuggerClient;
 });
 
 XPCOMUtils.defineLazyGetter(this, 'WebConsoleUtils', function() {
   return devtools.require('devtools/shared/webconsole/utils').Utils;
 });
 
 XPCOMUtils.defineLazyGetter(this, 'EventLoopLagFront', function() {
-  return devtools.require('devtools/server/actors/eventlooplag').EventLoopLagFront;
+  return devtools.require('devtools/shared/fronts/eventlooplag').EventLoopLagFront;
 });
 
 XPCOMUtils.defineLazyGetter(this, 'PerformanceEntriesFront', function() {
   return devtools.require('devtools/server/actors/performance-entries').PerformanceEntriesFront;
 });
 
 XPCOMUtils.defineLazyGetter(this, 'MemoryFront', function() {
   return devtools.require('devtools/server/actors/memory').MemoryFront;
--- a/devtools/server/actors/eventlooplag.js
+++ b/devtools/server/actors/eventlooplag.js
@@ -8,74 +8,53 @@
  * The eventLoopLag actor emits "event-loop-lag" events when the event
  * loop gets unresponsive. The event comes with a "time" property (the
  * duration of the lag in milliseconds).
  */
 
 const {Ci} = require("chrome");
 const Services = require("Services");
 const {XPCOMUtils} = require("resource://gre/modules/XPCOMUtils.jsm");
-const protocol = require("devtools/shared/protocol");
-const {method, Arg, RetVal} = protocol;
+const {Actor, ActorClassWithSpec} = require("devtools/shared/protocol");
 const events = require("sdk/event/core");
-
-var EventLoopLagActor = exports.EventLoopLagActor = protocol.ActorClass({
-
-  typeName: "eventLoopLag",
+const {eventLoopLagSpec} = require("devtools/shared/specs/eventlooplag");
 
+var EventLoopLagActor = exports.EventLoopLagActor = ActorClassWithSpec(eventLoopLagSpec, {
   _observerAdded: false,
 
-  events: {
-    "event-loop-lag" : {
-      type: "event-loop-lag",
-      time: Arg(0, "number") // duration of the lag in milliseconds.
-    }
-  },
-
   /**
    * Start tracking the event loop lags.
    */
-  start: method(function () {
+  start: function () {
     if (!this._observerAdded) {
       Services.obs.addObserver(this, "event-loop-lag", false);
       this._observerAdded = true;
     }
     return Services.appShell.startEventLoopLagTracking();
-  }, {
-    request: {},
-    response: {success: RetVal("number")}
-  }),
+  },
 
   /**
    * Stop tracking the event loop lags.
    */
-  stop: method(function () {
+  stop: function () {
     if (this._observerAdded) {
       Services.obs.removeObserver(this, "event-loop-lag");
       this._observerAdded = false;
     }
     Services.appShell.stopEventLoopLagTracking();
-  }, {request: {}, response: {}}),
+  },
 
   destroy: function () {
     this.stop();
-    protocol.Actor.prototype.destroy.call(this);
+    Actor.prototype.destroy.call(this);
   },
 
   // nsIObserver
 
   observe: function (subject, topic, data) {
     if (topic == "event-loop-lag") {
       // Forward event loop lag event
       events.emit(this, "event-loop-lag", data);
     }
   },
 
   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
 });
-
-exports.EventLoopLagFront = protocol.FrontClass(EventLoopLagActor, {
-  initialize: function (client, form) {
-    protocol.Front.prototype.initialize.call(this, client);
-    this.actorID = form.eventLoopLagActor;
-    this.manage(this);
-  },
-});
--- a/devtools/server/tests/unit/test_eventlooplag_actor.js
+++ b/devtools/server/tests/unit/test_eventlooplag_actor.js
@@ -4,17 +4,17 @@
 /**
  * Test the eventLoopLag actor.
  */
 
 "use strict";
 
 function run_test()
 {
-  let {EventLoopLagFront} = require("devtools/server/actors/eventlooplag");
+  let {EventLoopLagFront} = require("devtools/shared/fronts/eventlooplag");
 
   DebuggerServer.init();
   DebuggerServer.addBrowserActors();
 
   // As seen in EventTracer.cpp
   let threshold = 20;
   let interval = 10;
 
new file mode 100644
--- /dev/null
+++ b/devtools/shared/fronts/eventlooplag.js
@@ -0,0 +1,15 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Front, FrontClassWithSpec } = require("devtools/shared/protocol");
+const { eventLoopLagSpec } = require("devtools/shared/specs/eventlooplag");
+
+exports.EventLoopLagFront = FrontClassWithSpec(eventLoopLagSpec, {
+  initialize: function (client, form) {
+    Front.prototype.initialize.call(this, client);
+    this.actorID = form.eventLoopLagActor;
+    this.manage(this);
+  },
+});
--- a/devtools/shared/fronts/moz.build
+++ b/devtools/shared/fronts/moz.build
@@ -10,16 +10,17 @@ DevToolsModules(
     'animation.js',
     'call-watcher.js',
     'canvas.js',
     'css-properties.js',
     'csscoverage.js',
     'device.js',
     'director-manager.js',
     'director-registry.js',
+    'eventlooplag.js',
     'framerate.js',
     'gcli.js',
     'highlighters.js',
     'inspector.js',
     'layout.js',
     'memory.js',
     'performance-recording.js',
     'performance.js',
new file mode 100644
--- /dev/null
+++ b/devtools/shared/specs/eventlooplag.js
@@ -0,0 +1,31 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+"use strict";
+
+const { Arg, RetVal, generateActorSpec } = require("devtools/shared/protocol");
+
+const eventLoopLagSpec = generateActorSpec({
+  typeName: "eventLoopLag",
+
+  events: {
+    "event-loop-lag": {
+      type: "event-loop-lag",
+      // duration of the lag in milliseconds.
+      time: Arg(0, "number")
+    }
+  },
+
+  methods: {
+    start: {
+      request: {},
+      response: {success: RetVal("number")}
+    },
+    stop: {
+      request: {},
+      response: {}
+    }
+  }
+});
+
+exports.eventLoopLagSpec = eventLoopLagSpec;
--- a/devtools/shared/specs/moz.build
+++ b/devtools/shared/specs/moz.build
@@ -12,16 +12,17 @@ DevToolsModules(
     'call-watcher.js',
     'canvas.js',
     'css-properties.js',
     'csscoverage.js',
     'device.js',
     'director-manager.js',
     'director-registry.js',
     'environment.js',
+    'eventlooplag.js',
     'frame.js',
     'framerate.js',
     'gcli.js',
     'heap-snapshot-file.js',
     'highlighters.js',
     'inspector.js',
     'layout.js',
     'memory.js',