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

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: 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
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..49986ac4b49bb283ed6aa755c501a14298c90a67 100644
--- a/Source/devtools/front_end/sdk/CPUProfilerModel.js
+++ b/Source/devtools/front_end/sdk/CPUProfilerModel.js
@@ -50,7 +50,7 @@ WebInspector.CPUProfilerModel.EventTypes = {
WebInspector.CPUProfilerModel.prototype = {
/**
- * @param {!WebInspector.CPUProfilerModel.Delegate} delegate
+ * @param {?WebInspector.CPUProfilerModel.Delegate} delegate
*/
setDelegate: function(delegate)
{
@@ -67,7 +67,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);
+ if (this._delegate)
+ this._delegate.consoleProfileFinished(id, WebInspector.DebuggerModel.Location.fromPayload(this.target(), scriptLocation), cpuProfile, title);
},
/**
@@ -79,26 +80,34 @@ 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);
+ if (this._delegate)
+ this._delegate.consoleProfileStarted(id, WebInspector.DebuggerModel.Location.fromPayload(this.target(), scriptLocation), title);
},
/**
- * @param {boolean} isRecording
+ * @return {boolean}
*/
- setRecording: function(isRecording)
+ isRecordingProfile: function()
+ {
+ return this._isRecording;
+ },
+
+ startRecording: function()
{
- this._isRecording = isRecording;
- this.dispatchEventToListeners(isRecording ?
- WebInspector.CPUProfilerModel.EventTypes.ProfileStarted :
- WebInspector.CPUProfilerModel.EventTypes.ProfileStopped);
+ this._isRecording = true;
+ this.target().profilerAgent().start();
+ this.dispatchEventToListeners(WebInspector.CPUProfilerModel.EventTypes.ProfileStarted);
+ WebInspector.userMetrics.ProfilesCPUProfileTaken.record();
},
/**
- * @return {boolean}
- */
- isRecordingProfile: function()
+ * @param {!function(?string,?ProfilerAgent.CPUProfile)} callback
+ */
+ stopRecording: function(callback)
{
- return this._isRecording;
+ this._isRecording = false;
+ this.target().profilerAgent().stop(callback);
+ this.dispatchEventToListeners(WebInspector.CPUProfilerModel.EventTypes.ProfileStopped);
},
__proto__: WebInspector.TargetAwareObject.prototype

Powered by Google App Engine
This is Rietveld 408576698