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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 ExecutionContextData(AsyncCallTracker* tracker, ExecutionContext* executionC
ontext) | 64 ExecutionContextData(AsyncCallTracker* tracker, ExecutionContext* executionC
ontext) |
65 : ContextLifecycleObserver(executionContext) | 65 : ContextLifecycleObserver(executionContext) |
66 , m_tracker(tracker) | 66 , m_tracker(tracker) |
67 , m_timerCallChains(tracker->m_debuggerAgent) | 67 , m_timerCallChains(tracker->m_debuggerAgent) |
68 , m_animationFrameCallChains(tracker->m_debuggerAgent) | 68 , m_animationFrameCallChains(tracker->m_debuggerAgent) |
69 , m_eventCallChains(tracker->m_debuggerAgent) | 69 , m_eventCallChains(tracker->m_debuggerAgent) |
70 , m_xhrCallChains(tracker->m_debuggerAgent) | 70 , m_xhrCallChains(tracker->m_debuggerAgent) |
71 , m_mutationObserverCallChains(tracker->m_debuggerAgent) | 71 , m_mutationObserverCallChains(tracker->m_debuggerAgent) |
72 , m_executionContextTaskCallChains(tracker->m_debuggerAgent) | 72 , m_executionContextTaskCallChains(tracker->m_debuggerAgent) |
73 , m_asyncOperationCallChains(tracker->m_debuggerAgent) | 73 , m_asyncOperationCallChains(tracker->m_debuggerAgent) |
74 , m_circularSequentialId(0) | |
75 { | 74 { |
76 } | 75 } |
77 | 76 |
78 virtual void contextDestroyed() override | 77 virtual void contextDestroyed() override |
79 { | 78 { |
80 ASSERT(executionContext()); | 79 ASSERT(executionContext()); |
81 OwnPtrWillBeRawPtr<ExecutionContextData> self = m_tracker->m_executionCo
ntextDataMap.take(executionContext()); | 80 OwnPtrWillBeRawPtr<ExecutionContextData> self = m_tracker->m_executionCo
ntextDataMap.take(executionContext()); |
82 ASSERT_UNUSED(self, self == this); | 81 ASSERT_UNUSED(self, self == this); |
83 ContextLifecycleObserver::contextDestroyed(); | 82 ContextLifecycleObserver::contextDestroyed(); |
84 clearLifecycleContext(); | 83 clearLifecycleContext(); |
85 disposeCallChains(); | 84 disposeCallChains(); |
86 } | 85 } |
87 | 86 |
88 void unobserve() | 87 void unobserve() |
89 { | 88 { |
90 disposeCallChains(); | 89 disposeCallChains(); |
91 dispose(); | 90 dispose(); |
92 } | 91 } |
93 | 92 |
94 int nextAsyncOperationUniqueId() | |
95 { | |
96 do { | |
97 ++m_circularSequentialId; | |
98 if (m_circularSequentialId <= 0) | |
99 m_circularSequentialId = 1; | |
100 } while (m_asyncOperationCallChains.contains(m_circularSequentialId)); | |
101 return m_circularSequentialId; | |
102 } | |
103 | |
104 virtual void trace(Visitor* visitor) override | 93 virtual void trace(Visitor* visitor) override |
105 { | 94 { |
106 visitor->trace(m_tracker); | 95 visitor->trace(m_tracker); |
107 #if ENABLE(OILPAN) | 96 #if ENABLE(OILPAN) |
108 visitor->trace(m_timerCallChains); | 97 visitor->trace(m_timerCallChains); |
109 visitor->trace(m_animationFrameCallChains); | 98 visitor->trace(m_animationFrameCallChains); |
110 visitor->trace(m_eventCallChains); | 99 visitor->trace(m_eventCallChains); |
111 visitor->trace(m_xhrCallChains); | 100 visitor->trace(m_xhrCallChains); |
112 visitor->trace(m_mutationObserverCallChains); | 101 visitor->trace(m_mutationObserverCallChains); |
113 visitor->trace(m_executionContextTaskCallChains); | 102 visitor->trace(m_executionContextTaskCallChains); |
(...skipping 16 matching lines...) Expand all Loading... |
130 void disposeCallChains() | 119 void disposeCallChains() |
131 { | 120 { |
132 m_timerCallChains.dispose(); | 121 m_timerCallChains.dispose(); |
133 m_animationFrameCallChains.dispose(); | 122 m_animationFrameCallChains.dispose(); |
134 m_eventCallChains.dispose(); | 123 m_eventCallChains.dispose(); |
135 m_xhrCallChains.dispose(); | 124 m_xhrCallChains.dispose(); |
136 m_mutationObserverCallChains.dispose(); | 125 m_mutationObserverCallChains.dispose(); |
137 m_executionContextTaskCallChains.dispose(); | 126 m_executionContextTaskCallChains.dispose(); |
138 m_asyncOperationCallChains.dispose(); | 127 m_asyncOperationCallChains.dispose(); |
139 } | 128 } |
140 | |
141 int m_circularSequentialId; | |
142 }; | 129 }; |
143 | 130 |
144 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) | 131 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) |
145 { | 132 { |
146 const AtomicString& interfaceName = eventTarget->interfaceName(); | 133 const AtomicString& interfaceName = eventTarget->interfaceName(); |
147 if (interfaceName == EventTargetNames::XMLHttpRequest) | 134 if (interfaceName == EventTargetNames::XMLHttpRequest) |
148 return static_cast<XMLHttpRequest*>(eventTarget); | 135 return static_cast<XMLHttpRequest*>(eventTarget); |
149 if (interfaceName == EventTargetNames::XMLHttpRequestUpload) | 136 if (interfaceName == EventTargetNames::XMLHttpRequestUpload) |
150 return static_cast<XMLHttpRequestUpload*>(eventTarget)->xmlHttpRequest()
; | 137 return static_cast<XMLHttpRequestUpload*>(eventTarget)->xmlHttpRequest()
; |
151 return nullptr; | 138 return nullptr; |
(...skipping 19 matching lines...) Expand all Loading... |
171 { | 158 { |
172 for (auto& it : m_executionContextDataMap) | 159 for (auto& it : m_executionContextDataMap) |
173 it.value->unobserve(); | 160 it.value->unobserve(); |
174 m_executionContextDataMap.clear(); | 161 m_executionContextDataMap.clear(); |
175 } | 162 } |
176 | 163 |
177 void AsyncCallTracker::didInstallTimer(ExecutionContext* context, int timerId, i
nt timeout, bool singleShot) | 164 void AsyncCallTracker::didInstallTimer(ExecutionContext* context, int timerId, i
nt timeout, bool singleShot) |
178 { | 165 { |
179 ASSERT(context); | 166 ASSERT(context); |
180 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 167 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
181 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->traceAsyncOp
erationStarting(singleShot ? setTimeoutName : setIntervalName); | 168 int operationId = m_debuggerAgent->traceAsyncOperationStarting(singleShot ?
setTimeoutName : setIntervalName); |
182 if (!callChain) | |
183 return; | |
184 ASSERT(timerId > 0); | 169 ASSERT(timerId > 0); |
185 ExecutionContextData* data = createContextDataIfNeeded(context); | 170 ExecutionContextData* data = createContextDataIfNeeded(context); |
186 data->m_timerCallChains.set(timerId, callChain.release()); | 171 data->m_timerCallChains.set(timerId, operationId); |
187 if (!singleShot) | 172 if (!singleShot) |
188 data->m_intervalTimerIds.add(timerId); | 173 data->m_intervalTimerIds.add(timerId); |
189 } | 174 } |
190 | 175 |
191 void AsyncCallTracker::didRemoveTimer(ExecutionContext* context, int timerId) | 176 void AsyncCallTracker::didRemoveTimer(ExecutionContext* context, int timerId) |
192 { | 177 { |
193 ASSERT(context); | 178 ASSERT(context); |
194 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 179 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
195 if (timerId <= 0) | 180 if (timerId <= 0) |
196 return; | 181 return; |
197 ExecutionContextData* data = m_executionContextDataMap.get(context); | 182 ExecutionContextData* data = m_executionContextDataMap.get(context); |
198 if (!data) | 183 if (!data) |
199 return; | 184 return; |
200 data->m_intervalTimerIds.remove(timerId); | 185 data->m_intervalTimerIds.remove(timerId); |
201 data->m_timerCallChains.remove(timerId); | 186 data->m_timerCallChains.remove(timerId); |
202 } | 187 } |
203 | 188 |
204 bool AsyncCallTracker::willFireTimer(ExecutionContext* context, int timerId) | 189 bool AsyncCallTracker::willFireTimer(ExecutionContext* context, int timerId) |
205 { | 190 { |
206 ASSERT(context); | 191 ASSERT(context); |
207 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 192 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
208 ASSERT(timerId > 0); | 193 ASSERT(timerId > 0); |
209 ASSERT(!m_debuggerAgent->currentAsyncCallChain()); | 194 ASSERT(!m_debuggerAgent->currentAsyncCallChain()); |
210 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { | 195 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { |
211 setCurrentAsyncCallChain(context, data->m_timerCallChains.get(timerId)); | 196 setCurrentAsyncCallChain(context, data->m_timerCallChains.get(timerId)); |
212 if (!data->m_intervalTimerIds.contains(timerId)) | 197 if (!data->m_intervalTimerIds.contains(timerId)) |
213 data->m_timerCallChains.remove(timerId); | 198 data->m_timerCallChains.remove(timerId); |
214 } else { | 199 } else { |
215 setCurrentAsyncCallChain(context, nullptr); | 200 setCurrentAsyncCallChain(context, InspectorDebuggerAgent::unknownAsyncOp
erationId); |
216 } | 201 } |
217 return true; | 202 return true; |
218 } | 203 } |
219 | 204 |
220 void AsyncCallTracker::didRequestAnimationFrame(ExecutionContext* context, int c
allbackId) | 205 void AsyncCallTracker::didRequestAnimationFrame(ExecutionContext* context, int c
allbackId) |
221 { | 206 { |
222 ASSERT(context); | 207 ASSERT(context); |
223 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 208 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
224 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->traceAsyncOp
erationStarting(requestAnimationFrameName); | 209 int operationId = m_debuggerAgent->traceAsyncOperationStarting(requestAnimat
ionFrameName); |
225 if (!callChain) | |
226 return; | |
227 ASSERT(callbackId > 0); | 210 ASSERT(callbackId > 0); |
228 ExecutionContextData* data = createContextDataIfNeeded(context); | 211 ExecutionContextData* data = createContextDataIfNeeded(context); |
229 data->m_animationFrameCallChains.set(callbackId, callChain.release()); | 212 data->m_animationFrameCallChains.set(callbackId, operationId); |
230 } | 213 } |
231 | 214 |
232 void AsyncCallTracker::didCancelAnimationFrame(ExecutionContext* context, int ca
llbackId) | 215 void AsyncCallTracker::didCancelAnimationFrame(ExecutionContext* context, int ca
llbackId) |
233 { | 216 { |
234 ASSERT(context); | 217 ASSERT(context); |
235 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 218 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
236 if (callbackId <= 0) | 219 if (callbackId <= 0) |
237 return; | 220 return; |
238 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 221 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
239 data->m_animationFrameCallChains.remove(callbackId); | 222 data->m_animationFrameCallChains.remove(callbackId); |
240 } | 223 } |
241 | 224 |
242 bool AsyncCallTracker::willFireAnimationFrame(ExecutionContext* context, int cal
lbackId) | 225 bool AsyncCallTracker::willFireAnimationFrame(ExecutionContext* context, int cal
lbackId) |
243 { | 226 { |
244 ASSERT(context); | 227 ASSERT(context); |
245 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 228 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
246 ASSERT(callbackId > 0); | 229 ASSERT(callbackId > 0); |
247 ASSERT(!m_debuggerAgent->currentAsyncCallChain()); | 230 ASSERT(!m_debuggerAgent->currentAsyncCallChain()); |
248 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { | 231 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { |
249 setCurrentAsyncCallChain(context, data->m_animationFrameCallChains.get(c
allbackId)); | 232 setCurrentAsyncCallChain(context, data->m_animationFrameCallChains.get(c
allbackId)); |
250 data->m_animationFrameCallChains.remove(callbackId); | 233 data->m_animationFrameCallChains.remove(callbackId); |
251 } else { | 234 } else { |
252 setCurrentAsyncCallChain(context, nullptr); | 235 setCurrentAsyncCallChain(context, InspectorDebuggerAgent::unknownAsyncOp
erationId); |
253 } | 236 } |
254 return true; | 237 return true; |
255 } | 238 } |
256 | 239 |
257 void AsyncCallTracker::didEnqueueEvent(EventTarget* eventTarget, Event* event) | 240 void AsyncCallTracker::didEnqueueEvent(EventTarget* eventTarget, Event* event) |
258 { | 241 { |
259 ASSERT(eventTarget->executionContext()); | 242 ASSERT(eventTarget->executionContext()); |
260 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 243 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
261 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->traceAsyncOp
erationStarting(event->type()); | 244 int operationId = m_debuggerAgent->traceAsyncOperationStarting(event->type()
); |
262 if (!callChain) | |
263 return; | |
264 ExecutionContextData* data = createContextDataIfNeeded(eventTarget->executio
nContext()); | 245 ExecutionContextData* data = createContextDataIfNeeded(eventTarget->executio
nContext()); |
265 data->m_eventCallChains.set(event, callChain.release()); | 246 data->m_eventCallChains.set(event, operationId); |
266 } | 247 } |
267 | 248 |
268 void AsyncCallTracker::didRemoveEvent(EventTarget* eventTarget, Event* event) | 249 void AsyncCallTracker::didRemoveEvent(EventTarget* eventTarget, Event* event) |
269 { | 250 { |
270 ASSERT(eventTarget->executionContext()); | 251 ASSERT(eventTarget->executionContext()); |
271 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 252 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
272 if (ExecutionContextData* data = m_executionContextDataMap.get(eventTarget->
executionContext())) | 253 if (ExecutionContextData* data = m_executionContextDataMap.get(eventTarget->
executionContext())) |
273 data->m_eventCallChains.remove(event); | 254 data->m_eventCallChains.remove(event); |
274 } | 255 } |
275 | 256 |
276 void AsyncCallTracker::willHandleEvent(EventTarget* eventTarget, Event* event, E
ventListener* listener, bool useCapture) | 257 void AsyncCallTracker::willHandleEvent(EventTarget* eventTarget, Event* event, E
ventListener* listener, bool useCapture) |
277 { | 258 { |
278 ASSERT(eventTarget->executionContext()); | 259 ASSERT(eventTarget->executionContext()); |
279 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 260 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
280 if (XMLHttpRequest* xhr = toXmlHttpRequest(eventTarget)) { | 261 if (XMLHttpRequest* xhr = toXmlHttpRequest(eventTarget)) { |
281 willHandleXHREvent(xhr, event); | 262 willHandleXHREvent(xhr, event); |
282 } else { | 263 } else { |
283 ExecutionContext* context = eventTarget->executionContext(); | 264 ExecutionContext* context = eventTarget->executionContext(); |
284 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 265 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
285 setCurrentAsyncCallChain(context, data->m_eventCallChains.get(event)
); | 266 setCurrentAsyncCallChain(context, data->m_eventCallChains.get(event)
); |
286 else | 267 else |
287 setCurrentAsyncCallChain(context, nullptr); | 268 setCurrentAsyncCallChain(context, InspectorDebuggerAgent::unknownAsy
ncOperationId); |
288 } | 269 } |
289 } | 270 } |
290 | 271 |
291 void AsyncCallTracker::willLoadXHR(XMLHttpRequest* xhr, ThreadableLoaderClient*,
const AtomicString&, const KURL&, bool async, PassRefPtr<FormData>, const HTTPH
eaderMap&, bool) | 272 void AsyncCallTracker::willLoadXHR(XMLHttpRequest* xhr, ThreadableLoaderClient*,
const AtomicString&, const KURL&, bool async, PassRefPtr<FormData>, const HTTPH
eaderMap&, bool) |
292 { | 273 { |
293 ASSERT(xhr->executionContext()); | 274 ASSERT(xhr->executionContext()); |
294 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 275 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
295 if (!async) | 276 if (!async) |
296 return; | 277 return; |
297 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->traceAsyncOp
erationStarting(xhrSendName); | 278 int operationId = m_debuggerAgent->traceAsyncOperationStarting(xhrSendName); |
298 if (!callChain) | |
299 return; | |
300 ExecutionContextData* data = createContextDataIfNeeded(xhr->executionContext
()); | 279 ExecutionContextData* data = createContextDataIfNeeded(xhr->executionContext
()); |
301 data->m_xhrCallChains.set(xhr, callChain.release()); | 280 data->m_xhrCallChains.set(xhr, operationId); |
302 } | 281 } |
303 | 282 |
304 void AsyncCallTracker::didDispatchXHRLoadendEvent(XMLHttpRequest* xhr) | 283 void AsyncCallTracker::didDispatchXHRLoadendEvent(XMLHttpRequest* xhr) |
305 { | 284 { |
306 ASSERT(xhr->executionContext()); | 285 ASSERT(xhr->executionContext()); |
307 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 286 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
308 if (ExecutionContextData* data = m_executionContextDataMap.get(xhr->executio
nContext())) | 287 if (ExecutionContextData* data = m_executionContextDataMap.get(xhr->executio
nContext())) |
309 data->m_xhrCallChains.remove(xhr); | 288 data->m_xhrCallChains.remove(xhr); |
310 } | 289 } |
311 | 290 |
312 void AsyncCallTracker::willHandleXHREvent(XMLHttpRequest* xhr, Event* event) | 291 void AsyncCallTracker::willHandleXHREvent(XMLHttpRequest* xhr, Event* event) |
313 { | 292 { |
314 ExecutionContext* context = xhr->executionContext(); | 293 ExecutionContext* context = xhr->executionContext(); |
315 ASSERT(context); | 294 ASSERT(context); |
316 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 295 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
317 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 296 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
318 setCurrentAsyncCallChain(context, data->m_xhrCallChains.get(xhr)); | 297 setCurrentAsyncCallChain(context, data->m_xhrCallChains.get(xhr)); |
319 else | 298 else |
320 setCurrentAsyncCallChain(context, nullptr); | 299 setCurrentAsyncCallChain(context, InspectorDebuggerAgent::unknownAsyncOp
erationId); |
321 } | 300 } |
322 | 301 |
323 void AsyncCallTracker::didEnqueueMutationRecord(ExecutionContext* context, Mutat
ionObserver* observer) | 302 void AsyncCallTracker::didEnqueueMutationRecord(ExecutionContext* context, Mutat
ionObserver* observer) |
324 { | 303 { |
325 ASSERT(context); | 304 ASSERT(context); |
326 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 305 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
327 ExecutionContextData* data = createContextDataIfNeeded(context); | 306 ExecutionContextData* data = createContextDataIfNeeded(context); |
328 if (data->m_mutationObserverCallChains.contains(observer)) | 307 if (data->m_mutationObserverCallChains.contains(observer)) |
329 return; | 308 return; |
330 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->traceAsyncOp
erationStarting(enqueueMutationRecordName); | 309 int operationId = m_debuggerAgent->traceAsyncOperationStarting(enqueueMutati
onRecordName); |
331 if (!callChain) | 310 data->m_mutationObserverCallChains.set(observer, operationId); |
332 return; | |
333 data->m_mutationObserverCallChains.set(observer, callChain.release()); | |
334 } | 311 } |
335 | 312 |
336 void AsyncCallTracker::didClearAllMutationRecords(ExecutionContext* context, Mut
ationObserver* observer) | 313 void AsyncCallTracker::didClearAllMutationRecords(ExecutionContext* context, Mut
ationObserver* observer) |
337 { | 314 { |
338 ASSERT(context); | 315 ASSERT(context); |
339 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 316 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
340 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 317 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
341 data->m_mutationObserverCallChains.remove(observer); | 318 data->m_mutationObserverCallChains.remove(observer); |
342 } | 319 } |
343 | 320 |
344 void AsyncCallTracker::willDeliverMutationRecords(ExecutionContext* context, Mut
ationObserver* observer) | 321 void AsyncCallTracker::willDeliverMutationRecords(ExecutionContext* context, Mut
ationObserver* observer) |
345 { | 322 { |
346 ASSERT(context); | 323 ASSERT(context); |
347 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 324 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
348 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { | 325 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { |
349 setCurrentAsyncCallChain(context, data->m_mutationObserverCallChains.get
(observer)); | 326 setCurrentAsyncCallChain(context, data->m_mutationObserverCallChains.get
(observer)); |
350 data->m_mutationObserverCallChains.remove(observer); | 327 data->m_mutationObserverCallChains.remove(observer); |
351 } else { | 328 } else { |
352 setCurrentAsyncCallChain(context, nullptr); | 329 setCurrentAsyncCallChain(context, InspectorDebuggerAgent::unknownAsyncOp
erationId); |
353 } | 330 } |
354 } | 331 } |
355 | 332 |
356 void AsyncCallTracker::didPostExecutionContextTask(ExecutionContext* context, Ex
ecutionContextTask* task) | 333 void AsyncCallTracker::didPostExecutionContextTask(ExecutionContext* context, Ex
ecutionContextTask* task) |
357 { | 334 { |
358 ASSERT(context); | 335 ASSERT(context); |
359 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 336 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
360 if (task->taskNameForInstrumentation().isEmpty()) | 337 if (task->taskNameForInstrumentation().isEmpty()) |
361 return; | 338 return; |
362 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->traceAsyncOp
erationStarting(task->taskNameForInstrumentation()); | 339 int operationId = m_debuggerAgent->traceAsyncOperationStarting(task->taskNam
eForInstrumentation()); |
363 if (!callChain) | |
364 return; | |
365 ExecutionContextData* data = createContextDataIfNeeded(context); | 340 ExecutionContextData* data = createContextDataIfNeeded(context); |
366 data->m_executionContextTaskCallChains.set(task, callChain.release()); | 341 data->m_executionContextTaskCallChains.set(task, operationId); |
367 } | 342 } |
368 | 343 |
369 void AsyncCallTracker::didKillAllExecutionContextTasks(ExecutionContext* context
) | 344 void AsyncCallTracker::didKillAllExecutionContextTasks(ExecutionContext* context
) |
370 { | 345 { |
371 ASSERT(context); | 346 ASSERT(context); |
372 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 347 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
373 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 348 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
374 data->m_executionContextTaskCallChains.clear(); | 349 data->m_executionContextTaskCallChains.clear(); |
375 } | 350 } |
376 | 351 |
377 void AsyncCallTracker::willPerformExecutionContextTask(ExecutionContext* context
, ExecutionContextTask* task) | 352 void AsyncCallTracker::willPerformExecutionContextTask(ExecutionContext* context
, ExecutionContextTask* task) |
378 { | 353 { |
379 ASSERT(context); | 354 ASSERT(context); |
380 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 355 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
381 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { | 356 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { |
382 setCurrentAsyncCallChain(context, data->m_executionContextTaskCallChains
.get(task)); | 357 setCurrentAsyncCallChain(context, data->m_executionContextTaskCallChains
.get(task)); |
383 data->m_executionContextTaskCallChains.remove(task); | 358 data->m_executionContextTaskCallChains.remove(task); |
384 } else { | 359 } else { |
385 setCurrentAsyncCallChain(context, nullptr); | 360 setCurrentAsyncCallChain(context, InspectorDebuggerAgent::unknownAsyncOp
erationId); |
386 } | 361 } |
387 } | 362 } |
388 | 363 |
389 int AsyncCallTracker::traceAsyncOperationStarting(ExecutionContext* context, con
st String& operationName, int prevOperationId) | 364 int AsyncCallTracker::traceAsyncOperationStarting(ExecutionContext* context, con
st String& operationName, int prevOperationId) |
390 { | 365 { |
391 ASSERT(context); | 366 ASSERT(context); |
392 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 367 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
393 if (prevOperationId) | 368 if (prevOperationId) |
394 traceAsyncOperationCompleted(context, prevOperationId); | 369 traceAsyncOperationCompleted(context, prevOperationId); |
395 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->traceAsyncOp
erationStarting(operationName); | 370 int operationId = m_debuggerAgent->traceAsyncOperationStarting(operationName
); |
396 if (!callChain) | |
397 return 0; | |
398 ExecutionContextData* data = createContextDataIfNeeded(context); | 371 ExecutionContextData* data = createContextDataIfNeeded(context); |
399 int id = data->nextAsyncOperationUniqueId(); | 372 data->m_asyncOperationCallChains.set(operationId, operationId); |
400 data->m_asyncOperationCallChains.set(id, callChain.release()); | 373 return operationId; |
401 return id; | |
402 } | 374 } |
403 | 375 |
404 void AsyncCallTracker::traceAsyncOperationCompleted(ExecutionContext* context, i
nt operationId) | 376 void AsyncCallTracker::traceAsyncOperationCompleted(ExecutionContext* context, i
nt operationId) |
405 { | 377 { |
406 ASSERT(context); | 378 ASSERT(context); |
407 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 379 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
408 if (operationId <= 0) | 380 if (operationId <= 0) |
409 return; | 381 return; |
410 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 382 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
411 data->m_asyncOperationCallChains.remove(operationId); | 383 data->m_asyncOperationCallChains.remove(operationId); |
412 } | 384 } |
413 | 385 |
414 void AsyncCallTracker::traceAsyncOperationCompletedCallbackStarting(ExecutionCon
text* context, int operationId) | 386 void AsyncCallTracker::traceAsyncOperationCompletedCallbackStarting(ExecutionCon
text* context, int operationId) |
415 { | 387 { |
416 traceAsyncCallbackStarting(context, operationId); | 388 traceAsyncCallbackStarting(context, operationId); |
417 traceAsyncOperationCompleted(context, operationId); | 389 traceAsyncOperationCompleted(context, operationId); |
418 } | 390 } |
419 | 391 |
420 void AsyncCallTracker::traceAsyncCallbackStarting(ExecutionContext* context, int
operationId) | 392 void AsyncCallTracker::traceAsyncCallbackStarting(ExecutionContext* context, int
operationId) |
421 { | 393 { |
422 ASSERT(context); | 394 ASSERT(context); |
423 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 395 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
424 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 396 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
425 setCurrentAsyncCallChain(context, operationId > 0 ? data->m_asyncOperati
onCallChains.get(operationId) : nullptr); | 397 setCurrentAsyncCallChain(context, operationId > 0 ? data->m_asyncOperati
onCallChains.get(operationId) : InspectorDebuggerAgent::unknownAsyncOperationId)
; |
426 else | 398 else |
427 setCurrentAsyncCallChain(context, nullptr); | 399 setCurrentAsyncCallChain(context, InspectorDebuggerAgent::unknownAsyncOp
erationId); |
428 } | 400 } |
429 | 401 |
430 void AsyncCallTracker::didFireAsyncCall() | 402 void AsyncCallTracker::didFireAsyncCall() |
431 { | 403 { |
432 m_debuggerAgent->traceAsyncCallbackCompleted(); | 404 m_debuggerAgent->traceAsyncCallbackCompleted(); |
433 } | 405 } |
434 | 406 |
435 void AsyncCallTracker::setCurrentAsyncCallChain(ExecutionContext* context, PassR
efPtrWillBeRawPtr<AsyncCallChain> chain) | 407 void AsyncCallTracker::setCurrentAsyncCallChain(ExecutionContext* context, int o
perationId) |
436 { | 408 { |
437 m_debuggerAgent->traceAsyncCallbackStarting(toIsolate(context), chain); | 409 m_debuggerAgent->traceAsyncCallbackStarting(toIsolate(context), operationId)
; |
438 } | 410 } |
439 | 411 |
440 AsyncCallTracker::ExecutionContextData* AsyncCallTracker::createContextDataIfNee
ded(ExecutionContext* context) | 412 AsyncCallTracker::ExecutionContextData* AsyncCallTracker::createContextDataIfNee
ded(ExecutionContext* context) |
441 { | 413 { |
442 ExecutionContextData* data = m_executionContextDataMap.get(context); | 414 ExecutionContextData* data = m_executionContextDataMap.get(context); |
443 if (!data) { | 415 if (!data) { |
444 data = m_executionContextDataMap.set(context, adoptPtrWillBeNoop(new Asy
ncCallTracker::ExecutionContextData(this, context))) | 416 data = m_executionContextDataMap.set(context, adoptPtrWillBeNoop(new Asy
ncCallTracker::ExecutionContextData(this, context))) |
445 .storedValue->value.get(); | 417 .storedValue->value.get(); |
446 } | 418 } |
447 return data; | 419 return data; |
448 } | 420 } |
449 | 421 |
450 void AsyncCallTracker::trace(Visitor* visitor) | 422 void AsyncCallTracker::trace(Visitor* visitor) |
451 { | 423 { |
452 #if ENABLE(OILPAN) | 424 #if ENABLE(OILPAN) |
453 visitor->trace(m_executionContextDataMap); | 425 visitor->trace(m_executionContextDataMap); |
454 visitor->trace(m_debuggerAgent); | 426 visitor->trace(m_debuggerAgent); |
455 visitor->trace(m_instrumentingAgents); | 427 visitor->trace(m_instrumentingAgents); |
456 #endif | 428 #endif |
457 InspectorDebuggerAgent::AsyncCallTrackingListener::trace(visitor); | 429 InspectorDebuggerAgent::AsyncCallTrackingListener::trace(visitor); |
458 } | 430 } |
459 | 431 |
460 } // namespace blink | 432 } // namespace blink |
OLD | NEW |