Chromium Code Reviews| Index: third_party/WebKit/Source/devtools/front_end/timeline/TimelineController.js |
| diff --git a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineController.js b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineController.js |
| index 853765d809ae17427fce6fd88ee911a0fb84e292..e7a796fe2658d20a3e00509d47abb66ed770b9ff 100644 |
| --- a/third_party/WebKit/Source/devtools/front_end/timeline/TimelineController.js |
| +++ b/third_party/WebKit/Source/devtools/front_end/timeline/TimelineController.js |
| @@ -70,10 +70,11 @@ WebInspector.TimelineController.prototype = { |
| stopRecording: function() |
| { |
| - WebInspector.targetManager.resumeAllTargets(); |
| this._allProfilesStoppedPromise = this._stopProfilingOnAllTargets(); |
| - if (this._targets[0]) |
| - this._targets[0].tracingManager.stop(); |
| + var mainTarget = WebInspector.targetManager.mainTarget(); |
| + if (mainTarget) |
| + mainTarget.tracingManager.stop(); |
| + WebInspector.targetManager.resumeAllTargets(); |
| this._delegate.loadingStarted(); |
| }, |
| @@ -97,6 +98,8 @@ WebInspector.TimelineController.prototype = { |
| this._targets.remove(target, true); |
| // FIXME: We'd like to stop profiling on the target and retrieve a profile |
| // but it's too late. Backend connection is closed. |
| + if (this._profiling) |
| + WebInspector.console.log(WebInspector.UIString("A target is disconnected while profiling. Its profile will not be retrieved.")); |
|
pfeldman
2016/03/17 00:34:31
Don't output this message - it jumps at the user i
alph
2016/03/17 01:10:08
Done.
|
| }, |
| /** |
| @@ -114,7 +117,9 @@ WebInspector.TimelineController.prototype = { |
| _startProfilingOnAllTargets: function() |
| { |
| var intervalUs = WebInspector.moduleSetting("highResolutionCpuProfiling").get() ? 100 : 1000; |
| - this._targets[0].profilerAgent().setSamplingInterval(intervalUs); |
| + var mainTarget = WebInspector.targetManager.mainTarget(); |
| + if (mainTarget) |
| + mainTarget.profilerAgent().setSamplingInterval(intervalUs); |
| this._profiling = true; |
| return Promise.all(this._targets.map(this._startProfilingOnTarget)); |
| }, |
| @@ -125,16 +130,8 @@ WebInspector.TimelineController.prototype = { |
| */ |
| _stopProfilingOnTarget: function(target) |
| { |
| - /** |
| - * @param {?Protocol.Error} error |
| - * @param {?ProfilerAgent.CPUProfile} profile |
| - * @return {?ProfilerAgent.CPUProfile} |
| - */ |
| - function extractProfile(error, profile) |
| - { |
| - return !error && profile ? profile : null; |
| - } |
| - return target.profilerAgent().stop(extractProfile).then(this._addCpuProfile.bind(this, target.id())); |
| + return target.profilerAgent().stop((error, profile) => !error && profile ? profile : null) |
| + .then(this._addCpuProfile.bind(this, target.id())); |
| }, |
| /** |
| @@ -161,7 +158,7 @@ WebInspector.TimelineController.prototype = { |
| this._startProfilingOnAllTargets() : Promise.resolve(); |
| var samplingFrequencyHz = WebInspector.moduleSetting("highResolutionCpuProfiling").get() ? 10000 : 1000; |
| var options = "sampling-frequency=" + samplingFrequencyHz; |
| - var mainTarget = this._targets[0]; |
| + var mainTarget = WebInspector.targetManager.mainTarget(); |
| var tracingManager = mainTarget.tracingManager; |
| mainTarget.resourceTreeModel.suspendReload(); |
| profilingStartedPromise.then(tracingManager.start.bind(tracingManager, this, categories, options, onTraceStarted)); |
| @@ -247,7 +244,7 @@ WebInspector.TimelineController.prototype = { |
| return; |
| var pid = mainMetaEvent.thread.process().id(); |
| - var mainTarget = this._targets[0]; |
| + var mainTarget = WebInspector.targetManager.mainTarget(); |
| var mainCpuProfile = this._cpuProfiles.get(mainTarget.id()); |
| this._injectCpuProfileEvent(pid, mainMetaEvent.thread.id(), mainCpuProfile); |