OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
46 #include <v8.h> | 46 #include <v8.h> |
47 | 47 |
48 namespace { | 48 namespace { |
49 | 49 |
50 static const char setTimeoutName[] = "setTimeout"; | 50 static const char setTimeoutName[] = "setTimeout"; |
51 static const char setIntervalName[] = "setInterval"; | 51 static const char setIntervalName[] = "setInterval"; |
52 static const char requestAnimationFrameName[] = "requestAnimationFrame"; | 52 static const char requestAnimationFrameName[] = "requestAnimationFrame"; |
53 static const char xhrSendName[] = "XMLHttpRequest.send"; | 53 static const char xhrSendName[] = "XMLHttpRequest.send"; |
54 static const char enqueueMutationRecordName[] = "Mutation"; | 54 static const char enqueueMutationRecordName[] = "Mutation"; |
55 | 55 |
56 const int noOperationId = 0; | |
aandrey
2015/01/20 14:33:35
noAsyncOperationId or nullAsyncOperationId?
make a
yurys
2015/01/20 17:15:38
Done.
| |
57 | |
56 } | 58 } |
57 | 59 |
58 namespace blink { | 60 namespace blink { |
59 | 61 |
60 class AsyncCallTracker::ExecutionContextData final : public NoBaseWillBeGarbageC ollectedFinalized<ExecutionContextData>, public ContextLifecycleObserver { | 62 class AsyncCallTracker::ExecutionContextData final : public NoBaseWillBeGarbageC ollectedFinalized<ExecutionContextData>, public ContextLifecycleObserver { |
61 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AsyncCallTracker::ExecutionContextData ); | 63 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AsyncCallTracker::ExecutionContextData ); |
62 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 64 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
63 public: | 65 public: |
64 ExecutionContextData(AsyncCallTracker* tracker, ExecutionContext* executionC ontext) | 66 ExecutionContextData(AsyncCallTracker* tracker, ExecutionContext* executionC ontext) |
65 : ContextLifecycleObserver(executionContext) | 67 : ContextLifecycleObserver(executionContext) |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 } | 119 } |
118 | 120 |
119 RawPtrWillBeMember<AsyncCallTracker> m_tracker; | 121 RawPtrWillBeMember<AsyncCallTracker> m_tracker; |
120 HashSet<int> m_intervalTimerIds; | 122 HashSet<int> m_intervalTimerIds; |
121 AsyncCallChainMap<int> m_timerCallChains; | 123 AsyncCallChainMap<int> m_timerCallChains; |
122 AsyncCallChainMap<int> m_animationFrameCallChains; | 124 AsyncCallChainMap<int> m_animationFrameCallChains; |
123 AsyncCallChainMap<RawPtrWillBeMember<Event> > m_eventCallChains; | 125 AsyncCallChainMap<RawPtrWillBeMember<Event> > m_eventCallChains; |
124 AsyncCallChainMap<RawPtrWillBeMember<EventTarget> > m_xhrCallChains; | 126 AsyncCallChainMap<RawPtrWillBeMember<EventTarget> > m_xhrCallChains; |
125 AsyncCallChainMap<RawPtrWillBeMember<MutationObserver> > m_mutationObserverC allChains; | 127 AsyncCallChainMap<RawPtrWillBeMember<MutationObserver> > m_mutationObserverC allChains; |
126 AsyncCallChainMap<ExecutionContextTask*> m_executionContextTaskCallChains; | 128 AsyncCallChainMap<ExecutionContextTask*> m_executionContextTaskCallChains; |
127 AsyncCallChainMap<int> m_asyncOperationCallChains; | 129 AsyncCallChainMap<int> m_asyncOperationCallChains; |
aandrey
2015/01/20 14:33:36
remove?
yurys
2015/01/20 17:15:38
Removed nextAsyncOperationUniqueId() instead and n
| |
128 | 130 |
129 private: | 131 private: |
130 void disposeCallChains() | 132 void disposeCallChains() |
131 { | 133 { |
132 m_timerCallChains.dispose(); | 134 m_timerCallChains.dispose(); |
133 m_animationFrameCallChains.dispose(); | 135 m_animationFrameCallChains.dispose(); |
134 m_eventCallChains.dispose(); | 136 m_eventCallChains.dispose(); |
135 m_xhrCallChains.dispose(); | 137 m_xhrCallChains.dispose(); |
136 m_mutationObserverCallChains.dispose(); | 138 m_mutationObserverCallChains.dispose(); |
137 m_executionContextTaskCallChains.dispose(); | 139 m_executionContextTaskCallChains.dispose(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 { | 173 { |
172 for (auto& it : m_executionContextDataMap) | 174 for (auto& it : m_executionContextDataMap) |
173 it.value->unobserve(); | 175 it.value->unobserve(); |
174 m_executionContextDataMap.clear(); | 176 m_executionContextDataMap.clear(); |
175 } | 177 } |
176 | 178 |
177 void AsyncCallTracker::didInstallTimer(ExecutionContext* context, int timerId, i nt timeout, bool singleShot) | 179 void AsyncCallTracker::didInstallTimer(ExecutionContext* context, int timerId, i nt timeout, bool singleShot) |
178 { | 180 { |
179 ASSERT(context); | 181 ASSERT(context); |
180 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 182 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
181 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->traceAsyncOp erationStarting(singleShot ? setTimeoutName : setIntervalName); | 183 int operationId = m_debuggerAgent->traceAsyncOperationStarting(singleShot ? setTimeoutName : setIntervalName); |
182 if (!callChain) | 184 if (!operationId) |
183 return; | 185 return; |
184 ASSERT(timerId > 0); | 186 ASSERT(timerId > 0); |
185 ExecutionContextData* data = createContextDataIfNeeded(context); | 187 ExecutionContextData* data = createContextDataIfNeeded(context); |
186 data->m_timerCallChains.set(timerId, callChain.release()); | 188 data->m_timerCallChains.set(timerId, operationId); |
187 if (!singleShot) | 189 if (!singleShot) |
188 data->m_intervalTimerIds.add(timerId); | 190 data->m_intervalTimerIds.add(timerId); |
189 } | 191 } |
190 | 192 |
191 void AsyncCallTracker::didRemoveTimer(ExecutionContext* context, int timerId) | 193 void AsyncCallTracker::didRemoveTimer(ExecutionContext* context, int timerId) |
192 { | 194 { |
193 ASSERT(context); | 195 ASSERT(context); |
194 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 196 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
195 if (timerId <= 0) | 197 if (timerId <= 0) |
196 return; | 198 return; |
197 ExecutionContextData* data = m_executionContextDataMap.get(context); | 199 ExecutionContextData* data = m_executionContextDataMap.get(context); |
198 if (!data) | 200 if (!data) |
199 return; | 201 return; |
200 data->m_intervalTimerIds.remove(timerId); | 202 data->m_intervalTimerIds.remove(timerId); |
201 data->m_timerCallChains.remove(timerId); | 203 data->m_timerCallChains.remove(timerId); |
202 } | 204 } |
203 | 205 |
204 bool AsyncCallTracker::willFireTimer(ExecutionContext* context, int timerId) | 206 bool AsyncCallTracker::willFireTimer(ExecutionContext* context, int timerId) |
205 { | 207 { |
206 ASSERT(context); | 208 ASSERT(context); |
207 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 209 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
208 ASSERT(timerId > 0); | 210 ASSERT(timerId > 0); |
209 ASSERT(!m_debuggerAgent->currentAsyncCallChain()); | 211 ASSERT(!m_debuggerAgent->currentAsyncCallChain()); |
210 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { | 212 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { |
211 setCurrentAsyncCallChain(context, data->m_timerCallChains.get(timerId)); | 213 setCurrentAsyncCallChain(context, data->m_timerCallChains.get(timerId)); |
212 if (!data->m_intervalTimerIds.contains(timerId)) | 214 if (!data->m_intervalTimerIds.contains(timerId)) |
213 data->m_timerCallChains.remove(timerId); | 215 data->m_timerCallChains.remove(timerId); |
214 } else { | 216 } else { |
215 setCurrentAsyncCallChain(context, nullptr); | 217 setCurrentAsyncCallChain(context, noOperationId); |
216 } | 218 } |
217 return true; | 219 return true; |
218 } | 220 } |
219 | 221 |
220 void AsyncCallTracker::didRequestAnimationFrame(ExecutionContext* context, int c allbackId) | 222 void AsyncCallTracker::didRequestAnimationFrame(ExecutionContext* context, int c allbackId) |
221 { | 223 { |
222 ASSERT(context); | 224 ASSERT(context); |
223 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 225 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
224 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->traceAsyncOp erationStarting(requestAnimationFrameName); | 226 int operationId = m_debuggerAgent->traceAsyncOperationStarting(requestAnimat ionFrameName); |
225 if (!callChain) | 227 if (!operationId) |
226 return; | 228 return; |
227 ASSERT(callbackId > 0); | 229 ASSERT(callbackId > 0); |
228 ExecutionContextData* data = createContextDataIfNeeded(context); | 230 ExecutionContextData* data = createContextDataIfNeeded(context); |
229 data->m_animationFrameCallChains.set(callbackId, callChain.release()); | 231 data->m_animationFrameCallChains.set(callbackId, operationId); |
230 } | 232 } |
231 | 233 |
232 void AsyncCallTracker::didCancelAnimationFrame(ExecutionContext* context, int ca llbackId) | 234 void AsyncCallTracker::didCancelAnimationFrame(ExecutionContext* context, int ca llbackId) |
233 { | 235 { |
234 ASSERT(context); | 236 ASSERT(context); |
235 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 237 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
236 if (callbackId <= 0) | 238 if (callbackId <= 0) |
237 return; | 239 return; |
238 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 240 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
239 data->m_animationFrameCallChains.remove(callbackId); | 241 data->m_animationFrameCallChains.remove(callbackId); |
240 } | 242 } |
241 | 243 |
242 bool AsyncCallTracker::willFireAnimationFrame(ExecutionContext* context, int cal lbackId) | 244 bool AsyncCallTracker::willFireAnimationFrame(ExecutionContext* context, int cal lbackId) |
243 { | 245 { |
244 ASSERT(context); | 246 ASSERT(context); |
245 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 247 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
246 ASSERT(callbackId > 0); | 248 ASSERT(callbackId > 0); |
247 ASSERT(!m_debuggerAgent->currentAsyncCallChain()); | 249 ASSERT(!m_debuggerAgent->currentAsyncCallChain()); |
248 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { | 250 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { |
249 setCurrentAsyncCallChain(context, data->m_animationFrameCallChains.get(c allbackId)); | 251 setCurrentAsyncCallChain(context, data->m_animationFrameCallChains.get(c allbackId)); |
250 data->m_animationFrameCallChains.remove(callbackId); | 252 data->m_animationFrameCallChains.remove(callbackId); |
251 } else { | 253 } else { |
252 setCurrentAsyncCallChain(context, nullptr); | 254 setCurrentAsyncCallChain(context, noOperationId); |
253 } | 255 } |
254 return true; | 256 return true; |
255 } | 257 } |
256 | 258 |
257 void AsyncCallTracker::didEnqueueEvent(EventTarget* eventTarget, Event* event) | 259 void AsyncCallTracker::didEnqueueEvent(EventTarget* eventTarget, Event* event) |
258 { | 260 { |
259 ASSERT(eventTarget->executionContext()); | 261 ASSERT(eventTarget->executionContext()); |
260 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 262 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
261 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->traceAsyncOp erationStarting(event->type()); | 263 int operationId = m_debuggerAgent->traceAsyncOperationStarting(event->type() ); |
262 if (!callChain) | 264 if (!operationId) |
263 return; | 265 return; |
264 ExecutionContextData* data = createContextDataIfNeeded(eventTarget->executio nContext()); | 266 ExecutionContextData* data = createContextDataIfNeeded(eventTarget->executio nContext()); |
265 data->m_eventCallChains.set(event, callChain.release()); | 267 data->m_eventCallChains.set(event, operationId); |
266 } | 268 } |
267 | 269 |
268 void AsyncCallTracker::didRemoveEvent(EventTarget* eventTarget, Event* event) | 270 void AsyncCallTracker::didRemoveEvent(EventTarget* eventTarget, Event* event) |
269 { | 271 { |
270 ASSERT(eventTarget->executionContext()); | 272 ASSERT(eventTarget->executionContext()); |
271 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 273 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
272 if (ExecutionContextData* data = m_executionContextDataMap.get(eventTarget-> executionContext())) | 274 if (ExecutionContextData* data = m_executionContextDataMap.get(eventTarget-> executionContext())) |
273 data->m_eventCallChains.remove(event); | 275 data->m_eventCallChains.remove(event); |
274 } | 276 } |
275 | 277 |
276 void AsyncCallTracker::willHandleEvent(EventTarget* eventTarget, Event* event, E ventListener* listener, bool useCapture) | 278 void AsyncCallTracker::willHandleEvent(EventTarget* eventTarget, Event* event, E ventListener* listener, bool useCapture) |
277 { | 279 { |
278 ASSERT(eventTarget->executionContext()); | 280 ASSERT(eventTarget->executionContext()); |
279 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 281 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
280 if (XMLHttpRequest* xhr = toXmlHttpRequest(eventTarget)) { | 282 if (XMLHttpRequest* xhr = toXmlHttpRequest(eventTarget)) { |
281 willHandleXHREvent(xhr, event); | 283 willHandleXHREvent(xhr, event); |
282 } else { | 284 } else { |
283 ExecutionContext* context = eventTarget->executionContext(); | 285 ExecutionContext* context = eventTarget->executionContext(); |
284 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 286 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
285 setCurrentAsyncCallChain(context, data->m_eventCallChains.get(event) ); | 287 setCurrentAsyncCallChain(context, data->m_eventCallChains.get(event) ); |
286 else | 288 else |
287 setCurrentAsyncCallChain(context, nullptr); | 289 setCurrentAsyncCallChain(context, noOperationId); |
288 } | 290 } |
289 } | 291 } |
290 | 292 |
291 void AsyncCallTracker::willLoadXHR(XMLHttpRequest* xhr, ThreadableLoaderClient*, const AtomicString&, const KURL&, bool async, PassRefPtr<FormData>, const HTTPH eaderMap&, bool) | 293 void AsyncCallTracker::willLoadXHR(XMLHttpRequest* xhr, ThreadableLoaderClient*, const AtomicString&, const KURL&, bool async, PassRefPtr<FormData>, const HTTPH eaderMap&, bool) |
292 { | 294 { |
293 ASSERT(xhr->executionContext()); | 295 ASSERT(xhr->executionContext()); |
294 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 296 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
295 if (!async) | 297 if (!async) |
296 return; | 298 return; |
297 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->traceAsyncOp erationStarting(xhrSendName); | 299 int operationId = m_debuggerAgent->traceAsyncOperationStarting(xhrSendName); |
298 if (!callChain) | 300 if (!operationId) |
299 return; | 301 return; |
300 ExecutionContextData* data = createContextDataIfNeeded(xhr->executionContext ()); | 302 ExecutionContextData* data = createContextDataIfNeeded(xhr->executionContext ()); |
301 data->m_xhrCallChains.set(xhr, callChain.release()); | 303 data->m_xhrCallChains.set(xhr, operationId); |
302 } | 304 } |
303 | 305 |
304 void AsyncCallTracker::didDispatchXHRLoadendEvent(XMLHttpRequest* xhr) | 306 void AsyncCallTracker::didDispatchXHRLoadendEvent(XMLHttpRequest* xhr) |
305 { | 307 { |
306 ASSERT(xhr->executionContext()); | 308 ASSERT(xhr->executionContext()); |
307 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 309 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
308 if (ExecutionContextData* data = m_executionContextDataMap.get(xhr->executio nContext())) | 310 if (ExecutionContextData* data = m_executionContextDataMap.get(xhr->executio nContext())) |
309 data->m_xhrCallChains.remove(xhr); | 311 data->m_xhrCallChains.remove(xhr); |
310 } | 312 } |
311 | 313 |
312 void AsyncCallTracker::willHandleXHREvent(XMLHttpRequest* xhr, Event* event) | 314 void AsyncCallTracker::willHandleXHREvent(XMLHttpRequest* xhr, Event* event) |
313 { | 315 { |
314 ExecutionContext* context = xhr->executionContext(); | 316 ExecutionContext* context = xhr->executionContext(); |
315 ASSERT(context); | 317 ASSERT(context); |
316 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 318 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
317 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 319 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
318 setCurrentAsyncCallChain(context, data->m_xhrCallChains.get(xhr)); | 320 setCurrentAsyncCallChain(context, data->m_xhrCallChains.get(xhr)); |
319 else | 321 else |
320 setCurrentAsyncCallChain(context, nullptr); | 322 setCurrentAsyncCallChain(context, noOperationId); |
321 } | 323 } |
322 | 324 |
323 void AsyncCallTracker::didEnqueueMutationRecord(ExecutionContext* context, Mutat ionObserver* observer) | 325 void AsyncCallTracker::didEnqueueMutationRecord(ExecutionContext* context, Mutat ionObserver* observer) |
324 { | 326 { |
325 ASSERT(context); | 327 ASSERT(context); |
326 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 328 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
327 ExecutionContextData* data = createContextDataIfNeeded(context); | 329 ExecutionContextData* data = createContextDataIfNeeded(context); |
328 if (data->m_mutationObserverCallChains.contains(observer)) | 330 if (data->m_mutationObserverCallChains.contains(observer)) |
329 return; | 331 return; |
330 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->traceAsyncOp erationStarting(enqueueMutationRecordName); | 332 int operationId = m_debuggerAgent->traceAsyncOperationStarting(enqueueMutati onRecordName); |
331 if (!callChain) | 333 if (!operationId) |
332 return; | 334 return; |
333 data->m_mutationObserverCallChains.set(observer, callChain.release()); | 335 data->m_mutationObserverCallChains.set(observer, operationId); |
334 } | 336 } |
335 | 337 |
336 void AsyncCallTracker::didClearAllMutationRecords(ExecutionContext* context, Mut ationObserver* observer) | 338 void AsyncCallTracker::didClearAllMutationRecords(ExecutionContext* context, Mut ationObserver* observer) |
337 { | 339 { |
338 ASSERT(context); | 340 ASSERT(context); |
339 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 341 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
340 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 342 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
341 data->m_mutationObserverCallChains.remove(observer); | 343 data->m_mutationObserverCallChains.remove(observer); |
342 } | 344 } |
343 | 345 |
344 void AsyncCallTracker::willDeliverMutationRecords(ExecutionContext* context, Mut ationObserver* observer) | 346 void AsyncCallTracker::willDeliverMutationRecords(ExecutionContext* context, Mut ationObserver* observer) |
345 { | 347 { |
346 ASSERT(context); | 348 ASSERT(context); |
347 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 349 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
348 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { | 350 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { |
349 setCurrentAsyncCallChain(context, data->m_mutationObserverCallChains.get (observer)); | 351 setCurrentAsyncCallChain(context, data->m_mutationObserverCallChains.get (observer)); |
350 data->m_mutationObserverCallChains.remove(observer); | 352 data->m_mutationObserverCallChains.remove(observer); |
351 } else { | 353 } else { |
352 setCurrentAsyncCallChain(context, nullptr); | 354 setCurrentAsyncCallChain(context, noOperationId); |
353 } | 355 } |
354 } | 356 } |
355 | 357 |
356 void AsyncCallTracker::didPostExecutionContextTask(ExecutionContext* context, Ex ecutionContextTask* task) | 358 void AsyncCallTracker::didPostExecutionContextTask(ExecutionContext* context, Ex ecutionContextTask* task) |
357 { | 359 { |
358 ASSERT(context); | 360 ASSERT(context); |
359 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 361 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
360 if (task->taskNameForInstrumentation().isEmpty()) | 362 if (task->taskNameForInstrumentation().isEmpty()) |
361 return; | 363 return; |
362 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->traceAsyncOp erationStarting(task->taskNameForInstrumentation()); | 364 int operationId = m_debuggerAgent->traceAsyncOperationStarting(task->taskNam eForInstrumentation()); |
363 if (!callChain) | 365 if (!operationId) |
364 return; | 366 return; |
365 ExecutionContextData* data = createContextDataIfNeeded(context); | 367 ExecutionContextData* data = createContextDataIfNeeded(context); |
366 data->m_executionContextTaskCallChains.set(task, callChain.release()); | 368 data->m_executionContextTaskCallChains.set(task, operationId); |
367 } | 369 } |
368 | 370 |
369 void AsyncCallTracker::didKillAllExecutionContextTasks(ExecutionContext* context ) | 371 void AsyncCallTracker::didKillAllExecutionContextTasks(ExecutionContext* context ) |
370 { | 372 { |
371 ASSERT(context); | 373 ASSERT(context); |
372 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 374 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
373 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 375 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
374 data->m_executionContextTaskCallChains.clear(); | 376 data->m_executionContextTaskCallChains.clear(); |
375 } | 377 } |
376 | 378 |
377 void AsyncCallTracker::willPerformExecutionContextTask(ExecutionContext* context , ExecutionContextTask* task) | 379 void AsyncCallTracker::willPerformExecutionContextTask(ExecutionContext* context , ExecutionContextTask* task) |
378 { | 380 { |
379 ASSERT(context); | 381 ASSERT(context); |
380 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 382 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
381 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { | 383 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { |
382 setCurrentAsyncCallChain(context, data->m_executionContextTaskCallChains .get(task)); | 384 setCurrentAsyncCallChain(context, data->m_executionContextTaskCallChains .get(task)); |
383 data->m_executionContextTaskCallChains.remove(task); | 385 data->m_executionContextTaskCallChains.remove(task); |
384 } else { | 386 } else { |
385 setCurrentAsyncCallChain(context, nullptr); | 387 setCurrentAsyncCallChain(context, noOperationId); |
386 } | 388 } |
387 } | 389 } |
388 | 390 |
389 int AsyncCallTracker::traceAsyncOperationStarting(ExecutionContext* context, con st String& operationName, int prevOperationId) | 391 int AsyncCallTracker::traceAsyncOperationStarting(ExecutionContext* context, con st String& operationName, int prevOperationId) |
390 { | 392 { |
391 ASSERT(context); | 393 ASSERT(context); |
392 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 394 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
393 if (prevOperationId) | 395 if (prevOperationId) |
394 traceAsyncOperationCompleted(context, prevOperationId); | 396 traceAsyncOperationCompleted(context, prevOperationId); |
395 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->traceAsyncOp erationStarting(operationName); | 397 int operationId = m_debuggerAgent->traceAsyncOperationStarting(operationName ); |
396 if (!callChain) | 398 if (!operationId) |
397 return 0; | 399 return 0; |
398 ExecutionContextData* data = createContextDataIfNeeded(context); | 400 ExecutionContextData* data = createContextDataIfNeeded(context); |
399 int id = data->nextAsyncOperationUniqueId(); | 401 int id = data->nextAsyncOperationUniqueId(); |
aandrey
2015/01/20 14:33:35
remove, use a Set of operationId's
yurys
2015/01/20 17:15:38
Done.
| |
400 data->m_asyncOperationCallChains.set(id, callChain.release()); | 402 data->m_asyncOperationCallChains.set(id, operationId); |
401 return id; | 403 return id; |
402 } | 404 } |
403 | 405 |
404 void AsyncCallTracker::traceAsyncOperationCompleted(ExecutionContext* context, i nt operationId) | 406 void AsyncCallTracker::traceAsyncOperationCompleted(ExecutionContext* context, i nt operationId) |
405 { | 407 { |
406 ASSERT(context); | 408 ASSERT(context); |
407 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 409 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
408 if (operationId <= 0) | 410 if (operationId <= 0) |
409 return; | 411 return; |
410 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 412 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
411 data->m_asyncOperationCallChains.remove(operationId); | 413 data->m_asyncOperationCallChains.remove(operationId); |
412 } | 414 } |
413 | 415 |
414 void AsyncCallTracker::traceAsyncOperationCompletedCallbackStarting(ExecutionCon text* context, int operationId) | 416 void AsyncCallTracker::traceAsyncOperationCompletedCallbackStarting(ExecutionCon text* context, int operationId) |
415 { | 417 { |
416 traceAsyncCallbackStarting(context, operationId); | 418 traceAsyncCallbackStarting(context, operationId); |
417 traceAsyncOperationCompleted(context, operationId); | 419 traceAsyncOperationCompleted(context, operationId); |
418 } | 420 } |
419 | 421 |
420 void AsyncCallTracker::traceAsyncCallbackStarting(ExecutionContext* context, int operationId) | 422 void AsyncCallTracker::traceAsyncCallbackStarting(ExecutionContext* context, int operationId) |
421 { | 423 { |
422 ASSERT(context); | 424 ASSERT(context); |
423 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 425 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
424 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 426 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
425 setCurrentAsyncCallChain(context, operationId > 0 ? data->m_asyncOperati onCallChains.get(operationId) : nullptr); | 427 setCurrentAsyncCallChain(context, operationId > 0 ? data->m_asyncOperati onCallChains.get(operationId) : noOperationId); |
426 else | 428 else |
427 setCurrentAsyncCallChain(context, nullptr); | 429 setCurrentAsyncCallChain(context, noOperationId); |
428 } | 430 } |
429 | 431 |
430 void AsyncCallTracker::didFireAsyncCall() | 432 void AsyncCallTracker::didFireAsyncCall() |
431 { | 433 { |
432 m_debuggerAgent->traceAsyncCallbackCompleted(); | 434 m_debuggerAgent->traceAsyncCallbackCompleted(); |
433 } | 435 } |
434 | 436 |
435 void AsyncCallTracker::setCurrentAsyncCallChain(ExecutionContext* context, PassR efPtrWillBeRawPtr<AsyncCallChain> chain) | 437 void AsyncCallTracker::setCurrentAsyncCallChain(ExecutionContext* context, int o perationId) |
436 { | 438 { |
437 m_debuggerAgent->traceAsyncCallbackStarting(toIsolate(context), chain); | 439 m_debuggerAgent->traceAsyncCallbackStarting(toIsolate(context), operationId) ; |
438 } | 440 } |
439 | 441 |
440 AsyncCallTracker::ExecutionContextData* AsyncCallTracker::createContextDataIfNee ded(ExecutionContext* context) | 442 AsyncCallTracker::ExecutionContextData* AsyncCallTracker::createContextDataIfNee ded(ExecutionContext* context) |
441 { | 443 { |
442 ExecutionContextData* data = m_executionContextDataMap.get(context); | 444 ExecutionContextData* data = m_executionContextDataMap.get(context); |
443 if (!data) { | 445 if (!data) { |
444 data = m_executionContextDataMap.set(context, adoptPtrWillBeNoop(new Asy ncCallTracker::ExecutionContextData(this, context))) | 446 data = m_executionContextDataMap.set(context, adoptPtrWillBeNoop(new Asy ncCallTracker::ExecutionContextData(this, context))) |
445 .storedValue->value.get(); | 447 .storedValue->value.get(); |
446 } | 448 } |
447 return data; | 449 return data; |
448 } | 450 } |
449 | 451 |
450 void AsyncCallTracker::trace(Visitor* visitor) | 452 void AsyncCallTracker::trace(Visitor* visitor) |
451 { | 453 { |
452 #if ENABLE(OILPAN) | 454 #if ENABLE(OILPAN) |
453 visitor->trace(m_executionContextDataMap); | 455 visitor->trace(m_executionContextDataMap); |
454 visitor->trace(m_debuggerAgent); | 456 visitor->trace(m_debuggerAgent); |
455 visitor->trace(m_instrumentingAgents); | 457 visitor->trace(m_instrumentingAgents); |
456 #endif | 458 #endif |
457 InspectorDebuggerAgent::AsyncCallTrackingListener::trace(visitor); | 459 InspectorDebuggerAgent::AsyncCallTrackingListener::trace(visitor); |
458 } | 460 } |
459 | 461 |
460 } // namespace blink | 462 } // namespace blink |
OLD | NEW |