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

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

Issue 475803002: Make profiling lock global rather than per Target (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Extracted Lock.js 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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 /** 62 /**
63 * @param {number=} maxCallStackDepth 63 * @param {number=} maxCallStackDepth
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, liveEvents, includeCounters, includeGPUEv ents, callback) 69 start: function(maxCallStackDepth, liveEvents, includeCounters, includeGPUEv ents, callback)
70 { 70 {
71 this._enablementCount++; 71 this._enablementCount++;
72 this.target().profilingLock.acquire(); 72 WebInspector.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, true, liveEve nts, 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 },
(...skipping 13 matching lines...) Expand all
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 105
106 callbackBarrier.callWhenDone(allDoneCallback.bind(this)); 106 callbackBarrier.callWhenDone(allDoneCallback);
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 }
115 115
116 /** 116 /**
117 * @param {?Protocol.Error} error 117 * @param {?Protocol.Error} error
118 * @param {!ProfilerAgent.CPUProfile} profile 118 * @param {!ProfilerAgent.CPUProfile} profile
119 */ 119 */
120 function profilerCallback(error, profile) 120 function profilerCallback(error, profile)
121 { 121 {
122 masterError = masterError || error; 122 masterError = masterError || error;
123 masterProfile = profile; 123 masterProfile = profile;
124 } 124 }
125 125
126 /**
127 * @this {WebInspector.TimelineManager}
128 */
129 function allDoneCallback() 126 function allDoneCallback()
130 { 127 {
131 this.target().profilingLock.release(); 128 WebInspector.profilingLock.release();
132 callback(masterError, masterProfile); 129 callback(masterError, masterProfile);
133 } 130 }
134 }, 131 },
135 132
136 /** 133 /**
137 * @param {boolean=} consoleTimeline 134 * @param {boolean=} consoleTimeline
138 * @param {!Array.<!TimelineAgent.TimelineEvent>=} events 135 * @param {!Array.<!TimelineAgent.TimelineEvent>=} events
139 */ 136 */
140 _stopped: function(consoleTimeline, events) 137 _stopped: function(consoleTimeline, events)
141 { 138 {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 }, 210 },
214 211
215 /** 212 /**
216 * @param {number} count 213 * @param {number} count
217 */ 214 */
218 progress: function(count) 215 progress: function(count)
219 { 216 {
220 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineProgress, count); 217 this._manager.dispatchEventToListeners(WebInspector.TimelineManager.Even tTypes.TimelineProgress, count);
221 } 218 }
222 } 219 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698