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

Side by Side Diff: Source/devtools/front_end/sdk/TimelineManager.js

Issue 399043002: DevTools: switch Timeline frontend into buffered mode and remove the corresponding experiment. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: timeline-websocket-event rebaselined Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 28 matching lines...) Expand all
39 this._dispatcher = new WebInspector.TimelineDispatcher(this); 39 this._dispatcher = new WebInspector.TimelineDispatcher(this);
40 this._enablementCount = 0; 40 this._enablementCount = 0;
41 this._jsProfilerStarted = false; 41 this._jsProfilerStarted = false;
42 target.timelineAgent().enable(); 42 target.timelineAgent().enable();
43 } 43 }
44 44
45 WebInspector.TimelineManager.EventTypes = { 45 WebInspector.TimelineManager.EventTypes = {
46 TimelineStarted: "TimelineStarted", 46 TimelineStarted: "TimelineStarted",
47 TimelineStopped: "TimelineStopped", 47 TimelineStopped: "TimelineStopped",
48 TimelineEventRecorded: "TimelineEventRecorded", 48 TimelineEventRecorded: "TimelineEventRecorded",
49 TimelineAllEventsReceived: "TimelineAllEventsReceived",
49 TimelineProgress: "TimelineProgress" 50 TimelineProgress: "TimelineProgress"
50 } 51 }
51 52
52 WebInspector.TimelineManager.prototype = { 53 WebInspector.TimelineManager.prototype = {
53 /** 54 /**
54 * @return {boolean} 55 * @return {boolean}
55 */ 56 */
56 isStarted: function() 57 isStarted: function()
57 { 58 {
58 return this._dispatcher.isStarted(); 59 return this._dispatcher.isStarted();
59 }, 60 },
60 61
61 /** 62 /**
62 * @param {number=} maxCallStackDepth 63 * @param {number=} maxCallStackDepth
63 * @param {boolean=} bufferEvents
64 * @param {string=} liveEvents 64 * @param {string=} liveEvents
65 * @param {boolean=} includeCounters 65 * @param {boolean=} includeCounters
66 * @param {boolean=} includeGPUEvents 66 * @param {boolean=} includeGPUEvents
67 * @param {function(?Protocol.Error)=} callback 67 * @param {function(?Protocol.Error)=} callback
68 */ 68 */
69 start: function(maxCallStackDepth, bufferEvents, liveEvents, includeCounters , includeGPUEvents, callback) 69 start: function(maxCallStackDepth, liveEvents, includeCounters, includeGPUEv ents, callback)
70 { 70 {
71 this._enablementCount++; 71 this._enablementCount++;
72 this.target().profilingLock.acquire(); 72 this.target().profilingLock.acquire();
73 if (WebInspector.experimentsSettings.timelineJSCPUProfile.isEnabled() && maxCallStackDepth) { 73 if (WebInspector.experimentsSettings.timelineJSCPUProfile.isEnabled() && maxCallStackDepth) {
74 this._configureCpuProfilerSamplingInterval(); 74 this._configureCpuProfilerSamplingInterval();
75 this._jsProfilerStarted = true; 75 this._jsProfilerStarted = true;
76 this.target().profilerAgent().start(); 76 this.target().profilerAgent().start();
77 } 77 }
78 if (this._enablementCount === 1) 78 if (this._enablementCount === 1)
79 this.target().timelineAgent().start(maxCallStackDepth, bufferEvents, liveEvents, includeCounters, includeGPUEvents, callback); 79 this.target().timelineAgent().start(maxCallStackDepth, true, liveEve nts, includeCounters, includeGPUEvents, callback);
80 else if (callback) 80 else if (callback)
81 callback(null); 81 callback(null);
82 }, 82 },
83 83
84 /** 84 /**
85 * @param {function(?Protocol.Error,?ProfilerAgent.CPUProfile)} callback 85 * @param {function(?Protocol.Error,?ProfilerAgent.CPUProfile)} callback
86 */ 86 */
87 stop: function(callback) 87 stop: function(callback)
88 { 88 {
89 this._enablementCount--; 89 this._enablementCount--;
90 if (this._enablementCount < 0) { 90 if (this._enablementCount < 0) {
91 console.error("WebInspector.TimelineManager start/stop calls are unb alanced " + new Error().stack); 91 console.error("WebInspector.TimelineManager start/stop calls are unb alanced " + new Error().stack);
92 return; 92 return;
93 } 93 }
94 94
95 var masterError = null; 95 var masterError = null;
96 var masterProfile = null; 96 var masterProfile = null;
97 var callbackBarrier = new CallbackBarrier(); 97 var callbackBarrier = new CallbackBarrier();
98 98
99 if (this._jsProfilerStarted) { 99 if (this._jsProfilerStarted) {
100 this.target().profilerAgent().stop(callbackBarrier.createCallback(pr ofilerCallback)); 100 this.target().profilerAgent().stop(callbackBarrier.createCallback(pr ofilerCallback));
101 this._jsProfilerStarted = false; 101 this._jsProfilerStarted = false;
102 } 102 }
103 if (!this._enablementCount) 103 if (!this._enablementCount)
104 this.target().timelineAgent().stop(callbackBarrier.createCallback(ti melineCallback)); 104 this.target().timelineAgent().stop(callbackBarrier.createCallback(ti melineCallback));
105 TimelineAgent.stop(callbackBarrier.createCallback(timelineCallback)) ;
106 105
107 callbackBarrier.callWhenDone(allDoneCallback.bind(this)); 106 callbackBarrier.callWhenDone(allDoneCallback.bind(this));
108 107
109 /** 108 /**
110 * @param {?Protocol.Error} error 109 * @param {?Protocol.Error} error
111 */ 110 */
112 function timelineCallback(error) 111 function timelineCallback(error)
113 { 112 {
114 masterError = masterError || error; 113 masterError = masterError || error;
115 } 114 }
(...skipping 12 matching lines...) Expand all
128 * @this {WebInspector.TimelineManager} 127 * @this {WebInspector.TimelineManager}
129 */ 128 */
130 function allDoneCallback() 129 function allDoneCallback()
131 { 130 {
132 this.target().profilingLock.release(); 131 this.target().profilingLock.release();
133 callback(masterError, masterProfile); 132 callback(masterError, masterProfile);
134 } 133 }
135 }, 134 },
136 135
137 /** 136 /**
137 * @param {boolean=} consoleTimeline
138 * @param {!Array.<!TimelineAgent.TimelineEvent>=} events 138 * @param {!Array.<!TimelineAgent.TimelineEvent>=} events
139 */ 139 */
140 _processBufferedEvents: function(events) 140 _stopped: function(consoleTimeline, events)
141 { 141 {
142 this.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.Ti melineStopped, consoleTimeline);
142 if (events) { 143 if (events) {
143 for (var i = 0; i < events.length; ++i) 144 for (var i = 0; i < events.length; ++i)
144 this._dispatcher.eventRecorded(events[i]); 145 this._dispatcher.eventRecorded(events[i]);
145 } 146 }
147 this.dispatchEventToListeners(WebInspector.TimelineManager.EventTypes.Ti melineAllEventsReceived, 0);
146 }, 148 },
147 149
148 _configureCpuProfilerSamplingInterval: function() 150 _configureCpuProfilerSamplingInterval: function()
149 { 151 {
150 var intervalUs = WebInspector.settings.highResolutionCpuProfiling.get() ? 100 : 1000; 152 var intervalUs = WebInspector.settings.highResolutionCpuProfiling.get() ? 100 : 1000;
151 this.target().profilerAgent().setSamplingInterval(intervalUs, didChangeI nterval); 153 this.target().profilerAgent().setSamplingInterval(intervalUs, didChangeI nterval);
152 154
153 function didChangeInterval(error) 155 function didChangeInterval(error)
154 { 156 {
155 if (error) 157 if (error)
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineStarted, consoleTimeline); 202 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineStarted, consoleTimeline);
201 }, 203 },
202 204
203 /** 205 /**
204 * @param {boolean=} consoleTimeline 206 * @param {boolean=} consoleTimeline
205 * @param {!Array.<!TimelineAgent.TimelineEvent>=} events 207 * @param {!Array.<!TimelineAgent.TimelineEvent>=} events
206 */ 208 */
207 stopped: function(consoleTimeline, events) 209 stopped: function(consoleTimeline, events)
208 { 210 {
209 this._started = false; 211 this._started = false;
210 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineStopped, consoleTimeline); 212 this._manager._stopped(consoleTimeline, events);
211 this._manager._processBufferedEvents(events);
212 }, 213 },
213 214
214 /** 215 /**
215 * @param {number} count 216 * @param {number} count
216 */ 217 */
217 progress: function(count) 218 progress: function(count)
218 { 219 {
219 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineProgress, count); 220 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineProgress, count);
220 } 221 }
221 } 222 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/common/Settings.js ('k') | Source/devtools/front_end/timeline/TimelineModelImpl.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698