| 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 18 matching lines...) Expand all Loading... |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "core/inspector/AsyncCallTracker.h" | 32 #include "core/inspector/AsyncCallTracker.h" |
| 33 | 33 |
| 34 #include "core/dom/ContextLifecycleObserver.h" | 34 #include "core/dom/ContextLifecycleObserver.h" |
| 35 #include "core/dom/ExecutionContext.h" | 35 #include "core/dom/ExecutionContext.h" |
| 36 #include "core/dom/ExecutionContextTask.h" | 36 #include "core/dom/ExecutionContextTask.h" |
| 37 #include "core/events/Event.h" | 37 #include "core/events/Event.h" |
| 38 #include "core/events/EventTarget.h" | 38 #include "core/events/EventTarget.h" |
| 39 #include "core/inspector/AsyncCallChain.h" | 39 #include "core/inspector/AsyncOperationMap.h" |
| 40 #include "core/inspector/AsyncCallChainMap.h" | |
| 41 #include "core/inspector/InspectorDebuggerAgent.h" | 40 #include "core/inspector/InspectorDebuggerAgent.h" |
| 42 #include "core/xmlhttprequest/XMLHttpRequest.h" | 41 #include "core/xmlhttprequest/XMLHttpRequest.h" |
| 43 #include "core/xmlhttprequest/XMLHttpRequestUpload.h" | 42 #include "core/xmlhttprequest/XMLHttpRequestUpload.h" |
| 44 #include "wtf/text/StringBuilder.h" | 43 #include "wtf/text/StringBuilder.h" |
| 45 #include "wtf/text/StringHash.h" | 44 #include "wtf/text/StringHash.h" |
| 46 #include <v8.h> | |
| 47 | 45 |
| 48 namespace { | 46 namespace { |
| 49 | 47 |
| 50 static const char setTimeoutName[] = "setTimeout"; | 48 static const char setTimeoutName[] = "setTimeout"; |
| 51 static const char setIntervalName[] = "setInterval"; | 49 static const char setIntervalName[] = "setInterval"; |
| 52 static const char requestAnimationFrameName[] = "requestAnimationFrame"; | 50 static const char requestAnimationFrameName[] = "requestAnimationFrame"; |
| 53 static const char xhrSendName[] = "XMLHttpRequest.send"; | 51 static const char xhrSendName[] = "XMLHttpRequest.send"; |
| 54 static const char enqueueMutationRecordName[] = "Mutation"; | 52 static const char enqueueMutationRecordName[] = "Mutation"; |
| 55 | 53 |
| 56 } | 54 } |
| 57 | 55 |
| 58 namespace blink { | 56 namespace blink { |
| 59 | 57 |
| 60 class AsyncCallTracker::ExecutionContextData final : public NoBaseWillBeGarbageC
ollectedFinalized<ExecutionContextData>, public ContextLifecycleObserver { | 58 class AsyncCallTracker::ExecutionContextData final : public NoBaseWillBeGarbageC
ollectedFinalized<ExecutionContextData>, public ContextLifecycleObserver { |
| 61 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AsyncCallTracker::ExecutionContextData
); | 59 WILL_BE_USING_GARBAGE_COLLECTED_MIXIN(AsyncCallTracker::ExecutionContextData
); |
| 62 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | 60 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; |
| 63 public: | 61 public: |
| 64 ExecutionContextData(AsyncCallTracker* tracker, ExecutionContext* executionC
ontext) | 62 ExecutionContextData(AsyncCallTracker* tracker, ExecutionContext* executionC
ontext) |
| 65 : ContextLifecycleObserver(executionContext) | 63 : ContextLifecycleObserver(executionContext) |
| 66 , m_tracker(tracker) | 64 , m_tracker(tracker) |
| 67 , m_timerCallChains(tracker->m_debuggerAgent) | 65 , m_timerCallChains(tracker->m_debuggerAgent) |
| 68 , m_animationFrameCallChains(tracker->m_debuggerAgent) | 66 , m_animationFrameCallChains(tracker->m_debuggerAgent) |
| 69 , m_eventCallChains(tracker->m_debuggerAgent) | 67 , m_eventCallChains(tracker->m_debuggerAgent) |
| 70 , m_xhrCallChains(tracker->m_debuggerAgent) | 68 , m_xhrCallChains(tracker->m_debuggerAgent) |
| 71 , m_mutationObserverCallChains(tracker->m_debuggerAgent) | 69 , m_mutationObserverCallChains(tracker->m_debuggerAgent) |
| 72 , m_executionContextTaskCallChains(tracker->m_debuggerAgent) | 70 , m_executionContextTaskCallChains(tracker->m_debuggerAgent) |
| 73 , m_asyncOperationCallChains(tracker->m_debuggerAgent) | 71 , m_asyncOperations(tracker->m_debuggerAgent) |
| 74 { | 72 { |
| 75 } | 73 } |
| 76 | 74 |
| 77 virtual void contextDestroyed() override | 75 virtual void contextDestroyed() override |
| 78 { | 76 { |
| 79 ASSERT(executionContext()); | 77 ASSERT(executionContext()); |
| 80 OwnPtrWillBeRawPtr<ExecutionContextData> self = m_tracker->m_executionCo
ntextDataMap.take(executionContext()); | 78 OwnPtrWillBeRawPtr<ExecutionContextData> self = m_tracker->m_executionCo
ntextDataMap.take(executionContext()); |
| 81 ASSERT_UNUSED(self, self == this); | 79 ASSERT_UNUSED(self, self == this); |
| 82 ContextLifecycleObserver::contextDestroyed(); | 80 ContextLifecycleObserver::contextDestroyed(); |
| 83 clearLifecycleContext(); | 81 clearLifecycleContext(); |
| 84 disposeCallChains(); | 82 disposeCallChains(); |
| 85 } | 83 } |
| 86 | 84 |
| 87 void unobserve() | 85 void unobserve() |
| 88 { | 86 { |
| 89 disposeCallChains(); | 87 disposeCallChains(); |
| 90 dispose(); | 88 dispose(); |
| 91 } | 89 } |
| 92 | 90 |
| 93 virtual void trace(Visitor* visitor) override | 91 virtual void trace(Visitor* visitor) override |
| 94 { | 92 { |
| 95 visitor->trace(m_tracker); | 93 visitor->trace(m_tracker); |
| 96 #if ENABLE(OILPAN) | 94 #if ENABLE(OILPAN) |
| 97 visitor->trace(m_timerCallChains); | 95 visitor->trace(m_timerCallChains); |
| 98 visitor->trace(m_animationFrameCallChains); | 96 visitor->trace(m_animationFrameCallChains); |
| 99 visitor->trace(m_eventCallChains); | 97 visitor->trace(m_eventCallChains); |
| 100 visitor->trace(m_xhrCallChains); | 98 visitor->trace(m_xhrCallChains); |
| 101 visitor->trace(m_mutationObserverCallChains); | 99 visitor->trace(m_mutationObserverCallChains); |
| 102 visitor->trace(m_executionContextTaskCallChains); | 100 visitor->trace(m_executionContextTaskCallChains); |
| 103 visitor->trace(m_asyncOperationCallChains); | 101 visitor->trace(m_asyncOperations); |
| 104 #endif | 102 #endif |
| 105 ContextLifecycleObserver::trace(visitor); | 103 ContextLifecycleObserver::trace(visitor); |
| 106 } | 104 } |
| 107 | 105 |
| 108 RawPtrWillBeMember<AsyncCallTracker> m_tracker; | 106 RawPtrWillBeMember<AsyncCallTracker> m_tracker; |
| 109 HashSet<int> m_intervalTimerIds; | 107 HashSet<int> m_intervalTimerIds; |
| 110 AsyncCallChainMap<int> m_timerCallChains; | 108 AsyncOperationMap<int> m_timerCallChains; |
| 111 AsyncCallChainMap<int> m_animationFrameCallChains; | 109 AsyncOperationMap<int> m_animationFrameCallChains; |
| 112 AsyncCallChainMap<RawPtrWillBeMember<Event> > m_eventCallChains; | 110 AsyncOperationMap<RawPtrWillBeMember<Event> > m_eventCallChains; |
| 113 AsyncCallChainMap<RawPtrWillBeMember<EventTarget> > m_xhrCallChains; | 111 AsyncOperationMap<RawPtrWillBeMember<EventTarget> > m_xhrCallChains; |
| 114 AsyncCallChainMap<RawPtrWillBeMember<MutationObserver> > m_mutationObserverC
allChains; | 112 AsyncOperationMap<RawPtrWillBeMember<MutationObserver> > m_mutationObserverC
allChains; |
| 115 AsyncCallChainMap<ExecutionContextTask*> m_executionContextTaskCallChains; | 113 AsyncOperationMap<ExecutionContextTask*> m_executionContextTaskCallChains; |
| 116 AsyncCallChainMap<int> m_asyncOperationCallChains; | 114 AsyncOperationMap<int> m_asyncOperations; |
| 117 | 115 |
| 118 private: | 116 private: |
| 119 void disposeCallChains() | 117 void disposeCallChains() |
| 120 { | 118 { |
| 121 m_timerCallChains.dispose(); | 119 m_timerCallChains.dispose(); |
| 122 m_animationFrameCallChains.dispose(); | 120 m_animationFrameCallChains.dispose(); |
| 123 m_eventCallChains.dispose(); | 121 m_eventCallChains.dispose(); |
| 124 m_xhrCallChains.dispose(); | 122 m_xhrCallChains.dispose(); |
| 125 m_mutationObserverCallChains.dispose(); | 123 m_mutationObserverCallChains.dispose(); |
| 126 m_executionContextTaskCallChains.dispose(); | 124 m_executionContextTaskCallChains.dispose(); |
| 127 m_asyncOperationCallChains.dispose(); | 125 m_asyncOperations.dispose(); |
| 128 } | 126 } |
| 129 }; | 127 }; |
| 130 | 128 |
| 131 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) | 129 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) |
| 132 { | 130 { |
| 133 const AtomicString& interfaceName = eventTarget->interfaceName(); | 131 const AtomicString& interfaceName = eventTarget->interfaceName(); |
| 134 if (interfaceName == EventTargetNames::XMLHttpRequest) | 132 if (interfaceName == EventTargetNames::XMLHttpRequest) |
| 135 return static_cast<XMLHttpRequest*>(eventTarget); | 133 return static_cast<XMLHttpRequest*>(eventTarget); |
| 136 if (interfaceName == EventTargetNames::XMLHttpRequestUpload) | 134 if (interfaceName == EventTargetNames::XMLHttpRequestUpload) |
| 137 return static_cast<XMLHttpRequestUpload*>(eventTarget)->xmlHttpRequest()
; | 135 return static_cast<XMLHttpRequestUpload*>(eventTarget)->xmlHttpRequest()
; |
| 138 return nullptr; | 136 return nullptr; |
| 139 } | 137 } |
| 140 | 138 |
| 141 AsyncCallTracker::AsyncCallTracker(InspectorDebuggerAgent* debuggerAgent, Instru
mentingAgents* instrumentingAgents) | 139 AsyncCallTracker::AsyncCallTracker(InspectorDebuggerAgent* debuggerAgent, Instru
mentingAgents* instrumentingAgents) |
| 142 : m_debuggerAgent(debuggerAgent) | 140 : m_debuggerAgent(debuggerAgent) |
| 143 , m_instrumentingAgents(instrumentingAgents) | 141 , m_instrumentingAgents(instrumentingAgents) |
| 144 { | 142 { |
| 145 m_debuggerAgent->addAsyncCallTrackingListener(this); | 143 m_debuggerAgent->addAsyncCallTrackingListener(this); |
| 146 } | 144 } |
| 147 | 145 |
| 148 AsyncCallTracker::~AsyncCallTracker() | 146 AsyncCallTracker::~AsyncCallTracker() |
| 149 { | 147 { |
| 150 } | 148 } |
| 151 | 149 |
| 152 void AsyncCallTracker::asyncCallTrackingStateChanged(bool tracking) | 150 void AsyncCallTracker::asyncCallTrackingStateChanged(bool tracking) |
| 153 { | 151 { |
| 154 m_instrumentingAgents->setAsyncCallTracker(tracking ? this : nullptr); | 152 m_instrumentingAgents->setAsyncCallTracker(tracking ? this : nullptr); |
| 155 } | 153 } |
| 156 | 154 |
| 157 void AsyncCallTracker::resetAsyncCallChains() | 155 void AsyncCallTracker::resetAsyncOperations() |
| 158 { | 156 { |
| 159 for (auto& it : m_executionContextDataMap) | 157 for (auto& it : m_executionContextDataMap) |
| 160 it.value->unobserve(); | 158 it.value->unobserve(); |
| 161 m_executionContextDataMap.clear(); | 159 m_executionContextDataMap.clear(); |
| 162 } | 160 } |
| 163 | 161 |
| 164 void AsyncCallTracker::didInstallTimer(ExecutionContext* context, int timerId, i
nt timeout, bool singleShot) | 162 void AsyncCallTracker::didInstallTimer(ExecutionContext* context, int timerId, i
nt timeout, bool singleShot) |
| 165 { | 163 { |
| 166 ASSERT(context); | 164 ASSERT(context); |
| 167 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 165 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 186 data->m_timerCallChains.remove(timerId); | 184 data->m_timerCallChains.remove(timerId); |
| 187 } | 185 } |
| 188 | 186 |
| 189 bool AsyncCallTracker::willFireTimer(ExecutionContext* context, int timerId) | 187 bool AsyncCallTracker::willFireTimer(ExecutionContext* context, int timerId) |
| 190 { | 188 { |
| 191 ASSERT(context); | 189 ASSERT(context); |
| 192 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 190 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 193 ASSERT(timerId > 0); | 191 ASSERT(timerId > 0); |
| 194 ASSERT(!m_debuggerAgent->currentAsyncCallChain()); | 192 ASSERT(!m_debuggerAgent->currentAsyncCallChain()); |
| 195 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { | 193 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { |
| 196 setCurrentAsyncCallChain(context, data->m_timerCallChains.get(timerId)); | 194 willFireAsyncCall(data->m_timerCallChains.get(timerId)); |
| 197 if (!data->m_intervalTimerIds.contains(timerId)) | 195 if (!data->m_intervalTimerIds.contains(timerId)) |
| 198 data->m_timerCallChains.remove(timerId); | 196 data->m_timerCallChains.remove(timerId); |
| 199 } else { | 197 } else { |
| 200 setCurrentAsyncCallChain(context, InspectorDebuggerAgent::unknownAsyncOp
erationId); | 198 willFireAsyncCall(InspectorDebuggerAgent::unknownAsyncOperationId); |
| 201 } | 199 } |
| 202 return true; | 200 return true; |
| 203 } | 201 } |
| 204 | 202 |
| 205 void AsyncCallTracker::didRequestAnimationFrame(ExecutionContext* context, int c
allbackId) | 203 void AsyncCallTracker::didRequestAnimationFrame(ExecutionContext* context, int c
allbackId) |
| 206 { | 204 { |
| 207 ASSERT(context); | 205 ASSERT(context); |
| 208 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 206 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 209 int operationId = m_debuggerAgent->traceAsyncOperationStarting(requestAnimat
ionFrameName); | 207 int operationId = m_debuggerAgent->traceAsyncOperationStarting(requestAnimat
ionFrameName); |
| 210 ASSERT(callbackId > 0); | 208 ASSERT(callbackId > 0); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 222 data->m_animationFrameCallChains.remove(callbackId); | 220 data->m_animationFrameCallChains.remove(callbackId); |
| 223 } | 221 } |
| 224 | 222 |
| 225 bool AsyncCallTracker::willFireAnimationFrame(ExecutionContext* context, int cal
lbackId) | 223 bool AsyncCallTracker::willFireAnimationFrame(ExecutionContext* context, int cal
lbackId) |
| 226 { | 224 { |
| 227 ASSERT(context); | 225 ASSERT(context); |
| 228 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 226 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 229 ASSERT(callbackId > 0); | 227 ASSERT(callbackId > 0); |
| 230 ASSERT(!m_debuggerAgent->currentAsyncCallChain()); | 228 ASSERT(!m_debuggerAgent->currentAsyncCallChain()); |
| 231 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { | 229 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { |
| 232 setCurrentAsyncCallChain(context, data->m_animationFrameCallChains.get(c
allbackId)); | 230 willFireAsyncCall(data->m_animationFrameCallChains.get(callbackId)); |
| 233 data->m_animationFrameCallChains.remove(callbackId); | 231 data->m_animationFrameCallChains.remove(callbackId); |
| 234 } else { | 232 } else { |
| 235 setCurrentAsyncCallChain(context, InspectorDebuggerAgent::unknownAsyncOp
erationId); | 233 willFireAsyncCall(InspectorDebuggerAgent::unknownAsyncOperationId); |
| 236 } | 234 } |
| 237 return true; | 235 return true; |
| 238 } | 236 } |
| 239 | 237 |
| 240 void AsyncCallTracker::didEnqueueEvent(EventTarget* eventTarget, Event* event) | 238 void AsyncCallTracker::didEnqueueEvent(EventTarget* eventTarget, Event* event) |
| 241 { | 239 { |
| 242 ASSERT(eventTarget->executionContext()); | 240 ASSERT(eventTarget->executionContext()); |
| 243 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 241 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 244 int operationId = m_debuggerAgent->traceAsyncOperationStarting(event->type()
); | 242 int operationId = m_debuggerAgent->traceAsyncOperationStarting(event->type()
); |
| 245 ExecutionContextData* data = createContextDataIfNeeded(eventTarget->executio
nContext()); | 243 ExecutionContextData* data = createContextDataIfNeeded(eventTarget->executio
nContext()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 256 | 254 |
| 257 void AsyncCallTracker::willHandleEvent(EventTarget* eventTarget, Event* event, E
ventListener* listener, bool useCapture) | 255 void AsyncCallTracker::willHandleEvent(EventTarget* eventTarget, Event* event, E
ventListener* listener, bool useCapture) |
| 258 { | 256 { |
| 259 ASSERT(eventTarget->executionContext()); | 257 ASSERT(eventTarget->executionContext()); |
| 260 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 258 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 261 if (XMLHttpRequest* xhr = toXmlHttpRequest(eventTarget)) { | 259 if (XMLHttpRequest* xhr = toXmlHttpRequest(eventTarget)) { |
| 262 willHandleXHREvent(xhr, event); | 260 willHandleXHREvent(xhr, event); |
| 263 } else { | 261 } else { |
| 264 ExecutionContext* context = eventTarget->executionContext(); | 262 ExecutionContext* context = eventTarget->executionContext(); |
| 265 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 263 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
| 266 setCurrentAsyncCallChain(context, data->m_eventCallChains.get(event)
); | 264 willFireAsyncCall(data->m_eventCallChains.get(event)); |
| 267 else | 265 else |
| 268 setCurrentAsyncCallChain(context, InspectorDebuggerAgent::unknownAsy
ncOperationId); | 266 willFireAsyncCall(InspectorDebuggerAgent::unknownAsyncOperationId); |
| 269 } | 267 } |
| 270 } | 268 } |
| 271 | 269 |
| 272 void AsyncCallTracker::willLoadXHR(XMLHttpRequest* xhr, ThreadableLoaderClient*,
const AtomicString&, const KURL&, bool async, PassRefPtr<FormData>, const HTTPH
eaderMap&, bool) | 270 void AsyncCallTracker::willLoadXHR(XMLHttpRequest* xhr, ThreadableLoaderClient*,
const AtomicString&, const KURL&, bool async, PassRefPtr<FormData>, const HTTPH
eaderMap&, bool) |
| 273 { | 271 { |
| 274 ASSERT(xhr->executionContext()); | 272 ASSERT(xhr->executionContext()); |
| 275 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 273 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 276 if (!async) | 274 if (!async) |
| 277 return; | 275 return; |
| 278 int operationId = m_debuggerAgent->traceAsyncOperationStarting(xhrSendName); | 276 int operationId = m_debuggerAgent->traceAsyncOperationStarting(xhrSendName); |
| 279 ExecutionContextData* data = createContextDataIfNeeded(xhr->executionContext
()); | 277 ExecutionContextData* data = createContextDataIfNeeded(xhr->executionContext
()); |
| 280 data->m_xhrCallChains.set(xhr, operationId); | 278 data->m_xhrCallChains.set(xhr, operationId); |
| 281 } | 279 } |
| 282 | 280 |
| 283 void AsyncCallTracker::didDispatchXHRLoadendEvent(XMLHttpRequest* xhr) | 281 void AsyncCallTracker::didDispatchXHRLoadendEvent(XMLHttpRequest* xhr) |
| 284 { | 282 { |
| 285 ASSERT(xhr->executionContext()); | 283 ASSERT(xhr->executionContext()); |
| 286 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 284 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 287 if (ExecutionContextData* data = m_executionContextDataMap.get(xhr->executio
nContext())) | 285 if (ExecutionContextData* data = m_executionContextDataMap.get(xhr->executio
nContext())) |
| 288 data->m_xhrCallChains.remove(xhr); | 286 data->m_xhrCallChains.remove(xhr); |
| 289 } | 287 } |
| 290 | 288 |
| 291 void AsyncCallTracker::willHandleXHREvent(XMLHttpRequest* xhr, Event* event) | 289 void AsyncCallTracker::willHandleXHREvent(XMLHttpRequest* xhr, Event* event) |
| 292 { | 290 { |
| 293 ExecutionContext* context = xhr->executionContext(); | 291 ExecutionContext* context = xhr->executionContext(); |
| 294 ASSERT(context); | 292 ASSERT(context); |
| 295 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 293 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 296 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 294 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
| 297 setCurrentAsyncCallChain(context, data->m_xhrCallChains.get(xhr)); | 295 willFireAsyncCall(data->m_xhrCallChains.get(xhr)); |
| 298 else | 296 else |
| 299 setCurrentAsyncCallChain(context, InspectorDebuggerAgent::unknownAsyncOp
erationId); | 297 willFireAsyncCall(InspectorDebuggerAgent::unknownAsyncOperationId); |
| 300 } | 298 } |
| 301 | 299 |
| 302 void AsyncCallTracker::didEnqueueMutationRecord(ExecutionContext* context, Mutat
ionObserver* observer) | 300 void AsyncCallTracker::didEnqueueMutationRecord(ExecutionContext* context, Mutat
ionObserver* observer) |
| 303 { | 301 { |
| 304 ASSERT(context); | 302 ASSERT(context); |
| 305 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 303 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 306 ExecutionContextData* data = createContextDataIfNeeded(context); | 304 ExecutionContextData* data = createContextDataIfNeeded(context); |
| 307 if (data->m_mutationObserverCallChains.contains(observer)) | 305 if (data->m_mutationObserverCallChains.contains(observer)) |
| 308 return; | 306 return; |
| 309 int operationId = m_debuggerAgent->traceAsyncOperationStarting(enqueueMutati
onRecordName); | 307 int operationId = m_debuggerAgent->traceAsyncOperationStarting(enqueueMutati
onRecordName); |
| 310 data->m_mutationObserverCallChains.set(observer, operationId); | 308 data->m_mutationObserverCallChains.set(observer, operationId); |
| 311 } | 309 } |
| 312 | 310 |
| 313 void AsyncCallTracker::didClearAllMutationRecords(ExecutionContext* context, Mut
ationObserver* observer) | 311 void AsyncCallTracker::didClearAllMutationRecords(ExecutionContext* context, Mut
ationObserver* observer) |
| 314 { | 312 { |
| 315 ASSERT(context); | 313 ASSERT(context); |
| 316 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 314 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 317 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 315 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
| 318 data->m_mutationObserverCallChains.remove(observer); | 316 data->m_mutationObserverCallChains.remove(observer); |
| 319 } | 317 } |
| 320 | 318 |
| 321 void AsyncCallTracker::willDeliverMutationRecords(ExecutionContext* context, Mut
ationObserver* observer) | 319 void AsyncCallTracker::willDeliverMutationRecords(ExecutionContext* context, Mut
ationObserver* observer) |
| 322 { | 320 { |
| 323 ASSERT(context); | 321 ASSERT(context); |
| 324 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 322 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 325 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { | 323 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { |
| 326 setCurrentAsyncCallChain(context, data->m_mutationObserverCallChains.get
(observer)); | 324 willFireAsyncCall(data->m_mutationObserverCallChains.get(observer)); |
| 327 data->m_mutationObserverCallChains.remove(observer); | 325 data->m_mutationObserverCallChains.remove(observer); |
| 328 } else { | 326 } else { |
| 329 setCurrentAsyncCallChain(context, InspectorDebuggerAgent::unknownAsyncOp
erationId); | 327 willFireAsyncCall(InspectorDebuggerAgent::unknownAsyncOperationId); |
| 330 } | 328 } |
| 331 } | 329 } |
| 332 | 330 |
| 333 void AsyncCallTracker::didPostExecutionContextTask(ExecutionContext* context, Ex
ecutionContextTask* task) | 331 void AsyncCallTracker::didPostExecutionContextTask(ExecutionContext* context, Ex
ecutionContextTask* task) |
| 334 { | 332 { |
| 335 ASSERT(context); | 333 ASSERT(context); |
| 336 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 334 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 337 if (task->taskNameForInstrumentation().isEmpty()) | 335 if (task->taskNameForInstrumentation().isEmpty()) |
| 338 return; | 336 return; |
| 339 int operationId = m_debuggerAgent->traceAsyncOperationStarting(task->taskNam
eForInstrumentation()); | 337 int operationId = m_debuggerAgent->traceAsyncOperationStarting(task->taskNam
eForInstrumentation()); |
| 340 ExecutionContextData* data = createContextDataIfNeeded(context); | 338 ExecutionContextData* data = createContextDataIfNeeded(context); |
| 341 data->m_executionContextTaskCallChains.set(task, operationId); | 339 data->m_executionContextTaskCallChains.set(task, operationId); |
| 342 } | 340 } |
| 343 | 341 |
| 344 void AsyncCallTracker::didKillAllExecutionContextTasks(ExecutionContext* context
) | 342 void AsyncCallTracker::didKillAllExecutionContextTasks(ExecutionContext* context
) |
| 345 { | 343 { |
| 346 ASSERT(context); | 344 ASSERT(context); |
| 347 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 345 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 348 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 346 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
| 349 data->m_executionContextTaskCallChains.clear(); | 347 data->m_executionContextTaskCallChains.clear(); |
| 350 } | 348 } |
| 351 | 349 |
| 352 void AsyncCallTracker::willPerformExecutionContextTask(ExecutionContext* context
, ExecutionContextTask* task) | 350 void AsyncCallTracker::willPerformExecutionContextTask(ExecutionContext* context
, ExecutionContextTask* task) |
| 353 { | 351 { |
| 354 ASSERT(context); | 352 ASSERT(context); |
| 355 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 353 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 356 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { | 354 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { |
| 357 setCurrentAsyncCallChain(context, data->m_executionContextTaskCallChains
.get(task)); | 355 willFireAsyncCall(data->m_executionContextTaskCallChains.get(task)); |
| 358 data->m_executionContextTaskCallChains.remove(task); | 356 data->m_executionContextTaskCallChains.remove(task); |
| 359 } else { | 357 } else { |
| 360 setCurrentAsyncCallChain(context, InspectorDebuggerAgent::unknownAsyncOp
erationId); | 358 willFireAsyncCall(InspectorDebuggerAgent::unknownAsyncOperationId); |
| 361 } | 359 } |
| 362 } | 360 } |
| 363 | 361 |
| 364 int AsyncCallTracker::traceAsyncOperationStarting(ExecutionContext* context, con
st String& operationName, int prevOperationId) | 362 int AsyncCallTracker::traceAsyncOperationStarting(ExecutionContext* context, con
st String& operationName, int prevOperationId) |
| 365 { | 363 { |
| 366 ASSERT(context); | 364 ASSERT(context); |
| 367 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 365 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 368 if (prevOperationId) | 366 if (prevOperationId) |
| 369 traceAsyncOperationCompleted(context, prevOperationId); | 367 traceAsyncOperationCompleted(context, prevOperationId); |
| 370 int operationId = m_debuggerAgent->traceAsyncOperationStarting(operationName
); | 368 int operationId = m_debuggerAgent->traceAsyncOperationStarting(operationName
); |
| 371 ExecutionContextData* data = createContextDataIfNeeded(context); | 369 ExecutionContextData* data = createContextDataIfNeeded(context); |
| 372 data->m_asyncOperationCallChains.set(operationId, operationId); | 370 data->m_asyncOperations.set(operationId, operationId); |
| 373 return operationId; | 371 return operationId; |
| 374 } | 372 } |
| 375 | 373 |
| 376 void AsyncCallTracker::traceAsyncOperationCompleted(ExecutionContext* context, i
nt operationId) | 374 void AsyncCallTracker::traceAsyncOperationCompleted(ExecutionContext* context, i
nt operationId) |
| 377 { | 375 { |
| 378 ASSERT(context); | 376 ASSERT(context); |
| 379 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 377 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 380 if (operationId <= 0) | 378 if (operationId <= 0) |
| 381 return; | 379 return; |
| 382 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 380 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
| 383 data->m_asyncOperationCallChains.remove(operationId); | 381 data->m_asyncOperations.remove(operationId); |
| 384 } | 382 } |
| 385 | 383 |
| 386 void AsyncCallTracker::traceAsyncOperationCompletedCallbackStarting(ExecutionCon
text* context, int operationId) | 384 void AsyncCallTracker::traceAsyncOperationCompletedCallbackStarting(ExecutionCon
text* context, int operationId) |
| 387 { | 385 { |
| 388 traceAsyncCallbackStarting(context, operationId); | 386 traceAsyncCallbackStarting(context, operationId); |
| 389 traceAsyncOperationCompleted(context, operationId); | 387 traceAsyncOperationCompleted(context, operationId); |
| 390 } | 388 } |
| 391 | 389 |
| 390 bool AsyncCallTracker::isKnownAsyncOperationId(ExecutionContext* context, int op
erationId) const |
| 391 { |
| 392 if (operationId <= 0) |
| 393 return false; |
| 394 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
| 395 return data->m_asyncOperations.contains(operationId); |
| 396 return false; |
| 397 } |
| 398 |
| 392 void AsyncCallTracker::traceAsyncCallbackStarting(ExecutionContext* context, int
operationId) | 399 void AsyncCallTracker::traceAsyncCallbackStarting(ExecutionContext* context, int
operationId) |
| 393 { | 400 { |
| 394 ASSERT(context); | 401 ASSERT(context); |
| 395 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 402 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
| 396 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 403 ASSERT(operationId <= 0 || isKnownAsyncOperationId(context, operationId)); |
| 397 setCurrentAsyncCallChain(context, operationId > 0 ? data->m_asyncOperati
onCallChains.get(operationId) : InspectorDebuggerAgent::unknownAsyncOperationId)
; | 404 willFireAsyncCall(operationId > 0 ? operationId : InspectorDebuggerAgent::un
knownAsyncOperationId); |
| 398 else | |
| 399 setCurrentAsyncCallChain(context, InspectorDebuggerAgent::unknownAsyncOp
erationId); | |
| 400 } | 405 } |
| 401 | 406 |
| 402 void AsyncCallTracker::didFireAsyncCall() | 407 void AsyncCallTracker::didFireAsyncCall() |
| 403 { | 408 { |
| 404 m_debuggerAgent->traceAsyncCallbackCompleted(); | 409 m_debuggerAgent->traceAsyncCallbackCompleted(); |
| 405 } | 410 } |
| 406 | 411 |
| 407 void AsyncCallTracker::setCurrentAsyncCallChain(ExecutionContext* context, int o
perationId) | 412 void AsyncCallTracker::willFireAsyncCall(int operationId) |
| 408 { | 413 { |
| 409 m_debuggerAgent->traceAsyncCallbackStarting(toIsolate(context), operationId)
; | 414 m_debuggerAgent->traceAsyncCallbackStarting(operationId); |
| 410 } | 415 } |
| 411 | 416 |
| 412 AsyncCallTracker::ExecutionContextData* AsyncCallTracker::createContextDataIfNee
ded(ExecutionContext* context) | 417 AsyncCallTracker::ExecutionContextData* AsyncCallTracker::createContextDataIfNee
ded(ExecutionContext* context) |
| 413 { | 418 { |
| 414 ExecutionContextData* data = m_executionContextDataMap.get(context); | 419 ExecutionContextData* data = m_executionContextDataMap.get(context); |
| 415 if (!data) { | 420 if (!data) { |
| 416 data = m_executionContextDataMap.set(context, adoptPtrWillBeNoop(new Asy
ncCallTracker::ExecutionContextData(this, context))) | 421 data = m_executionContextDataMap.set(context, adoptPtrWillBeNoop(new Asy
ncCallTracker::ExecutionContextData(this, context))) |
| 417 .storedValue->value.get(); | 422 .storedValue->value.get(); |
| 418 } | 423 } |
| 419 return data; | 424 return data; |
| 420 } | 425 } |
| 421 | 426 |
| 422 void AsyncCallTracker::trace(Visitor* visitor) | 427 void AsyncCallTracker::trace(Visitor* visitor) |
| 423 { | 428 { |
| 424 #if ENABLE(OILPAN) | 429 #if ENABLE(OILPAN) |
| 425 visitor->trace(m_executionContextDataMap); | 430 visitor->trace(m_executionContextDataMap); |
| 426 visitor->trace(m_debuggerAgent); | 431 visitor->trace(m_debuggerAgent); |
| 427 visitor->trace(m_instrumentingAgents); | 432 visitor->trace(m_instrumentingAgents); |
| 428 #endif | 433 #endif |
| 429 InspectorDebuggerAgent::AsyncCallTrackingListener::trace(visitor); | 434 InspectorDebuggerAgent::AsyncCallTrackingListener::trace(visitor); |
| 430 } | 435 } |
| 431 | 436 |
| 432 } // namespace blink | 437 } // namespace blink |
| OLD | NEW |