mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1265727 - Decouple EventLoopLagFront from EventLoopActor. r=fitzgen
This commit is contained in:
parent
55401c8180
commit
34cdf87c79
@ -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() {
|
||||
|
@ -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);
|
||||
},
|
||||
});
|
||||
|
@ -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();
|
||||
|
15
devtools/shared/fronts/eventlooplag.js
Normal file
15
devtools/shared/fronts/eventlooplag.js
Normal 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);
|
||||
},
|
||||
});
|
@ -15,6 +15,7 @@ DevToolsModules(
|
||||
'device.js',
|
||||
'director-manager.js',
|
||||
'director-registry.js',
|
||||
'eventlooplag.js',
|
||||
'framerate.js',
|
||||
'gcli.js',
|
||||
'highlighters.js',
|
||||
|
31
devtools/shared/specs/eventlooplag.js
Normal file
31
devtools/shared/specs/eventlooplag.js
Normal 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;
|
@ -17,6 +17,7 @@ DevToolsModules(
|
||||
'director-manager.js',
|
||||
'director-registry.js',
|
||||
'environment.js',
|
||||
'eventlooplag.js',
|
||||
'frame.js',
|
||||
'framerate.js',
|
||||
'gcli.js',
|
||||
|
Loading…
Reference in New Issue
Block a user