Bug 1265727 - Decouple EventLoopLagFront from EventLoopActor. r=fitzgen

This commit is contained in:
Eddy Bruel 2016-07-21 12:52:30 +02:00
parent 55401c8180
commit 34cdf87c79
7 changed files with 58 additions and 31 deletions

View File

@ -25,7 +25,7 @@ XPCOMUtils.defineLazyGetter(this, 'WebConsoleUtils', function() {
});
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() {

View File

@ -13,51 +13,38 @@
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");
const {eventLoopLagSpec} = require("devtools/shared/specs/eventlooplag");
var EventLoopLagActor = exports.EventLoopLagActor = protocol.ActorClass({
typeName: "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
@ -71,11 +58,3 @@ var EventLoopLagActor = exports.EventLoopLagActor = protocol.ActorClass({
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);
},
});

View File

@ -9,7 +9,7 @@
function run_test()
{
let {EventLoopLagFront} = require("devtools/server/actors/eventlooplag");
let {EventLoopLagFront} = require("devtools/shared/fronts/eventlooplag");
DebuggerServer.init();
DebuggerServer.addBrowserActors();

View File

@ -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);
},
});

View File

@ -15,6 +15,7 @@ DevToolsModules(
'device.js',
'director-manager.js',
'director-registry.js',
'eventlooplag.js',
'framerate.js',
'gcli.js',
'highlighters.js',

View File

@ -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;

View File

@ -17,6 +17,7 @@ DevToolsModules(
'director-manager.js',
'director-registry.js',
'environment.js',
'eventlooplag.js',
'frame.js',
'framerate.js',
'gcli.js',