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 * @implements {SDK.TargetManager.Observer} | 6 * @implements {SDK.TargetManager.Observer} |
| 7 * @implements {SDK.TracingManagerClient} | 7 * @implements {SDK.TracingManagerClient} |
| 8 * @unrestricted | 8 * @unrestricted |
| 9 */ | 9 */ |
| 10 Timeline.TimelineController = class { | 10 Timeline.TimelineController = class { |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 26 /** @type {!Array<!SDK.Target>} */ | 26 /** @type {!Array<!SDK.Target>} */ |
| 27 this._targets = []; | 27 this._targets = []; |
| 28 /** @type {!Array<!Timeline.ExtensionTracingSession>} */ | 28 /** @type {!Array<!Timeline.ExtensionTracingSession>} */ |
| 29 this._extensionSessions = []; | 29 this._extensionSessions = []; |
| 30 SDK.targetManager.observeTargets(this); | 30 SDK.targetManager.observeTargets(this); |
| 31 } | 31 } |
| 32 | 32 |
| 33 /** | 33 /** |
| 34 * @param {!Timeline.TimelineController.RecordingOptions} options | 34 * @param {!Timeline.TimelineController.RecordingOptions} options |
| 35 * @param {!Array<!Extensions.ExtensionTraceProvider>} providers | 35 * @param {!Array<!Extensions.ExtensionTraceProvider>} providers |
| 36 * @return {!Promise} | |
| 36 */ | 37 */ |
| 37 startRecording(options, providers) { | 38 startRecording(options, providers) { |
| 38 this._extensionTraceProviders = Extensions.extensionServer.traceProviders(). slice(); | 39 this._extensionTraceProviders = Extensions.extensionServer.traceProviders(). slice(); |
| 39 | 40 |
| 40 /** | 41 /** |
| 41 * @param {string} category | 42 * @param {string} category |
| 42 * @return {string} | 43 * @return {string} |
| 43 */ | 44 */ |
| 44 function disabledByDefault(category) { | 45 function disabledByDefault(category) { |
| 45 return 'disabled-by-default-' + category; | 46 return 'disabled-by-default-' + category; |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 65 categoriesArray.push( | 66 categoriesArray.push( |
| 66 disabledByDefault('devtools.timeline.layers'), disabledByDefault('devt ools.timeline.picture'), | 67 disabledByDefault('devtools.timeline.layers'), disabledByDefault('devt ools.timeline.picture'), |
| 67 disabledByDefault('blink.graphics_context_annotations')); | 68 disabledByDefault('blink.graphics_context_annotations')); |
| 68 } | 69 } |
| 69 if (options.captureFilmStrip) | 70 if (options.captureFilmStrip) |
| 70 categoriesArray.push(disabledByDefault('devtools.screenshot')); | 71 categoriesArray.push(disabledByDefault('devtools.screenshot')); |
| 71 | 72 |
| 72 this._extensionSessions = | 73 this._extensionSessions = |
| 73 providers.map(provider => new Timeline.ExtensionTracingSession(provider, this._performanceModel)); | 74 providers.map(provider => new Timeline.ExtensionTracingSession(provider, this._performanceModel)); |
| 74 this._extensionSessions.forEach(session => session.start()); | 75 this._extensionSessions.forEach(session => session.start()); |
| 75 this._startRecordingWithCategories(categoriesArray.join(','), options.enable JSSampling); | 76 var startPromise = this._startRecordingWithCategories(categoriesArray.join(' ,'), options.enableJSSampling); |
| 76 this._performanceModel.setRecordStartTime(Date.now()); | 77 this._performanceModel.setRecordStartTime(Date.now()); |
| 78 return startPromise; | |
| 77 } | 79 } |
| 78 | 80 |
| 79 stopRecording() { | 81 stopRecording() { |
| 80 var tracingStoppedPromises = []; | 82 var tracingStoppedPromises = []; |
| 81 tracingStoppedPromises.push(new Promise(resolve => this._tracingCompleteCall back = resolve)); | 83 tracingStoppedPromises.push(new Promise(resolve => this._tracingCompleteCall back = resolve)); |
| 82 tracingStoppedPromises.push(this._stopProfilingOnAllTargets()); | 84 tracingStoppedPromises.push(this._stopProfilingOnAllTargets()); |
| 83 this._target.tracingManager.stop(); | 85 this._target.tracingManager.stop(); |
| 84 tracingStoppedPromises.push(SDK.targetManager.resumeAllTargets()); | 86 tracingStoppedPromises.push(SDK.targetManager.resumeAllTargets()); |
| 85 | 87 |
| 86 this._client.loadingStarted(); | 88 this._client.loadingStarted(); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 162 */ | 164 */ |
| 163 _stopProfilingOnAllTargets() { | 165 _stopProfilingOnAllTargets() { |
| 164 var targets = this._profiling ? this._targets : []; | 166 var targets = this._profiling ? this._targets : []; |
| 165 this._profiling = false; | 167 this._profiling = false; |
| 166 return Promise.all(targets.map(this._stopProfilingOnTarget, this)); | 168 return Promise.all(targets.map(this._stopProfilingOnTarget, this)); |
| 167 } | 169 } |
| 168 | 170 |
| 169 /** | 171 /** |
| 170 * @param {string} categories | 172 * @param {string} categories |
| 171 * @param {boolean=} enableJSSampling | 173 * @param {boolean=} enableJSSampling |
| 172 * @param {function(?string)=} callback | 174 * @return {!Promise} |
| 173 */ | 175 */ |
| 174 _startRecordingWithCategories(categories, enableJSSampling, callback) { | 176 _startRecordingWithCategories(categories, enableJSSampling) { |
| 175 SDK.targetManager.suspendAllTargets(); | 177 SDK.targetManager.suspendAllTargets(); |
| 176 var profilingStartedPromise = enableJSSampling && !Runtime.experiments.isEna bled('timelineTracingJSProfile') ? | 178 var profilingStartedPromise = enableJSSampling && !Runtime.experiments.isEna bled('timelineTracingJSProfile') ? |
| 177 this._startProfilingOnAllTargets() : | 179 this._startProfilingOnAllTargets() : |
| 178 Promise.resolve(); | 180 Promise.resolve(); |
| 179 var samplingFrequencyHz = Common.moduleSetting('highResolutionCpuProfiling') .get() ? 10000 : 1000; | 181 var samplingFrequencyHz = Common.moduleSetting('highResolutionCpuProfiling') .get() ? 10000 : 1000; |
| 180 var options = 'sampling-frequency=' + samplingFrequencyHz; | 182 var options = 'sampling-frequency=' + samplingFrequencyHz; |
| 181 var target = this._target; | 183 var tracingManager = this._target.tracingManager; |
| 182 var tracingManager = target.tracingManager; | 184 return profilingStartedPromise.then(() => tracingManager.start(this, categor ies, options)); |
|
alph
2017/02/28 03:11:24
nit: await
| |
| 183 SDK.targetManager.suspendReload(target); | |
| 184 profilingStartedPromise.then(tracingManager.start.bind(tracingManager, this, categories, options, onTraceStarted)); | |
| 185 /** | |
| 186 * @param {?string} error | |
| 187 */ | |
| 188 function onTraceStarted(error) { | |
| 189 SDK.targetManager.resumeReload(target); | |
| 190 if (callback) | |
| 191 callback(error); | |
| 192 } | |
| 193 } | 185 } |
| 194 | 186 |
| 195 /** | 187 /** |
| 196 * @override | |
| 197 */ | |
| 198 tracingStarted() { | |
| 199 this._client.recordingStarted(); | |
| 200 } | |
| 201 | |
| 202 /** | |
| 203 * @param {!Array.<!SDK.TracingManager.EventPayload>} events | 188 * @param {!Array.<!SDK.TracingManager.EventPayload>} events |
| 204 * @override | 189 * @override |
| 205 */ | 190 */ |
| 206 traceEventsCollected(events) { | 191 traceEventsCollected(events) { |
| 207 this._tracingModel.addEvents(events); | 192 this._tracingModel.addEvents(events); |
| 208 } | 193 } |
| 209 | 194 |
| 210 /** | 195 /** |
| 211 * @override | 196 * @override |
| 212 */ | 197 */ |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 291 } | 276 } |
| 292 }; | 277 }; |
| 293 | 278 |
| 294 /** | 279 /** |
| 295 * @interface | 280 * @interface |
| 296 * @extends {Timeline.TimelineLoader.Client} | 281 * @extends {Timeline.TimelineLoader.Client} |
| 297 */ | 282 */ |
| 298 Timeline.TimelineController.Client = function() {}; | 283 Timeline.TimelineController.Client = function() {}; |
| 299 | 284 |
| 300 Timeline.TimelineController.Client.prototype = { | 285 Timeline.TimelineController.Client.prototype = { |
| 301 recordingStarted() {}, | |
| 302 | |
| 303 /** | 286 /** |
| 304 * @param {number} usage | 287 * @param {number} usage |
| 305 */ | 288 */ |
| 306 recordingProgress(usage) {}, | 289 recordingProgress(usage) {}, |
| 307 }; | 290 }; |
| 308 | 291 |
| 309 /** | 292 /** |
| 310 * @typedef {!{ | 293 * @typedef {!{ |
| 311 * enableJSSampling: (boolean|undefined), | 294 * enableJSSampling: (boolean|undefined), |
| 312 * capturePictures: (boolean|undefined), | 295 * capturePictures: (boolean|undefined), |
| 313 * captureFilmStrip: (boolean|undefined) | 296 * captureFilmStrip: (boolean|undefined) |
| 314 * }} | 297 * }} |
| 315 */ | 298 */ |
| 316 Timeline.TimelineController.RecordingOptions; | 299 Timeline.TimelineController.RecordingOptions; |
| OLD | NEW |