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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 ASSERT(self == this); | 69 ASSERT(self == this); |
70 ContextLifecycleObserver::contextDestroyed(); | 70 ContextLifecycleObserver::contextDestroyed(); |
71 delete self; | 71 delete self; |
72 } | 72 } |
73 | 73 |
74 public: | 74 public: |
75 AsyncCallStackTracker* m_tracker; | 75 AsyncCallStackTracker* m_tracker; |
76 HashSet<int> m_intervalTimerIds; | 76 HashSet<int> m_intervalTimerIds; |
77 HashMap<int, RefPtr<AsyncCallChain> > m_timerCallChains; | 77 HashMap<int, RefPtr<AsyncCallChain> > m_timerCallChains; |
78 HashMap<int, RefPtr<AsyncCallChain> > m_animationFrameCallChains; | 78 HashMap<int, RefPtr<AsyncCallChain> > m_animationFrameCallChains; |
| 79 HashMap<Event*, RefPtr<AsyncCallChain> > m_eventCallChains; |
79 HashMap<EventTarget*, RefPtr<AsyncCallChain> > m_xhrCallChains; | 80 HashMap<EventTarget*, RefPtr<AsyncCallChain> > m_xhrCallChains; |
80 HashMap<MutationObserver*, RefPtr<AsyncCallChain> > m_mutationObserverCallCh
ains; | 81 HashMap<MutationObserver*, RefPtr<AsyncCallChain> > m_mutationObserverCallCh
ains; |
81 }; | 82 }; |
82 | 83 |
83 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) | 84 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) |
84 { | 85 { |
85 const AtomicString& interfaceName = eventTarget->interfaceName(); | 86 const AtomicString& interfaceName = eventTarget->interfaceName(); |
86 if (interfaceName == EventTargetNames::XMLHttpRequest) | 87 if (interfaceName == EventTargetNames::XMLHttpRequest) |
87 return static_cast<XMLHttpRequest*>(eventTarget); | 88 return static_cast<XMLHttpRequest*>(eventTarget); |
88 if (interfaceName == EventTargetNames::XMLHttpRequestUpload) | 89 if (interfaceName == EventTargetNames::XMLHttpRequestUpload) |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 ASSERT(context); | 191 ASSERT(context); |
191 ASSERT(isEnabled()); | 192 ASSERT(isEnabled()); |
192 ASSERT(callbackId > 0); | 193 ASSERT(callbackId > 0); |
193 ASSERT(!m_currentAsyncCallChain); | 194 ASSERT(!m_currentAsyncCallChain); |
194 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) | 195 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) |
195 setCurrentAsyncCallChain(data->m_animationFrameCallChains.take(callbackI
d)); | 196 setCurrentAsyncCallChain(data->m_animationFrameCallChains.take(callbackI
d)); |
196 else | 197 else |
197 setCurrentAsyncCallChain(nullptr); | 198 setCurrentAsyncCallChain(nullptr); |
198 } | 199 } |
199 | 200 |
200 void AsyncCallStackTracker::willHandleEvent(EventTarget* eventTarget, const Atom
icString& eventType, EventListener* listener, bool useCapture) | 201 void AsyncCallStackTracker::didEnqueueEvent(EventTarget* eventTarget, Event* eve
nt, const ScriptValue& callFrames) |
201 { | 202 { |
202 ASSERT(eventTarget->executionContext()); | 203 ASSERT(eventTarget->executionContext()); |
203 ASSERT(isEnabled()); | 204 ASSERT(isEnabled()); |
204 if (XMLHttpRequest* xhr = toXmlHttpRequest(eventTarget)) | 205 if (!validateCallFrames(callFrames)) |
205 willHandleXHREvent(xhr, eventTarget, eventType); | 206 return; |
206 else | 207 ExecutionContextData* data = createContextDataIfNeeded(eventTarget->executio
nContext()); |
207 setCurrentAsyncCallChain(nullptr); | 208 data->m_eventCallChains.set(event, createAsyncCallChain(event->type(), callF
rames)); |
| 209 } |
| 210 |
| 211 void AsyncCallStackTracker::didDispatchEvent(EventTarget* eventTarget, Event* ev
ent) |
| 212 { |
| 213 ASSERT(eventTarget->executionContext()); |
| 214 ASSERT(isEnabled()); |
| 215 if (ExecutionContextData* data = m_executionContextDataMap.get(eventTarget->
executionContext())) |
| 216 data->m_eventCallChains.remove(event); |
| 217 } |
| 218 |
| 219 void AsyncCallStackTracker::willHandleEvent(EventTarget* eventTarget, Event* eve
nt, EventListener* listener, bool useCapture) |
| 220 { |
| 221 ASSERT(eventTarget->executionContext()); |
| 222 ASSERT(isEnabled()); |
| 223 if (XMLHttpRequest* xhr = toXmlHttpRequest(eventTarget)) { |
| 224 willHandleXHREvent(xhr, eventTarget, event); |
| 225 } else { |
| 226 if (ExecutionContextData* data = m_executionContextDataMap.get(eventTarg
et->executionContext())) |
| 227 setCurrentAsyncCallChain(data->m_eventCallChains.get(event)); |
| 228 else |
| 229 setCurrentAsyncCallChain(nullptr); |
| 230 } |
208 } | 231 } |
209 | 232 |
210 void AsyncCallStackTracker::willLoadXHR(XMLHttpRequest* xhr, const ScriptValue&
callFrames) | 233 void AsyncCallStackTracker::willLoadXHR(XMLHttpRequest* xhr, const ScriptValue&
callFrames) |
211 { | 234 { |
212 ASSERT(xhr->executionContext()); | 235 ASSERT(xhr->executionContext()); |
213 ASSERT(isEnabled()); | 236 ASSERT(isEnabled()); |
214 if (!validateCallFrames(callFrames)) | 237 if (!validateCallFrames(callFrames)) |
215 return; | 238 return; |
216 ExecutionContextData* data = createContextDataIfNeeded(xhr->executionContext
()); | 239 ExecutionContextData* data = createContextDataIfNeeded(xhr->executionContext
()); |
217 data->m_xhrCallChains.set(xhr, createAsyncCallChain(xhrSendName, callFrames)
); | 240 data->m_xhrCallChains.set(xhr, createAsyncCallChain(xhrSendName, callFrames)
); |
218 } | 241 } |
219 | 242 |
220 void AsyncCallStackTracker::willHandleXHREvent(XMLHttpRequest* xhr, EventTarget*
eventTarget, const AtomicString& eventType) | 243 void AsyncCallStackTracker::willHandleXHREvent(XMLHttpRequest* xhr, EventTarget*
eventTarget, Event* event) |
221 { | 244 { |
222 ASSERT(xhr->executionContext()); | 245 ASSERT(xhr->executionContext()); |
223 ASSERT(isEnabled()); | 246 ASSERT(isEnabled()); |
224 if (ExecutionContextData* data = m_executionContextDataMap.get(xhr->executio
nContext())) { | 247 if (ExecutionContextData* data = m_executionContextDataMap.get(xhr->executio
nContext())) { |
225 bool isXHRDownload = (xhr == eventTarget); | 248 bool isXHRDownload = (xhr == eventTarget); |
226 if (isXHRDownload && eventType == EventTypeNames::loadend) | 249 if (isXHRDownload && event->type() == EventTypeNames::loadend) |
227 setCurrentAsyncCallChain(data->m_xhrCallChains.take(xhr)); | 250 setCurrentAsyncCallChain(data->m_xhrCallChains.take(xhr)); |
228 else | 251 else |
229 setCurrentAsyncCallChain(data->m_xhrCallChains.get(xhr)); | 252 setCurrentAsyncCallChain(data->m_xhrCallChains.get(xhr)); |
230 } else { | 253 } else { |
231 setCurrentAsyncCallChain(nullptr); | 254 setCurrentAsyncCallChain(nullptr); |
232 } | 255 } |
233 } | 256 } |
234 | 257 |
235 void AsyncCallStackTracker::didEnqueueMutationRecord(ExecutionContext* context,
MutationObserver* observer, const ScriptValue& callFrames) | 258 void AsyncCallStackTracker::didEnqueueMutationRecord(ExecutionContext* context,
MutationObserver* observer, const ScriptValue& callFrames) |
236 { | 259 { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 { | 351 { |
329 m_currentAsyncCallChain.clear(); | 352 m_currentAsyncCallChain.clear(); |
330 m_nestedAsyncCallCount = 0; | 353 m_nestedAsyncCallCount = 0; |
331 ExecutionContextDataMap copy; | 354 ExecutionContextDataMap copy; |
332 m_executionContextDataMap.swap(copy); | 355 m_executionContextDataMap.swap(copy); |
333 for (ExecutionContextDataMap::const_iterator it = copy.begin(); it != copy.e
nd(); ++it) | 356 for (ExecutionContextDataMap::const_iterator it = copy.begin(); it != copy.e
nd(); ++it) |
334 delete it->value; | 357 delete it->value; |
335 } | 358 } |
336 | 359 |
337 } // namespace WebCore | 360 } // namespace WebCore |
OLD | NEW |