/* 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 { Cu } = require("chrome"); const protocol = require("devtools/server/protocol"); const { custom, method, RetVal, Arg, Option, types } = protocol; const { Profiler } = require("devtools/server/performance/profiler"); const { actorBridge } = require("devtools/server/actors/common"); loader.lazyRequireGetter(this, "events", "sdk/event/core"); loader.lazyRequireGetter(this, "extend", "sdk/util/object", true); types.addType("profiler-data", { // On Fx42+, the profile is only deserialized on the front; older // servers will get the profiler data as an object from nsIProfiler, // causing one parse/stringify cycle, then again implicitly in a packet. read: (v) => { if (typeof v.profile === "string") { // Create a new response object since `profile` is read only. let newValue = Object.create(null); newValue.profile = JSON.parse(v.profile); newValue.currentTime = v.currentTime; return newValue; } return v; } }); /** * This actor wraps the Profiler module at devtools/server/performance/profiler.js * and provides RDP definitions. * * @see devtools/server/performance/profiler.js for documentation. */ var ProfilerActor = exports.ProfilerActor = protocol.ActorClass({ typeName: "profiler", /** * The set of events the ProfilerActor emits over RDP. */ events: { "console-api-profiler": { data: Arg(0, "json"), }, "profiler-started": { data: Arg(0, "json"), }, "profiler-stopped": { data: Arg(0, "json"), }, "profiler-status": { data: Arg(0, "json"), }, // Only for older geckos, pre-protocol.js ProfilerActor (