Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/timeline/TimelineController.js

Issue 2137213004: Timeline: rearrange trace completion logic for better extensibility (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments addressed Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/tracing/trace-event-self-time.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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._tracingComplete Callback = resolve));
76 tracingStoppedPromises.push(this._stopProfilingOnAllTargets());
77 this._target.tracingManager.stop(); 77 this._target.tracingManager.stop();
78 this._targetsResumedPromise = WebInspector.targetManager.resumeAllTarget s(); 78 tracingStoppedPromises.push(WebInspector.targetManager.resumeAllTargets( ));
79 Promise.all(tracingStoppedPromises).then(() => this._allSourcesFinished( ));
80
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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
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._tracingCompleteCallback();
210 .then(this._didStopRecordingTraceEvents.bind(this)); 212 this._tracingCompleteCallback = 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
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 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/inspector/tracing/trace-event-self-time.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698