From 64e4b4e648ca5c872c3105efc6f8405360e70a2e Mon Sep 17 00:00:00 2001 From: Benoit Girard Date: Thu, 6 Sep 2012 16:55:55 +0300 Subject: [PATCH] Bug 751034 - Support remote profiling Via Remote debugging protocol. r=past,rcampbell --- .../debugger/server/dbg-profiler-actors.js | 78 +++++++++++++++++++ toolkit/devtools/jar.mn | 1 + 2 files changed, 79 insertions(+) create mode 100644 toolkit/devtools/debugger/server/dbg-profiler-actors.js diff --git a/toolkit/devtools/debugger/server/dbg-profiler-actors.js b/toolkit/devtools/debugger/server/dbg-profiler-actors.js new file mode 100644 index 00000000000..ae00a0f27ce --- /dev/null +++ b/toolkit/devtools/debugger/server/dbg-profiler-actors.js @@ -0,0 +1,78 @@ +/* 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"; + +/** + * Creates a ProfilerActor. ProfilerActor provides remote access to the + * built-in profiler module. + */ +function ProfilerActor() +{ + this._profiler = Cc["@mozilla.org/tools/profiler;1"].getService(Ci.nsIProfiler); + this._started = false; +} + +ProfilerActor.prototype = { + actorPrefix: "profiler", + + disconnect: function() { + if (this._profiler && this._started) { + this._profiler.StopProfiler(); + } + this._profiler = null; + }, + + onStartProfiler: function(aRequest) { + this._profiler.StartProfiler(aRequest.entries, aRequest.interval, + aRequest.features, aRequest.features.length); + this._started = true; + return { "msg": "profiler started" } + }, + onStopProfiler: function(aRequest) { + this._profiler.StopProfiler(); + this._started = false; + return { "msg": "profiler stopped" } + }, + onGetProfileStr: function(aRequest) { + var profileStr = this._profiler.GetProfile(); + return { "profileStr": profileStr } + }, + onGetProfile: function(aRequest) { + var profile = this._profiler.getProfileData(); + return { "profile": profile } + }, + onIsActive: function(aRequest) { + var isActive = this._profiler.IsActive(); + return { "isActive": isActive } + }, + onGetResponsivenessTimes: function(aRequest) { + var times = this._profiler.GetResponsivenessTimes({}); + return { "responsivenessTimes": times } + }, + onGetFeatures: function(aRequest) { + var features = this._profiler.GetFeatures([]); + return { "features": features } + }, + onGetSharedLibraryInformation: function(aRequest) { + var sharedLibraries = this._profiler.getSharedLibraryInformation(); + return { "sharedLibraryInformation": sharedLibraries } + } +}; + +/** + * The request types this actor can handle. + */ +ProfilerActor.prototype.requestTypes = { + "startProfiler": ProfilerActor.prototype.onStartProfiler, + "stopProfiler": ProfilerActor.prototype.onStopProfiler, + "getProfileStr": ProfilerActor.prototype.onGetProfileStr, + "getProfile": ProfilerActor.prototype.onGetProfile, + "isActive": ProfilerActor.prototype.onIsActive, + "getResponsivenessTimes": ProfilerActor.prototype.onGetResponsivenessTimes, + "getFeatures": ProfilerActor.prototype.onGetFeatures, + "getSharedLibraryInformation": ProfilerActor.prototype.onGetSharedLibraryInformation +}; + +DebuggerServer.addGlobalActor(ProfilerActor, "profilerActor"); diff --git a/toolkit/devtools/jar.mn b/toolkit/devtools/jar.mn index d9bc9ef020b..7a1a7491a8a 100644 --- a/toolkit/devtools/jar.mn +++ b/toolkit/devtools/jar.mn @@ -7,3 +7,4 @@ toolkit.jar: content/global/devtools/dbg-server.js (debugger/server/dbg-server.js) content/global/devtools/dbg-script-actors.js (debugger/server/dbg-script-actors.js) content/global/devtools/dbg-browser-actors.js (debugger/server/dbg-browser-actors.js) + content/global/devtools/dbg-profiler-actors.js (debugger/server/dbg-profiler-actors.js)