OLD | NEW |
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 /** | 53 /** |
54 * @return {boolean} | 54 * @return {boolean} |
55 */ | 55 */ |
56 isStarted: function() | 56 isStarted: function() |
57 { | 57 { |
58 return this._dispatcher.isStarted(); | 58 return this._dispatcher.isStarted(); |
59 }, | 59 }, |
60 | 60 |
61 /** | 61 /** |
62 * @param {number=} maxCallStackDepth | 62 * @param {number=} maxCallStackDepth |
63 * @param {boolean=} bufferEvents | |
64 * @param {string=} liveEvents | 63 * @param {string=} liveEvents |
65 * @param {boolean=} includeCounters | 64 * @param {boolean=} includeCounters |
66 * @param {boolean=} includeGPUEvents | 65 * @param {boolean=} includeGPUEvents |
67 * @param {function(?Protocol.Error)=} callback | 66 * @param {function(?Protocol.Error)=} callback |
68 */ | 67 */ |
69 start: function(maxCallStackDepth, bufferEvents, liveEvents, includeCounters
, includeGPUEvents, callback) | 68 start: function(maxCallStackDepth, liveEvents, includeCounters, includeGPUEv
ents, callback) |
70 { | 69 { |
71 this._enablementCount++; | 70 this._enablementCount++; |
72 this.target().profilingLock.acquire(); | 71 this.target().profilingLock.acquire(); |
73 if (WebInspector.experimentsSettings.timelineJSCPUProfile.isEnabled() &&
maxCallStackDepth) { | 72 if (WebInspector.experimentsSettings.timelineJSCPUProfile.isEnabled() &&
maxCallStackDepth) { |
74 this._configureCpuProfilerSamplingInterval(); | 73 this._configureCpuProfilerSamplingInterval(); |
75 this._jsProfilerStarted = true; | 74 this._jsProfilerStarted = true; |
76 ProfilerAgent.start(); | 75 ProfilerAgent.start(); |
77 } | 76 } |
78 if (this._enablementCount === 1) | 77 if (this._enablementCount === 1) |
79 TimelineAgent.start(maxCallStackDepth, bufferEvents, liveEvents, inc
ludeCounters, includeGPUEvents, callback); | 78 TimelineAgent.start(maxCallStackDepth, liveEvents, includeCounters,
includeGPUEvents, callback); |
80 else if (callback) | 79 else if (callback) |
81 callback(null); | 80 callback(null); |
82 }, | 81 }, |
83 | 82 |
84 /** | 83 /** |
85 * @param {function(?Protocol.Error,?ProfilerAgent.CPUProfile)} callback | 84 * @param {function(?Protocol.Error,?ProfilerAgent.CPUProfile)} callback |
86 */ | 85 */ |
87 stop: function(callback) | 86 stop: function(callback) |
88 { | 87 { |
89 this._enablementCount--; | 88 this._enablementCount--; |
90 if (this._enablementCount < 0) { | 89 if (this._enablementCount < 0) { |
91 console.error("WebInspector.TimelineManager start/stop calls are unb
alanced " + new Error().stack); | 90 console.error("WebInspector.TimelineManager start/stop calls are unb
alanced " + new Error().stack); |
92 return; | 91 return; |
93 } | 92 } |
94 | 93 |
95 var masterError = null; | 94 var masterError = null; |
96 var masterProfile = null; | 95 var masterProfile = null; |
97 var callbackBarrier = new CallbackBarrier(); | 96 var callbackBarrier = new CallbackBarrier(); |
98 | 97 |
99 if (this._jsProfilerStarted) { | 98 if (this._jsProfilerStarted) { |
100 ProfilerAgent.stop(callbackBarrier.createCallback(profilerCallback))
; | 99 ProfilerAgent.stop(callbackBarrier.createCallback(profilerCallback))
; |
101 this._jsProfilerStarted = false; | 100 this._jsProfilerStarted = false; |
102 } | 101 } |
103 if (!this._enablementCount) | 102 if (!this._enablementCount) |
104 TimelineAgent.stop(callbackBarrier.createCallback(this._processBuffe
redEvents.bind(this, timelineCallback))); | 103 TimelineAgent.stop(callbackBarrier.createCallback(timelineCallback))
; |
105 | 104 |
106 callbackBarrier.callWhenDone(allDoneCallback.bind(this)); | 105 callbackBarrier.callWhenDone(allDoneCallback.bind(this)); |
107 | 106 |
108 /** | 107 /** |
109 * @param {?Protocol.Error} error | 108 * @param {?Protocol.Error} error |
110 */ | 109 */ |
111 function timelineCallback(error) | 110 function timelineCallback(error) |
112 { | 111 { |
113 masterError = masterError || error; | 112 masterError = masterError || error; |
114 } | 113 } |
(...skipping 12 matching lines...) Expand all Loading... |
127 * @this {WebInspector.TimelineManager} | 126 * @this {WebInspector.TimelineManager} |
128 */ | 127 */ |
129 function allDoneCallback() | 128 function allDoneCallback() |
130 { | 129 { |
131 this.target().profilingLock.release(); | 130 this.target().profilingLock.release(); |
132 callback(masterError, masterProfile); | 131 callback(masterError, masterProfile); |
133 } | 132 } |
134 }, | 133 }, |
135 | 134 |
136 /** | 135 /** |
137 * @param {function(?Protocol.Error)|undefined} callback | |
138 * @param {?Protocol.Error} error | |
139 * @param {!Array.<!TimelineAgent.TimelineEvent>=} events | 136 * @param {!Array.<!TimelineAgent.TimelineEvent>=} events |
140 */ | 137 */ |
141 _processBufferedEvents: function(callback, error, events) | 138 _processBufferedEvents: function(events) |
142 { | 139 { |
143 if (events) { | 140 if (events) { |
144 for (var i = 0; i < events.length; ++i) | 141 for (var i = 0; i < events.length; ++i) |
145 this._dispatcher.eventRecorded(events[i]); | 142 this._dispatcher.eventRecorded(events[i]); |
146 } | 143 } |
147 if (callback) | |
148 callback(error); | |
149 }, | 144 }, |
150 | 145 |
151 _configureCpuProfilerSamplingInterval: function() | 146 _configureCpuProfilerSamplingInterval: function() |
152 { | 147 { |
153 var intervalUs = WebInspector.settings.highResolutionCpuProfiling.get()
? 100 : 1000; | 148 var intervalUs = WebInspector.settings.highResolutionCpuProfiling.get()
? 100 : 1000; |
154 ProfilerAgent.setSamplingInterval(intervalUs, didChangeInterval.bind(thi
s)); | 149 ProfilerAgent.setSamplingInterval(intervalUs, didChangeInterval.bind(thi
s)); |
155 | 150 |
156 /** | 151 /** |
157 * @this {WebInspector.TimelineManager} | 152 * @this {WebInspector.TimelineManager} |
158 */ | 153 */ |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 if (consoleTimeline) { | 196 if (consoleTimeline) { |
202 // Wake up timeline panel module. | 197 // Wake up timeline panel module. |
203 WebInspector.moduleManager.loadModule("timeline"); | 198 WebInspector.moduleManager.loadModule("timeline"); |
204 } | 199 } |
205 this._started = true; | 200 this._started = true; |
206 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even
tTypes.TimelineStarted, consoleTimeline); | 201 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even
tTypes.TimelineStarted, consoleTimeline); |
207 }, | 202 }, |
208 | 203 |
209 /** | 204 /** |
210 * @param {boolean=} consoleTimeline | 205 * @param {boolean=} consoleTimeline |
| 206 * @param {!Array.<!TimelineAgent.TimelineEvent>=} events |
211 */ | 207 */ |
212 stopped: function(consoleTimeline) | 208 stopped: function(consoleTimeline, events) |
213 { | 209 { |
214 this._started = false; | 210 this._started = false; |
215 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even
tTypes.TimelineStopped, consoleTimeline); | 211 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even
tTypes.TimelineStopped, consoleTimeline); |
| 212 this._manager._processBufferedEvents(events); |
216 }, | 213 }, |
217 | 214 |
218 /** | 215 /** |
219 * @param {number} count | 216 * @param {number} count |
220 */ | 217 */ |
221 progress: function(count) | 218 progress: function(count) |
222 { | 219 { |
223 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even
tTypes.TimelineProgress, count); | 220 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even
tTypes.TimelineProgress, count); |
224 } | 221 } |
225 } | 222 } |
226 | 223 |
227 /** | 224 /** |
228 * @type {!WebInspector.TimelineManager} | 225 * @type {!WebInspector.TimelineManager} |
229 */ | 226 */ |
230 WebInspector.timelineManager; | 227 WebInspector.timelineManager; |
OLD | NEW |