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

Side by Side Diff: Source/core/inspector/AsyncCallStackTracker.cpp

Issue 383363002: DevTools: Fix async stacks instrumentation for XHRs. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 ASSERT(isEnabled()); 219 ASSERT(isEnabled());
220 if (ExecutionContextData* data = m_executionContextDataMap.get(eventTarget-> executionContext())) 220 if (ExecutionContextData* data = m_executionContextDataMap.get(eventTarget-> executionContext()))
221 data->m_eventCallChains.remove(event); 221 data->m_eventCallChains.remove(event);
222 } 222 }
223 223
224 void AsyncCallStackTracker::willHandleEvent(EventTarget* eventTarget, Event* eve nt, EventListener* listener, bool useCapture) 224 void AsyncCallStackTracker::willHandleEvent(EventTarget* eventTarget, Event* eve nt, EventListener* listener, bool useCapture)
225 { 225 {
226 ASSERT(eventTarget->executionContext()); 226 ASSERT(eventTarget->executionContext());
227 ASSERT(isEnabled()); 227 ASSERT(isEnabled());
228 if (XMLHttpRequest* xhr = toXmlHttpRequest(eventTarget)) { 228 if (XMLHttpRequest* xhr = toXmlHttpRequest(eventTarget)) {
229 willHandleXHREvent(xhr, eventTarget, event); 229 willHandleXHREvent(xhr, event);
230 } else { 230 } else {
231 ExecutionContext* context = eventTarget->executionContext(); 231 ExecutionContext* context = eventTarget->executionContext();
232 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) 232 if (ExecutionContextData* data = m_executionContextDataMap.get(context))
233 setCurrentAsyncCallChain(context, data->m_eventCallChains.get(event) ); 233 setCurrentAsyncCallChain(context, data->m_eventCallChains.get(event) );
234 else 234 else
235 setCurrentAsyncCallChain(context, nullptr); 235 setCurrentAsyncCallChain(context, nullptr);
236 } 236 }
237 } 237 }
238 238
239 void AsyncCallStackTracker::willLoadXHR(XMLHttpRequest* xhr, const ScriptValue& callFrames) 239 void AsyncCallStackTracker::willLoadXHR(XMLHttpRequest* xhr, const ScriptValue& callFrames)
240 { 240 {
241 ASSERT(xhr->executionContext()); 241 ASSERT(xhr->executionContext());
242 ASSERT(isEnabled()); 242 ASSERT(isEnabled());
243 if (!validateCallFrames(callFrames)) 243 if (!validateCallFrames(callFrames))
244 return; 244 return;
245 ExecutionContextData* data = createContextDataIfNeeded(xhr->executionContext ()); 245 ExecutionContextData* data = createContextDataIfNeeded(xhr->executionContext ());
246 data->m_xhrCallChains.set(xhr, createAsyncCallChain(xhrSendName, callFrames) ); 246 data->m_xhrCallChains.set(xhr, createAsyncCallChain(xhrSendName, callFrames) );
247 } 247 }
248 248
249 void AsyncCallStackTracker::willHandleXHREvent(XMLHttpRequest* xhr, EventTarget* eventTarget, Event* event) 249 void AsyncCallStackTracker::didLoadXHR(XMLHttpRequest* xhr)
250 {
251 ASSERT(xhr->executionContext());
252 ASSERT(isEnabled());
253 if (ExecutionContextData* data = m_executionContextDataMap.get(xhr->executio nContext()))
254 data->m_xhrCallChains.remove(xhr);
255 }
256
257 void AsyncCallStackTracker::willHandleXHREvent(XMLHttpRequest* xhr, Event* event )
250 { 258 {
251 ExecutionContext* context = xhr->executionContext(); 259 ExecutionContext* context = xhr->executionContext();
252 ASSERT(context); 260 ASSERT(context);
253 ASSERT(isEnabled()); 261 ASSERT(isEnabled());
254 if (ExecutionContextData* data = m_executionContextDataMap.get(context)) { 262 if (ExecutionContextData* data = m_executionContextDataMap.get(context))
255 bool isXHRDownload = (xhr == eventTarget); 263 setCurrentAsyncCallChain(context, data->m_xhrCallChains.get(xhr));
256 if (isXHRDownload && event->type() == EventTypeNames::loadend) 264 else
257 setCurrentAsyncCallChain(context, data->m_xhrCallChains.take(xhr));
258 else
259 setCurrentAsyncCallChain(context, data->m_xhrCallChains.get(xhr));
260 } else {
261 setCurrentAsyncCallChain(context, nullptr); 265 setCurrentAsyncCallChain(context, nullptr);
262 }
263 } 266 }
264 267
265 void AsyncCallStackTracker::didEnqueueMutationRecord(ExecutionContext* context, MutationObserver* observer, const ScriptValue& callFrames) 268 void AsyncCallStackTracker::didEnqueueMutationRecord(ExecutionContext* context, MutationObserver* observer, const ScriptValue& callFrames)
266 { 269 {
267 ASSERT(context); 270 ASSERT(context);
268 ASSERT(isEnabled()); 271 ASSERT(isEnabled());
269 if (!validateCallFrames(callFrames)) 272 if (!validateCallFrames(callFrames))
270 return; 273 return;
271 ExecutionContextData* data = createContextDataIfNeeded(context); 274 ExecutionContextData* data = createContextDataIfNeeded(context);
272 data->m_mutationObserverCallChains.set(observer, createAsyncCallChain(enqueu eMutationRecordName, callFrames)); 275 data->m_mutationObserverCallChains.set(observer, createAsyncCallChain(enqueu eMutationRecordName, callFrames));
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 { 421 {
419 m_currentAsyncCallChain.clear(); 422 m_currentAsyncCallChain.clear();
420 m_nestedAsyncCallCount = 0; 423 m_nestedAsyncCallCount = 0;
421 ExecutionContextDataMap copy; 424 ExecutionContextDataMap copy;
422 m_executionContextDataMap.swap(copy); 425 m_executionContextDataMap.swap(copy);
423 for (ExecutionContextDataMap::const_iterator it = copy.begin(); it != copy.e nd(); ++it) 426 for (ExecutionContextDataMap::const_iterator it = copy.begin(); it != copy.e nd(); ++it)
424 delete it->value; 427 delete it->value;
425 } 428 }
426 429
427 } // namespace WebCore 430 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698