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(); | 19 this._allProfilesStoppedPromise = Promise.resolve(); |
20 this._targetsResumedPromise = Promise.resolve(); | 20 this._targetsResumedPromise = Promise.resolve(); |
21 this._extensionTraceProviders = WebInspector.extensionServer.traceProviders( ); | |
21 WebInspector.targetManager.observeTargets(this); | 22 WebInspector.targetManager.observeTargets(this); |
22 } | 23 } |
23 | 24 |
24 WebInspector.TimelineController.prototype = { | 25 WebInspector.TimelineController.prototype = { |
25 /** | 26 /** |
26 * @param {boolean} captureCauses | 27 * @param {boolean} captureCauses |
27 * @param {boolean} enableJSSampling | 28 * @param {boolean} enableJSSampling |
28 * @param {boolean} captureMemory | 29 * @param {boolean} captureMemory |
29 * @param {boolean} capturePictures | 30 * @param {boolean} capturePictures |
30 * @param {boolean} captureFilmStrip | 31 * @param {boolean} captureFilmStrip |
(...skipping 29 matching lines...) Expand all Loading... | |
60 if (captureCauses && Runtime.experiments.isEnabled("timelineInvalidation Tracking")) | 61 if (captureCauses && Runtime.experiments.isEnabled("timelineInvalidation Tracking")) |
61 categoriesArray.push(disabledByDefault("devtools.timeline.invalidati onTracking")); | 62 categoriesArray.push(disabledByDefault("devtools.timeline.invalidati onTracking")); |
62 if (capturePictures) { | 63 if (capturePictures) { |
63 categoriesArray.push(disabledByDefault("devtools.timeline.layers"), | 64 categoriesArray.push(disabledByDefault("devtools.timeline.layers"), |
64 disabledByDefault("devtools.timeline.picture"), | 65 disabledByDefault("devtools.timeline.picture"), |
65 disabledByDefault("blink.graphics_context_annot ations")); | 66 disabledByDefault("blink.graphics_context_annot ations")); |
66 } | 67 } |
67 if (captureFilmStrip) | 68 if (captureFilmStrip) |
68 categoriesArray.push(disabledByDefault("devtools.screenshot")); | 69 categoriesArray.push(disabledByDefault("devtools.screenshot")); |
69 | 70 |
71 for (var traceProvider of this._extensionTraceProviders) { | |
72 traceProvider.run(); | |
73 } | |
74 | |
70 var categories = categoriesArray.join(","); | 75 var categories = categoriesArray.join(","); |
71 this._startRecordingWithCategories(categories, enableJSSampling); | 76 this._startRecordingWithCategories(categories, enableJSSampling); |
72 }, | 77 }, |
73 | 78 |
74 stopRecording: function() | 79 stopRecording: function() |
75 { | 80 { |
76 this._allProfilesStoppedPromise = this._stopProfilingOnAllTargets(); | 81 this._allProfilesStoppedPromise = this._stopProfilingOnAllTargets(); |
77 this._target.tracingManager.stop(); | 82 this._target.tracingManager.stop(); |
78 this._targetsResumedPromise = WebInspector.targetManager.resumeAllTarget s(); | 83 this._targetsResumedPromise = WebInspector.targetManager.resumeAllTarget s(); |
79 this._delegate.loadingStarted(); | 84 this._delegate.loadingStarted(); |
85 | |
86 var target = WebInspector.targetManager.mainTarget(); | |
87 var requests = target.networkLog.requests().slice(); | |
88 for (var traceProvider of this._extensionTraceProviders) { | |
89 traceProvider.stop(requests); | |
90 } | |
80 }, | 91 }, |
81 | 92 |
82 /** | 93 /** |
83 * @override | 94 * @override |
84 * @param {!WebInspector.Target} target | 95 * @param {!WebInspector.Target} target |
85 */ | 96 */ |
86 targetAdded: function(target) | 97 targetAdded: function(target) |
87 { | 98 { |
88 this._targets.push(target); | 99 this._targets.push(target); |
89 if (this._profiling) | 100 if (this._profiling) |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
182 callback(error); | 193 callback(error); |
183 } | 194 } |
184 }, | 195 }, |
185 | 196 |
186 /** | 197 /** |
187 * @override | 198 * @override |
188 */ | 199 */ |
189 tracingStarted: function() | 200 tracingStarted: function() |
190 { | 201 { |
191 this._tracingModel.reset(); | 202 this._tracingModel.reset(); |
203 for (var provider of this._extensionTraceProviders) { | |
204 provider.tracingModel.reset(); | |
205 } | |
192 this._delegate.recordingStarted(); | 206 this._delegate.recordingStarted(); |
193 }, | 207 }, |
194 | 208 |
195 /** | 209 /** |
196 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events | 210 * @param {!Array.<!WebInspector.TracingManager.EventPayload>} events |
197 * @override | 211 * @override |
198 */ | 212 */ |
199 traceEventsCollected: function(events) | 213 traceEventsCollected: function(events) |
200 { | 214 { |
201 this._tracingModel.addEvents(events); | 215 this._tracingModel.addEvents(events); |
202 }, | 216 }, |
203 | 217 |
204 /** | 218 /** |
205 * @override | 219 * @override |
206 */ | 220 */ |
207 tracingComplete: function() | 221 tracingComplete: function() |
208 { | 222 { |
209 Promise.all([this._allProfilesStoppedPromise, this._targetsResumedPromis e]) | 223 Promise.all([this._allProfilesStoppedPromise, this._targetsResumedPromis e]) |
210 .then(this._didStopRecordingTraceEvents.bind(this)); | 224 .then(this._didStopRecordingTraceEvents.bind(this)); |
211 }, | 225 }, |
212 | 226 |
213 _didStopRecordingTraceEvents: function() | 227 _didStopRecordingTraceEvents: function() |
214 { | 228 { |
215 this._injectCpuProfileEvents(); | 229 this._injectCpuProfileEvents(); |
216 this._tracingModel.tracingComplete(); | 230 this._tracingModel.tracingComplete(); |
217 this._delegate.loadingComplete(true); | 231 |
232 var count = 0; | |
233 var total = this._extensionTraceProviders.length; | |
234 var traceProviders = this._extensionTraceProviders; | |
235 var this_ = this; | |
236 var p = new Promise(function(resolve, reject) { | |
caseq
2016/07/11 18:58:38
Let's piggy-back on the existent allProfilesStoppp
| |
237 for (var traceProvider of traceProviders) { | |
238 var traceData = traceProvider.traceData; | |
239 function appendEventsComplete() { | |
240 if (traceData.events === null) { | |
241 setTimeout(appendEventsComplete, 1000); | |
242 } else { | |
243 traceProvider.tracingModel.addEvents(traceData.events); | |
244 traceProvider.tracingModel.tracingComplete(); | |
245 count++; | |
246 } | |
247 } | |
248 appendEventsComplete(); | |
249 } | |
250 function waitUntil(callback) { | |
251 setTimeout(function() { | |
252 count == total ? callback(): waitUntil(callback);}, 1000); | |
253 } | |
254 waitUntil(function() { | |
255 resolve(); | |
256 }); | |
257 }); | |
258 p.then(function() { | |
259 this_._delegate.loadingComplete(true); | |
260 }); | |
218 }, | 261 }, |
219 | 262 |
220 /** | 263 /** |
221 * @param {number} pid | 264 * @param {number} pid |
222 * @param {number} tid | 265 * @param {number} tid |
223 * @param {?ProfilerAgent.CPUProfile} cpuProfile | 266 * @param {?ProfilerAgent.CPUProfile} cpuProfile |
224 */ | 267 */ |
225 _injectCpuProfileEvent: function(pid, tid, cpuProfile) | 268 _injectCpuProfileEvent: function(pid, tid, cpuProfile) |
226 { | 269 { |
227 if (!cpuProfile) | 270 if (!cpuProfile) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
276 | 319 |
277 /** | 320 /** |
278 * @param {number} progress | 321 * @param {number} progress |
279 * @override | 322 * @override |
280 */ | 323 */ |
281 eventsRetrievalProgress: function(progress) | 324 eventsRetrievalProgress: function(progress) |
282 { | 325 { |
283 this._delegate.loadingProgress(progress); | 326 this._delegate.loadingProgress(progress); |
284 } | 327 } |
285 } | 328 } |
OLD | NEW |