Bug 751034 - Support remote profiling Via Remote debugging protocol. r=past,rcampbell

This commit is contained in:
Benoit Girard 2012-09-06 16:55:55 +03:00
parent 2df4be745b
commit 64e4b4e648
2 changed files with 79 additions and 0 deletions

View File

@ -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");

View File

@ -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)