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