Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * @constructor | 6 * @constructor |
| 7 * @param {!WebInspector.Target} target | 7 * @param {!WebInspector.Target} target |
| 8 * @param {!WebInspector.TimelineLifecycleDelegate} delegate | 8 * @param {!WebInspector.TimelineLifecycleDelegate} delegate |
| 9 * @param {!WebInspector.TracingModel} tracingModel | 9 * @param {!WebInspector.TracingModel} tracingModel |
| 10 * @implements {WebInspector.TargetManager.Observer} | 10 * @implements {WebInspector.TargetManager.Observer} |
| 11 * @implements {WebInspector.TracingManagerClient} | 11 * @implements {WebInspector.TracingManagerClient} |
| 12 */ | 12 */ |
| 13 WebInspector.TimelineController = function(target, delegate, tracingModel) | 13 WebInspector.TimelineController = function(target, delegate, tracingModel) |
| 14 { | 14 { |
| 15 this._delegate = delegate; | 15 this._delegate = delegate; |
| 16 this._target = target; | 16 this._target = target; |
| 17 this._tracingModel = tracingModel; | 17 this._tracingModel = tracingModel; |
| 18 this._targets = []; | 18 this._targets = []; |
| 19 this._allProfilesStoppedPromise = Promise.resolve(); | |
| 20 this._targetsResumedPromise = Promise.resolve(); | |
| 21 WebInspector.targetManager.observeTargets(this); | 19 WebInspector.targetManager.observeTargets(this); |
| 22 } | 20 } |
| 23 | 21 |
| 24 WebInspector.TimelineController.prototype = { | 22 WebInspector.TimelineController.prototype = { |
| 25 /** | 23 /** |
| 26 * @param {boolean} captureCauses | 24 * @param {boolean} captureCauses |
| 27 * @param {boolean} enableJSSampling | 25 * @param {boolean} enableJSSampling |
| 28 * @param {boolean} captureMemory | 26 * @param {boolean} captureMemory |
| 29 * @param {boolean} capturePictures | 27 * @param {boolean} capturePictures |
| 30 * @param {boolean} captureFilmStrip | 28 * @param {boolean} captureFilmStrip |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 66 } | 64 } |
| 67 if (captureFilmStrip) | 65 if (captureFilmStrip) |
| 68 categoriesArray.push(disabledByDefault("devtools.screenshot")); | 66 categoriesArray.push(disabledByDefault("devtools.screenshot")); |
| 69 | 67 |
| 70 var categories = categoriesArray.join(","); | 68 var categories = categoriesArray.join(","); |
| 71 this._startRecordingWithCategories(categories, enableJSSampling); | 69 this._startRecordingWithCategories(categories, enableJSSampling); |
| 72 }, | 70 }, |
| 73 | 71 |
| 74 stopRecording: function() | 72 stopRecording: function() |
| 75 { | 73 { |
| 76 this._allProfilesStoppedPromise = this._stopProfilingOnAllTargets(); | 74 var tracingStoppedPromises = []; |
| 75 tracingStoppedPromises.push(new Promise(resolve => this._resolveTracingS toppedPromise = resolve)); | |
| 76 tracingStoppedPromises.push.apply(tracingStoppedPromises, this._stopProf ilingOnAllTargets()); | |
| 77 | |
| 78 Promise.all(tracingStoppedPromises).then(() => this._allSourcesFinished( )); | |
| 77 this._target.tracingManager.stop(); | 79 this._target.tracingManager.stop(); |
| 78 this._targetsResumedPromise = WebInspector.targetManager.resumeAllTarget s(); | 80 WebInspector.targetManager.resumeAllTargets(); |
|
alph
2016/07/11 22:21:01
I think we still need this to have all targets res
| |
| 79 this._delegate.loadingStarted(); | 81 this._delegate.loadingStarted(); |
| 80 }, | 82 }, |
| 81 | 83 |
| 82 /** | 84 /** |
| 83 * @override | 85 * @override |
| 84 * @param {!WebInspector.Target} target | 86 * @param {!WebInspector.Target} target |
| 85 */ | 87 */ |
| 86 targetAdded: function(target) | 88 targetAdded: function(target) |
| 87 { | 89 { |
| 88 this._targets.push(target); | 90 this._targets.push(target); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 140 if (!cpuProfile) { | 142 if (!cpuProfile) { |
| 141 WebInspector.console.warn(WebInspector.UIString("CPU profile for a t arget is not available. %s", error || "")); | 143 WebInspector.console.warn(WebInspector.UIString("CPU profile for a t arget is not available. %s", error || "")); |
| 142 return; | 144 return; |
| 143 } | 145 } |
| 144 if (!this._cpuProfiles) | 146 if (!this._cpuProfiles) |
| 145 this._cpuProfiles = new Map(); | 147 this._cpuProfiles = new Map(); |
| 146 this._cpuProfiles.set(targetId, cpuProfile); | 148 this._cpuProfiles.set(targetId, cpuProfile); |
| 147 }, | 149 }, |
| 148 | 150 |
| 149 /** | 151 /** |
| 150 * @return {!Promise} | 152 * @return {!Array<!Promise>} |
| 151 */ | 153 */ |
| 152 _stopProfilingOnAllTargets: function() | 154 _stopProfilingOnAllTargets: function() |
| 153 { | 155 { |
| 154 var targets = this._profiling ? this._targets : []; | 156 var targets = this._profiling ? this._targets : []; |
| 155 this._profiling = false; | 157 this._profiling = false; |
| 156 return Promise.all(targets.map(this._stopProfilingOnTarget, this)); | 158 return targets.map(this._stopProfilingOnTarget, this); |
|
alph
2016/07/11 22:21:01
could you please revert it.
| |
| 157 }, | 159 }, |
| 158 | 160 |
| 159 /** | 161 /** |
| 160 * @param {string} categories | 162 * @param {string} categories |
| 161 * @param {boolean=} enableJSSampling | 163 * @param {boolean=} enableJSSampling |
| 162 * @param {function(?string)=} callback | 164 * @param {function(?string)=} callback |
| 163 */ | 165 */ |
| 164 _startRecordingWithCategories: function(categories, enableJSSampling, callba ck) | 166 _startRecordingWithCategories: function(categories, enableJSSampling, callba ck) |
| 165 { | 167 { |
| 166 WebInspector.targetManager.suspendAllTargets(); | 168 WebInspector.targetManager.suspendAllTargets(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 199 traceEventsCollected: function(events) | 201 traceEventsCollected: function(events) |
| 200 { | 202 { |
| 201 this._tracingModel.addEvents(events); | 203 this._tracingModel.addEvents(events); |
| 202 }, | 204 }, |
| 203 | 205 |
| 204 /** | 206 /** |
| 205 * @override | 207 * @override |
| 206 */ | 208 */ |
| 207 tracingComplete: function() | 209 tracingComplete: function() |
| 208 { | 210 { |
| 209 Promise.all([this._allProfilesStoppedPromise, this._targetsResumedPromis e]) | 211 this._resolveTracingStoppedPromise(); |
|
alph
2016/07/11 22:21:01
The name is misleading. This is not a promise.
| |
| 210 .then(this._didStopRecordingTraceEvents.bind(this)); | 212 this._resolveTracingStoppedPromise = null; |
| 211 }, | 213 }, |
| 212 | 214 |
| 213 _didStopRecordingTraceEvents: function() | 215 _allSourcesFinished: function() |
| 214 { | 216 { |
| 215 this._injectCpuProfileEvents(); | 217 this._injectCpuProfileEvents(); |
| 216 this._tracingModel.tracingComplete(); | 218 this._tracingModel.tracingComplete(); |
| 217 this._delegate.loadingComplete(true); | 219 this._delegate.loadingComplete(true); |
| 218 }, | 220 }, |
| 219 | 221 |
| 220 /** | 222 /** |
| 221 * @param {number} pid | 223 * @param {number} pid |
| 222 * @param {number} tid | 224 * @param {number} tid |
| 223 * @param {?ProfilerAgent.CPUProfile} cpuProfile | 225 * @param {?ProfilerAgent.CPUProfile} cpuProfile |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 276 | 278 |
| 277 /** | 279 /** |
| 278 * @param {number} progress | 280 * @param {number} progress |
| 279 * @override | 281 * @override |
| 280 */ | 282 */ |
| 281 eventsRetrievalProgress: function(progress) | 283 eventsRetrievalProgress: function(progress) |
| 282 { | 284 { |
| 283 this._delegate.loadingProgress(progress); | 285 this._delegate.loadingProgress(progress); |
| 284 } | 286 } |
| 285 } | 287 } |
| OLD | NEW |