Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2002)

Unified Diff: Source/devtools/front_end/sdk/CPUProfilerModel.js

Issue 360053003: DevTools: Basic support of multiple targets for CPU profiler (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix tests Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/devtools/front_end/profiler/CPUProfileView.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/devtools/front_end/sdk/CPUProfilerModel.js
diff --git a/Source/devtools/front_end/sdk/CPUProfilerModel.js b/Source/devtools/front_end/sdk/CPUProfilerModel.js
index 678e1888e03b42188db83dda6e67a3da133e2f5b..94625e15036325ae1b19657ea26c8f7a559aaf07 100644
--- a/Source/devtools/front_end/sdk/CPUProfilerModel.js
+++ b/Source/devtools/front_end/sdk/CPUProfilerModel.js
@@ -35,29 +35,20 @@
WebInspector.CPUProfilerModel = function(target)
{
WebInspector.TargetAwareObject.call(this, target);
-
- /** @type {?WebInspector.CPUProfilerModel.Delegate} */
- this._delegate = null;
this._isRecording = false;
target.registerProfilerDispatcher(this);
target.profilerAgent().enable();
}
WebInspector.CPUProfilerModel.EventTypes = {
- ProfileStarted: "profile-started",
- ProfileStopped: "profile-stopped"
+ ProfileStarted: "ProfileStarted",
+ ProfileStopped: "ProfileStopped",
+ ConsoleProfileStarted: "ConsoleProfileStarted",
+ ConsoleProfileFinished: "ConsoleProfileFinished"
};
WebInspector.CPUProfilerModel.prototype = {
/**
- * @param {!WebInspector.CPUProfilerModel.Delegate} delegate
- */
- setDelegate: function(delegate)
- {
- this._delegate = delegate;
- },
-
- /**
* @param {string} id
* @param {!DebuggerAgent.Location} scriptLocation
* @param {!ProfilerAgent.CPUProfile} cpuProfile
@@ -67,7 +58,8 @@ WebInspector.CPUProfilerModel.prototype = {
{
// Make sure ProfilesPanel is initialized and CPUProfileType is created.
WebInspector.moduleManager.loadModule("profiler");
- this._delegate.consoleProfileFinished(id, WebInspector.DebuggerModel.Location.fromPayload(this.target(), scriptLocation), cpuProfile, title);
+ var debuggerLocation = WebInspector.DebuggerModel.Location.fromPayload(this.target(), scriptLocation);
+ this.dispatchEventToListeners(WebInspector.CPUProfilerModel.EventTypes.ConsoleProfileFinished, {protocolId: id, scriptLocation: debuggerLocation, cpuProfile: cpuProfile, title: title});
},
/**
@@ -79,18 +71,8 @@ WebInspector.CPUProfilerModel.prototype = {
{
// Make sure ProfilesPanel is initialized and CPUProfileType is created.
WebInspector.moduleManager.loadModule("profiler");
- this._delegate.consoleProfileStarted(id, WebInspector.DebuggerModel.Location.fromPayload(this.target(), scriptLocation), title);
- },
-
- /**
- * @param {boolean} isRecording
- */
- setRecording: function(isRecording)
- {
- this._isRecording = isRecording;
- this.dispatchEventToListeners(isRecording ?
- WebInspector.CPUProfilerModel.EventTypes.ProfileStarted :
- WebInspector.CPUProfilerModel.EventTypes.ProfileStopped);
+ var debuggerLocation = WebInspector.DebuggerModel.Location.fromPayload(this.target(), scriptLocation)
+ this.dispatchEventToListeners(WebInspector.CPUProfilerModel.EventTypes.ConsoleProfileStarted, {protocolId: id, scriptLocation: debuggerLocation, title: title});
},
/**
@@ -101,27 +83,25 @@ WebInspector.CPUProfilerModel.prototype = {
return this._isRecording;
},
- __proto__: WebInspector.TargetAwareObject.prototype
-}
-
-/** @interface */
-WebInspector.CPUProfilerModel.Delegate = function() {};
+ startRecording: function()
+ {
+ this._isRecording = true;
+ this.target().profilerAgent().start();
+ this.dispatchEventToListeners(WebInspector.CPUProfilerModel.EventTypes.ProfileStarted);
+ WebInspector.userMetrics.ProfilesCPUProfileTaken.record();
+ },
-WebInspector.CPUProfilerModel.Delegate.prototype = {
/**
- * @param {string} protocolId
- * @param {!WebInspector.DebuggerModel.Location} scriptLocation
- * @param {string=} title
+ * @param {!function(?string,?ProfilerAgent.CPUProfile)} callback
*/
- consoleProfileStarted: function(protocolId, scriptLocation, title) {},
+ stopRecording: function(callback)
+ {
+ this._isRecording = false;
+ this.target().profilerAgent().stop(callback);
+ this.dispatchEventToListeners(WebInspector.CPUProfilerModel.EventTypes.ProfileStopped);
+ },
- /**
- * @param {string} protocolId
- * @param {!WebInspector.DebuggerModel.Location} scriptLocation
- * @param {!ProfilerAgent.CPUProfile} cpuProfile
- * @param {string=} title
- */
- consoleProfileFinished: function(protocolId, scriptLocation, cpuProfile, title) {}
+ __proto__: WebInspector.TargetAwareObject.prototype
}
/**
« no previous file with comments | « Source/devtools/front_end/profiler/CPUProfileView.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698