diff --git a/devtools/server/actors/framerate.js b/devtools/server/actors/framerate.js index 3513266e555d..872cd7360617 100644 --- a/devtools/server/actors/framerate.js +++ b/devtools/server/actors/framerate.js @@ -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"), }); diff --git a/devtools/server/tests/mochitest/test_framerate_01.html b/devtools/server/tests/mochitest/test_framerate_01.html index fbee0b9ba88a..26fc3bc5c59d 100644 --- a/devtools/server/tests/mochitest/test_framerate_01.html +++ b/devtools/server/tests/mochitest/test_framerate_01.html @@ -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 = []; diff --git a/devtools/server/tests/mochitest/test_framerate_02.html b/devtools/server/tests/mochitest/test_framerate_02.html index fb3a04f96480..e3b5b713c913 100644 --- a/devtools/server/tests/mochitest/test_framerate_02.html +++ b/devtools/server/tests/mochitest/test_framerate_02.html @@ -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 = []; diff --git a/devtools/server/tests/mochitest/test_framerate_03.html b/devtools/server/tests/mochitest/test_framerate_03.html index 7a41026897c9..a11cb550ba6a 100644 --- a/devtools/server/tests/mochitest/test_framerate_03.html +++ b/devtools/server/tests/mochitest/test_framerate_03.html @@ -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; diff --git a/devtools/server/tests/mochitest/test_framerate_04.html b/devtools/server/tests/mochitest/test_framerate_04.html index dc6a4584b2b7..2d7c541f58cd 100644 --- a/devtools/server/tests/mochitest/test_framerate_04.html +++ b/devtools/server/tests/mochitest/test_framerate_04.html @@ -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; diff --git a/devtools/server/tests/mochitest/test_framerate_05.html b/devtools/server/tests/mochitest/test_framerate_05.html index a46e30826109..e2c8444fd1a3 100644 --- a/devtools/server/tests/mochitest/test_framerate_05.html +++ b/devtools/server/tests/mochitest/test_framerate_05.html @@ -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(); diff --git a/devtools/server/tests/mochitest/test_framerate_06.html b/devtools/server/tests/mochitest/test_framerate_06.html index 9eb8fd43f9ca..add38794b99c 100644 --- a/devtools/server/tests/mochitest/test_framerate_06.html +++ b/devtools/server/tests/mochitest/test_framerate_06.html @@ -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; diff --git a/devtools/shared/fronts/framerate.js b/devtools/shared/fronts/framerate.js new file mode 100644 index 000000000000..2aa678a0d295 --- /dev/null +++ b/devtools/shared/fronts/framerate.js @@ -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; diff --git a/devtools/shared/fronts/moz.build b/devtools/shared/fronts/moz.build index b77d7225c50d..9b825d311ffb 100644 --- a/devtools/shared/fronts/moz.build +++ b/devtools/shared/fronts/moz.build @@ -15,6 +15,7 @@ DevToolsModules( 'device.js', 'director-manager.js', 'director-registry.js', + 'framerate.js', 'gcli.js', 'highlighters.js', 'inspector.js', diff --git a/devtools/shared/specs/framerate.js b/devtools/shared/specs/framerate.js new file mode 100644 index 000000000000..9fb2dff5dc2e --- /dev/null +++ b/devtools/shared/specs/framerate.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; diff --git a/devtools/shared/specs/moz.build b/devtools/shared/specs/moz.build index 99ecd0c3e028..a25bd475cf6e 100644 --- a/devtools/shared/specs/moz.build +++ b/devtools/shared/specs/moz.build @@ -18,6 +18,7 @@ DevToolsModules( 'director-registry.js', 'environment.js', 'frame.js', + 'framerate.js', 'gcli.js', 'heap-snapshot-file.js', 'highlighters.js',