Bug 1265727 - Decouple FramerateFront from FramerateActor;r=fitzgen

This commit is contained in:
Eddy Bruel 2016-07-04 17:50:30 +02:00
Родитель c7bd381abc
Коммит d98fe32356
11 изменённых файлов: 72 добавлений и 46 удалений

Просмотреть файл

@ -3,11 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
"use strict";
const protocol = require("devtools/shared/protocol");
const { actorBridge } = require("devtools/server/actors/common");
const { method, custom, Arg, Option, RetVal } = protocol;
const { Actor, ActorClassWithSpec } = require("devtools/shared/protocol");
const { actorBridgeWithSpec } = require("devtools/server/actors/common");
const { on, once, off, emit } = require("sdk/event/core");
const { Framerate } = require("devtools/server/performance/framerate");
const { framerateSpec } = require("devtools/shared/specs/framerate");
/**
* An actor wrapper around Framerate. Uses exposed
@ -15,48 +15,19 @@ const { Framerate } = require("devtools/server/performance/framerate");
*
* @see devtools/server/performance/framerate.js for documentation.
*/
var FramerateActor = exports.FramerateActor = protocol.ActorClass({
typeName: "framerate",
var FramerateActor = exports.FramerateActor = ActorClassWithSpec(framerateSpec, {
initialize: function (conn, tabActor) {
protocol.Actor.prototype.initialize.call(this, conn);
Actor.prototype.initialize.call(this, conn);
this.bridge = new Framerate(tabActor);
},
destroy: function (conn) {
protocol.Actor.prototype.destroy.call(this, conn);
Actor.prototype.destroy.call(this, conn);
this.bridge.destroy();
},
startRecording: actorBridge("startRecording", {}),
stopRecording: actorBridge("stopRecording", {
request: {
beginAt: Arg(0, "nullable:number"),
endAt: Arg(1, "nullable:number")
},
response: { ticks: RetVal("array:number") }
}),
cancelRecording: actorBridge("cancelRecording"),
isRecording: actorBridge("isRecording", {
response: { recording: RetVal("boolean") }
}),
getPendingTicks: actorBridge("getPendingTicks", {
request: {
beginAt: Arg(0, "nullable:number"),
endAt: Arg(1, "nullable:number")
},
response: { ticks: RetVal("array:number") }
}),
});
/**
* The corresponding Front object for the FramerateActor.
*/
var FramerateFront = exports.FramerateFront = protocol.FrontClass(FramerateActor, {
initialize: function (client, { framerateActor }) {
protocol.Front.prototype.initialize.call(this, client, { actor: framerateActor });
this.manage(this);
}
startRecording: actorBridgeWithSpec("startRecording"),
stopRecording: actorBridgeWithSpec("stopRecording"),
cancelRecording: actorBridgeWithSpec("cancelRecording"),
isRecording: actorBridgeWithSpec("isRecording"),
getPendingTicks: actorBridgeWithSpec("getPendingTicks"),
});

Просмотреть файл

@ -31,7 +31,7 @@ window.onload = function() {
SimpleTest.waitForExplicitFinish();
var {FramerateFront} = require("devtools/server/actors/framerate");
var {FramerateFront} = require("devtools/shared/fronts/framerate");
function plotFPS(ticks, interval = 100, clamp = 60) {
var timeline = [];

Просмотреть файл

@ -31,7 +31,7 @@ window.onload = function() {
SimpleTest.waitForExplicitFinish();
var {FramerateFront} = require("devtools/server/actors/framerate");
var {FramerateFront} = require("devtools/shared/fronts/framerate");
function plotFPS(ticks, interval = 100, clamp = 60) {
var timeline = [];

Просмотреть файл

@ -31,7 +31,7 @@ window.onload = function() {
SimpleTest.waitForExplicitFinish();
var {FramerateFront} = require("devtools/server/actors/framerate");
var {FramerateFront} = require("devtools/shared/fronts/framerate");
var START_TICK = 2000;
var STOP_TICK = 3000;
var TOTAL_TIME = 5000;

Просмотреть файл

@ -16,7 +16,7 @@ Bug 1023018 - Tests if the framerate actor keeps recording after navigations.
window.onload = function() {
SimpleTest.waitForExplicitFinish();
var {FramerateFront} = require("devtools/server/actors/framerate");
var {FramerateFront} = require("devtools/shared/fronts/framerate");
var {TargetFactory} = require("devtools/client/framework/target");
var url = document.getElementById("testContent").href;

Просмотреть файл

@ -31,7 +31,7 @@ window.onload = function() {
SimpleTest.waitForExplicitFinish();
var {FramerateFront} = require("devtools/server/actors/framerate");
var {FramerateFront} = require("devtools/shared/fronts/framerate");
DebuggerServer.init();
DebuggerServer.addBrowserActors();

Просмотреть файл

@ -16,7 +16,7 @@ Bug 1171489 - Tests if the framerate actor does not record timestamps from multi
window.onload = function() {
SimpleTest.waitForExplicitFinish();
var {FramerateFront} = require("devtools/server/actors/framerate");
var {FramerateFront} = require("devtools/shared/fronts/framerate");
var {TargetFactory} = require("devtools/client/framework/target");
var url = document.getElementById("testContent").href;

Просмотреть файл

@ -0,0 +1,19 @@
/* 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 { framerateSpec } = require("devtools/shared/specs/framerate");
/**
* The corresponding Front object for the FramerateActor.
*/
var FramerateFront = exports.FramerateFront = FrontClassWithSpec(framerateSpec, {
initialize: function (client, { framerateActor }) {
Front.prototype.initialize.call(this, client, { actor: framerateActor });
this.manage(this);
}
});
exports.FramerateFront = FramerateFront;

Просмотреть файл

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

Просмотреть файл

@ -0,0 +1,34 @@
/* 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 framerateSpec = generateActorSpec({
typeName: "framerate",
methods: {
startRecording: {},
stopRecording: {
request: {
beginAt: Arg(0, "nullable:number"),
endAt: Arg(1, "nullable:number")
},
response: { ticks: RetVal("array:number") }
},
cancelRecording: {},
isRecording: {
response: { recording: RetVal("boolean") }
},
getPendingTicks: {
request: {
beginAt: Arg(0, "nullable:number"),
endAt: Arg(1, "nullable:number")
},
response: { ticks: RetVal("array:number") }
}
}
});
exports.framerateSpec = framerateSpec;

Просмотреть файл

@ -18,6 +18,7 @@ DevToolsModules(
'director-registry.js',
'environment.js',
'frame.js',
'framerate.js',
'gcli.js',
'heap-snapshot-file.js',
'highlighters.js',