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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, bufferEvents, liveEvents, includeCounters
, includeGPUEvents, 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 ProfilerAgent.start(); | 76 this.target().profilerAgent().start(); |
77 } | 77 } |
78 if (this._enablementCount === 1) | 78 if (this._enablementCount === 1) |
79 TimelineAgent.start(maxCallStackDepth, bufferEvents, liveEvents, inc
ludeCounters, includeGPUEvents, callback); | 79 this.target().timelineAgent().start(maxCallStackDepth, bufferEvents,
liveEvents, 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 ProfilerAgent.stop(callbackBarrier.createCallback(profilerCallback))
; | 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 TimelineAgent.stop(callbackBarrier.createCallback(this._processBuffe
redEvents.bind(this, timelineCallback))); | 104 this.target().timelineAgent().stop(callbackBarrier.createCallback(th
is._processBufferedEvents.bind(this, timelineCallback))); |
105 | 105 |
106 callbackBarrier.callWhenDone(allDoneCallback.bind(this)); | 106 callbackBarrier.callWhenDone(allDoneCallback.bind(this)); |
107 | 107 |
108 /** | 108 /** |
109 * @param {?Protocol.Error} error | 109 * @param {?Protocol.Error} error |
110 */ | 110 */ |
111 function timelineCallback(error) | 111 function timelineCallback(error) |
112 { | 112 { |
113 masterError = masterError || error; | 113 masterError = masterError || error; |
114 } | 114 } |
(...skipping 29 matching lines...) Expand all Loading... |
144 for (var i = 0; i < events.length; ++i) | 144 for (var i = 0; i < events.length; ++i) |
145 this._dispatcher.eventRecorded(events[i]); | 145 this._dispatcher.eventRecorded(events[i]); |
146 } | 146 } |
147 if (callback) | 147 if (callback) |
148 callback(error); | 148 callback(error); |
149 }, | 149 }, |
150 | 150 |
151 _configureCpuProfilerSamplingInterval: function() | 151 _configureCpuProfilerSamplingInterval: function() |
152 { | 152 { |
153 var intervalUs = WebInspector.settings.highResolutionCpuProfiling.get()
? 100 : 1000; | 153 var intervalUs = WebInspector.settings.highResolutionCpuProfiling.get()
? 100 : 1000; |
154 ProfilerAgent.setSamplingInterval(intervalUs, didChangeInterval); | 154 this.target().profilerAgent().setSamplingInterval(intervalUs, didChangeI
nterval); |
155 | 155 |
156 function didChangeInterval(error) | 156 function didChangeInterval(error) |
157 { | 157 { |
158 if (error) | 158 if (error) |
159 WebInspector.console.error(error); | 159 WebInspector.console.error(error); |
160 } | 160 } |
161 }, | 161 }, |
162 | 162 |
163 __proto__: WebInspector.SDKModel.prototype | 163 __proto__: WebInspector.SDKModel.prototype |
164 } | 164 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
218 progress: function(count) | 218 progress: function(count) |
219 { | 219 { |
220 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even
tTypes.TimelineProgress, count); | 220 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even
tTypes.TimelineProgress, count); |
221 } | 221 } |
222 } | 222 } |
223 | 223 |
224 /** | 224 /** |
225 * @type {!WebInspector.TimelineManager} | 225 * @type {!WebInspector.TimelineManager} |
226 */ | 226 */ |
227 WebInspector.timelineManager; | 227 WebInspector.timelineManager; |
OLD | NEW |