| 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 WebInspector.targetManager.observeTargets(this); | 19 WebInspector.targetManager.observeTargets(this); |
| 20 } | 20 } |
| 21 | 21 |
| 22 WebInspector.TimelineController.prototype = { | 22 WebInspector.TimelineController.prototype = { |
| 23 /** | 23 /** |
| 24 * @param {boolean} captureCauses | 24 * @param {boolean} captureCauses |
| 25 * @param {boolean} enableJSSampling | 25 * @param {boolean} enableJSSampling |
| 26 * @param {boolean} captureMemory | 26 * @param {boolean} captureMemory |
| 27 * @param {boolean} capturePictures | 27 * @param {boolean} capturePictures |
| 28 * @param {boolean} captureFilmStrip | 28 * @param {boolean} captureFilmStrip |
| 29 * @param {string=} reloadingBanner |
| 29 */ | 30 */ |
| 30 startRecording: function(captureCauses, enableJSSampling, captureMemory, cap
turePictures, captureFilmStrip) | 31 startRecording: function(captureCauses, enableJSSampling, captureMemory, cap
turePictures, captureFilmStrip, reloadingBanner) |
| 31 { | 32 { |
| 32 function disabledByDefault(category) | 33 function disabledByDefault(category) |
| 33 { | 34 { |
| 34 return "disabled-by-default-" + category; | 35 return "disabled-by-default-" + category; |
| 35 } | 36 } |
| 36 var categoriesArray = [ | 37 var categoriesArray = [ |
| 37 "-*", | 38 "-*", |
| 38 "devtools.timeline", | 39 "devtools.timeline", |
| 39 disabledByDefault("devtools.timeline"), | 40 disabledByDefault("devtools.timeline"), |
| 40 disabledByDefault("devtools.timeline.frame"), | 41 disabledByDefault("devtools.timeline.frame"), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 59 categoriesArray.push(disabledByDefault("devtools.timeline.invalidati
onTracking")); | 60 categoriesArray.push(disabledByDefault("devtools.timeline.invalidati
onTracking")); |
| 60 if (capturePictures) { | 61 if (capturePictures) { |
| 61 categoriesArray.push(disabledByDefault("devtools.timeline.layers"), | 62 categoriesArray.push(disabledByDefault("devtools.timeline.layers"), |
| 62 disabledByDefault("devtools.timeline.picture"), | 63 disabledByDefault("devtools.timeline.picture"), |
| 63 disabledByDefault("blink.graphics_context_annot
ations")); | 64 disabledByDefault("blink.graphics_context_annot
ations")); |
| 64 } | 65 } |
| 65 if (captureFilmStrip) | 66 if (captureFilmStrip) |
| 66 categoriesArray.push(disabledByDefault("devtools.screenshot")); | 67 categoriesArray.push(disabledByDefault("devtools.screenshot")); |
| 67 | 68 |
| 68 var categories = categoriesArray.join(","); | 69 var categories = categoriesArray.join(","); |
| 69 this._startRecordingWithCategories(categories, enableJSSampling); | 70 this._startRecordingWithCategories(categories, enableJSSampling, reloadi
ngBanner); |
| 70 }, | 71 }, |
| 71 | 72 |
| 72 stopRecording: function() | 73 stopRecording: function() |
| 73 { | 74 { |
| 74 var tracingStoppedPromises = []; | 75 var tracingStoppedPromises = []; |
| 75 tracingStoppedPromises.push(new Promise(resolve => this._tracingComplete
Callback = resolve)); | 76 tracingStoppedPromises.push(new Promise(resolve => this._tracingComplete
Callback = resolve)); |
| 76 tracingStoppedPromises.push(this._stopProfilingOnAllTargets()); | 77 tracingStoppedPromises.push(this._stopProfilingOnAllTargets()); |
| 77 this._target.tracingManager.stop(); | 78 this._target.tracingManager.stop(); |
| 78 tracingStoppedPromises.push(WebInspector.targetManager.resumeAllTargets(
)); | 79 tracingStoppedPromises.push(WebInspector.targetManager.resumeAllTargets(
)); |
| 79 Promise.all(tracingStoppedPromises).then(() => this._allSourcesFinished(
)); | 80 Promise.all(tracingStoppedPromises).then(() => this._allSourcesFinished(
)); |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 _stopProfilingOnAllTargets: function() | 155 _stopProfilingOnAllTargets: function() |
| 155 { | 156 { |
| 156 var targets = this._profiling ? this._targets : []; | 157 var targets = this._profiling ? this._targets : []; |
| 157 this._profiling = false; | 158 this._profiling = false; |
| 158 return Promise.all(targets.map(this._stopProfilingOnTarget, this)); | 159 return Promise.all(targets.map(this._stopProfilingOnTarget, this)); |
| 159 }, | 160 }, |
| 160 | 161 |
| 161 /** | 162 /** |
| 162 * @param {string} categories | 163 * @param {string} categories |
| 163 * @param {boolean=} enableJSSampling | 164 * @param {boolean=} enableJSSampling |
| 165 * @param {string=} reloadingBanner |
| 164 * @param {function(?string)=} callback | 166 * @param {function(?string)=} callback |
| 165 */ | 167 */ |
| 166 _startRecordingWithCategories: function(categories, enableJSSampling, callba
ck) | 168 _startRecordingWithCategories: function(categories, enableJSSampling, reload
ingBanner, callback) |
| 167 { | 169 { |
| 168 WebInspector.targetManager.suspendAllTargets(); | 170 WebInspector.targetManager.suspendAllTargets(); |
| 169 var profilingStartedPromise = enableJSSampling && !Runtime.experiments.i
sEnabled("timelineTracingJSProfile") ? | 171 var profilingStartedPromise = enableJSSampling && !Runtime.experiments.i
sEnabled("timelineTracingJSProfile") ? |
| 170 this._startProfilingOnAllTargets() : Promise.resolve(); | 172 this._startProfilingOnAllTargets() : Promise.resolve(); |
| 171 var samplingFrequencyHz = WebInspector.moduleSetting("highResolutionCpuP
rofiling").get() ? 10000 : 1000; | 173 var samplingFrequencyHz = WebInspector.moduleSetting("highResolutionCpuP
rofiling").get() ? 10000 : 1000; |
| 172 var options = "sampling-frequency=" + samplingFrequencyHz; | 174 var options = "sampling-frequency=" + samplingFrequencyHz; |
| 173 var target = this._target; | 175 var target = this._target; |
| 174 var tracingManager = target.tracingManager; | 176 var tracingManager = target.tracingManager; |
| 175 target.resourceTreeModel.suspendReload(); | 177 target.resourceTreeModel.suspendReload(); |
| 176 profilingStartedPromise.then(tracingManager.start.bind(tracingManager, t
his, categories, options, onTraceStarted)); | 178 profilingStartedPromise.then(tracingManager.start.bind(tracingManager, t
his, categories, options, reloadingBanner, onTraceStarted)); |
| 177 /** | 179 /** |
| 178 * @param {?string} error | 180 * @param {?string} error |
| 179 */ | 181 */ |
| 180 function onTraceStarted(error) | 182 function onTraceStarted(error) |
| 181 { | 183 { |
| 182 target.resourceTreeModel.resumeReload(); | 184 target.resourceTreeModel.resumeReload(); |
| 183 if (callback) | 185 if (callback) |
| 184 callback(error); | 186 callback(error); |
| 185 } | 187 } |
| 186 }, | 188 }, |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 280 |
| 279 /** | 281 /** |
| 280 * @param {number} progress | 282 * @param {number} progress |
| 281 * @override | 283 * @override |
| 282 */ | 284 */ |
| 283 eventsRetrievalProgress: function(progress) | 285 eventsRetrievalProgress: function(progress) |
| 284 { | 286 { |
| 285 this._delegate.loadingProgress(progress); | 287 this._delegate.loadingProgress(progress); |
| 286 } | 288 } |
| 287 } | 289 } |
| OLD | NEW |