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

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

Issue 422273002: Oilpan: Prepare moving AsyncCallStackTracker to Oilpan (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed Created 6 years, 4 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 static const char setTimeoutName[] = "setTimeout"; 49 static const char setTimeoutName[] = "setTimeout";
50 static const char setIntervalName[] = "setInterval"; 50 static const char setIntervalName[] = "setInterval";
51 static const char requestAnimationFrameName[] = "requestAnimationFrame"; 51 static const char requestAnimationFrameName[] = "requestAnimationFrame";
52 static const char xhrSendName[] = "XMLHttpRequest.send"; 52 static const char xhrSendName[] = "XMLHttpRequest.send";
53 static const char enqueueMutationRecordName[] = "Mutation"; 53 static const char enqueueMutationRecordName[] = "Mutation";
54 54
55 } 55 }
56 56
57 namespace blink { 57 namespace blink {
58 58
59 class AsyncCallStackTracker::ExecutionContextData FINAL : public ContextLifecycl eObserver { 59 class AsyncCallStackTracker::ExecutionContextData FINAL : public NoBaseWillBeGar bageCollectedFinalized<AsyncCallStackTracker::ExecutionContextData>, public Cont extLifecycleObserver {
60 WTF_MAKE_FAST_ALLOCATED; 60 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
61 public: 61 public:
62 ExecutionContextData(AsyncCallStackTracker* tracker, ExecutionContext* execu tionContext) 62 ExecutionContextData(AsyncCallStackTracker* tracker, ExecutionContext* execu tionContext)
63 : ContextLifecycleObserver(executionContext) 63 : ContextLifecycleObserver(executionContext)
64 , m_circularSequentialID(0) 64 , m_circularSequentialID(0)
65 , m_tracker(tracker) 65 , m_tracker(tracker)
66 { 66 {
67 } 67 }
68 68
69 virtual void contextDestroyed() OVERRIDE 69 virtual void contextDestroyed() OVERRIDE
70 { 70 {
71 ASSERT(executionContext()); 71 ASSERT(executionContext());
72 ExecutionContextData* self = m_tracker->m_executionContextDataMap.take(e xecutionContext()); 72 OwnPtrWillBeRawPtr<ExecutionContextData> self = adoptPtrWillBeNoop(m_tra cker->m_executionContextDataMap.take(executionContext()));
aandrey 2014/08/11 13:35:49 I think adoptPtrWillBeNoop() is not needed, once t
keishi 2014/08/12 05:24:58 Done.
73 ASSERT(self == this); 73 ASSERT(self == this);
74 ContextLifecycleObserver::contextDestroyed(); 74 ContextLifecycleObserver::contextDestroyed();
75 delete self;
76 } 75 }
77 76
78 int circularSequentialID() 77 int circularSequentialID()
79 { 78 {
80 ++m_circularSequentialID; 79 ++m_circularSequentialID;
81 if (m_circularSequentialID <= 0) 80 if (m_circularSequentialID <= 0)
82 m_circularSequentialID = 1; 81 m_circularSequentialID = 1;
83 return m_circularSequentialID; 82 return m_circularSequentialID;
84 } 83 }
85 84
85 void trace(Visitor* visitor)
86 {
87 visitor->trace(m_tracker);
88 visitor->trace(m_timerCallChains);
89 visitor->trace(m_animationFrameCallChains);
90 visitor->trace(m_eventCallChains);
91 visitor->trace(m_xhrCallChains);
92 visitor->trace(m_mutationObserverCallChains);
93 visitor->trace(m_executionContextTaskCallChains);
94 visitor->trace(m_v8AsyncTaskCallChains);
95 visitor->trace(m_asyncOperationCallChains);
96 }
97
86 private: 98 private:
87 int m_circularSequentialID; 99 int m_circularSequentialID;
88 100
89 public: 101 public:
90 AsyncCallStackTracker* m_tracker; 102 RawPtrWillBeMember<AsyncCallStackTracker> m_tracker;
91 HashSet<int> m_intervalTimerIds; 103 HashSet<int> m_intervalTimerIds;
92 HashMap<int, RefPtr<AsyncCallChain> > m_timerCallChains; 104 WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_timerCallChain s;
93 HashMap<int, RefPtr<AsyncCallChain> > m_animationFrameCallChains; 105 WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_animationFrame CallChains;
94 HashMap<Event*, RefPtr<AsyncCallChain> > m_eventCallChains; 106 WillBeHeapHashMap<RawPtrWillBeMember<Event>, RefPtrWillBeMember<AsyncCallCha in> > m_eventCallChains;
95 HashMap<EventTarget*, RefPtr<AsyncCallChain> > m_xhrCallChains; 107 WillBeHeapHashMap<RawPtrWillBeMember<EventTarget>, RefPtrWillBeMember<AsyncC allChain> > m_xhrCallChains;
96 HashMap<MutationObserver*, RefPtr<AsyncCallChain> > m_mutationObserverCallCh ains; 108 WillBeHeapHashMap<RawPtrWillBeMember<MutationObserver>, RefPtrWillBeMember<A syncCallChain> > m_mutationObserverCallChains;
97 HashMap<ExecutionContextTask*, RefPtr<AsyncCallChain> > m_executionContextTa skCallChains; 109 WillBeHeapHashMap<ExecutionContextTask*, RefPtrWillBeMember<AsyncCallChain> > m_executionContextTaskCallChains;
98 HashMap<String, RefPtr<AsyncCallChain> > m_v8AsyncTaskCallChains; 110 WillBeHeapHashMap<String, RefPtrWillBeMember<AsyncCallChain> > m_v8AsyncTask CallChains;
99 HashMap<int, RefPtr<AsyncCallChain> > m_asyncOperationCallChains; 111 WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_asyncOperation CallChains;
100 }; 112 };
101 113
102 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) 114 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget)
103 { 115 {
104 const AtomicString& interfaceName = eventTarget->interfaceName(); 116 const AtomicString& interfaceName = eventTarget->interfaceName();
105 if (interfaceName == EventTargetNames::XMLHttpRequest) 117 if (interfaceName == EventTargetNames::XMLHttpRequest)
106 return static_cast<XMLHttpRequest*>(eventTarget); 118 return static_cast<XMLHttpRequest*>(eventTarget);
107 if (interfaceName == EventTargetNames::XMLHttpRequestUpload) 119 if (interfaceName == EventTargetNames::XMLHttpRequestUpload)
108 return static_cast<XMLHttpRequestUpload*>(eventTarget)->xmlHttpRequest() ; 120 return static_cast<XMLHttpRequestUpload*>(eventTarget)->xmlHttpRequest() ;
109 return 0; 121 return 0;
110 } 122 }
111 123
124 void AsyncCallStackTracker::AsyncCallChain::trace(Visitor* visitor)
125 {
126 visitor->trace(m_callStacks);
127 }
128
112 AsyncCallStackTracker::AsyncCallStack::AsyncCallStack(const String& description, const ScriptValue& callFrames) 129 AsyncCallStackTracker::AsyncCallStack::AsyncCallStack(const String& description, const ScriptValue& callFrames)
113 : m_description(description) 130 : m_description(description)
114 , m_callFrames(callFrames) 131 , m_callFrames(callFrames)
115 { 132 {
116 } 133 }
117 134
118 AsyncCallStackTracker::AsyncCallStack::~AsyncCallStack() 135 AsyncCallStackTracker::AsyncCallStack::~AsyncCallStack()
119 { 136 {
120 } 137 }
121 138
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 setCurrentAsyncCallChain(context, operationId > 0 ? data->m_asyncOperati onCallChains.get(operationId) : nullptr); 421 setCurrentAsyncCallChain(context, operationId > 0 ? data->m_asyncOperati onCallChains.get(operationId) : nullptr);
405 else 422 else
406 setCurrentAsyncCallChain(context, nullptr); 423 setCurrentAsyncCallChain(context, nullptr);
407 } 424 }
408 425
409 void AsyncCallStackTracker::didFireAsyncCall() 426 void AsyncCallStackTracker::didFireAsyncCall()
410 { 427 {
411 clearCurrentAsyncCallChain(); 428 clearCurrentAsyncCallChain();
412 } 429 }
413 430
414 PassRefPtr<AsyncCallStackTracker::AsyncCallChain> AsyncCallStackTracker::createA syncCallChain(const String& description, const ScriptValue& callFrames) 431 PassRefPtrWillBeRawPtr<AsyncCallStackTracker::AsyncCallChain> AsyncCallStackTrac ker::createAsyncCallChain(const String& description, const ScriptValue& callFram es)
415 { 432 {
416 if (callFrames.isEmpty()) { 433 if (callFrames.isEmpty()) {
417 ASSERT(m_currentAsyncCallChain); 434 ASSERT(m_currentAsyncCallChain);
418 return m_currentAsyncCallChain; // Propogate async call stack chain. 435 return m_currentAsyncCallChain; // Propogate async call stack chain.
419 } 436 }
420 RefPtr<AsyncCallChain> chain = adoptRef(m_currentAsyncCallChain ? new AsyncC allStackTracker::AsyncCallChain(*m_currentAsyncCallChain) : new AsyncCallStackTr acker::AsyncCallChain()); 437 RefPtrWillBeRawPtr<AsyncCallChain> chain = adoptRefWillBeNoop(m_currentAsync CallChain ? new AsyncCallStackTracker::AsyncCallChain(*m_currentAsyncCallChain) : new AsyncCallStackTracker::AsyncCallChain());
421 ensureMaxAsyncCallChainDepth(chain.get(), m_maxAsyncCallStackDepth - 1); 438 ensureMaxAsyncCallChainDepth(chain.get(), m_maxAsyncCallStackDepth - 1);
422 chain->m_callStacks.prepend(adoptRef(new AsyncCallStackTracker::AsyncCallSta ck(description, callFrames))); 439 chain->m_callStacks.prepend(adoptRefWillBeNoop(new AsyncCallStackTracker::As yncCallStack(description, callFrames)));
423 return chain.release(); 440 return chain.release();
424 } 441 }
425 442
426 void AsyncCallStackTracker::setCurrentAsyncCallChain(ExecutionContext* context, PassRefPtr<AsyncCallChain> chain) 443 void AsyncCallStackTracker::setCurrentAsyncCallChain(ExecutionContext* context, PassRefPtrWillBeRawPtr<AsyncCallChain> chain)
427 { 444 {
428 if (chain && !V8RecursionScope::recursionLevel(toIsolate(context))) { 445 if (chain && !V8RecursionScope::recursionLevel(toIsolate(context))) {
429 // Current AsyncCallChain corresponds to the bottommost JS call frame. 446 // Current AsyncCallChain corresponds to the bottommost JS call frame.
430 m_currentAsyncCallChain = chain; 447 m_currentAsyncCallChain = chain;
431 m_nestedAsyncCallCount = 1; 448 m_nestedAsyncCallCount = 1;
432 } else { 449 } else {
433 if (m_currentAsyncCallChain) 450 if (m_currentAsyncCallChain)
434 ++m_nestedAsyncCallCount; 451 ++m_nestedAsyncCallCount;
435 } 452 }
436 } 453 }
(...skipping 15 matching lines...) Expand all
452 469
453 bool AsyncCallStackTracker::validateCallFrames(const ScriptValue& callFrames) 470 bool AsyncCallStackTracker::validateCallFrames(const ScriptValue& callFrames)
454 { 471 {
455 return !callFrames.isEmpty() || m_currentAsyncCallChain; 472 return !callFrames.isEmpty() || m_currentAsyncCallChain;
456 } 473 }
457 474
458 AsyncCallStackTracker::ExecutionContextData* AsyncCallStackTracker::createContex tDataIfNeeded(ExecutionContext* context) 475 AsyncCallStackTracker::ExecutionContextData* AsyncCallStackTracker::createContex tDataIfNeeded(ExecutionContext* context)
459 { 476 {
460 ExecutionContextData* data = m_executionContextDataMap.get(context); 477 ExecutionContextData* data = m_executionContextDataMap.get(context);
461 if (!data) { 478 if (!data) {
462 data = new AsyncCallStackTracker::ExecutionContextData(this, context); 479 data = new AsyncCallStackTracker::ExecutionContextData(this, context);
aandrey 2014/08/11 13:35:49 adoptPtrWillBeNoop?
keishi 2014/08/12 05:24:58 Done.
463 m_executionContextDataMap.set(context, data); 480 m_executionContextDataMap.set(context, data);
464 } 481 }
465 return data; 482 return data;
466 } 483 }
467 484
468 void AsyncCallStackTracker::clear() 485 void AsyncCallStackTracker::clear()
469 { 486 {
470 m_currentAsyncCallChain.clear(); 487 m_currentAsyncCallChain.clear();
471 m_nestedAsyncCallCount = 0; 488 m_nestedAsyncCallCount = 0;
472 ExecutionContextDataMap copy; 489 ExecutionContextDataMap copy;
473 m_executionContextDataMap.swap(copy); 490 m_executionContextDataMap.swap(copy);
474 for (ExecutionContextDataMap::const_iterator it = copy.begin(); it != copy.e nd(); ++it) 491 for (ExecutionContextDataMap::const_iterator it = copy.begin(); it != copy.e nd(); ++it)
475 delete it->value; 492 delete it->value;
haraken 2014/08/11 13:47:06 This would be problematic as well. You cannot expl
keishi 2014/08/12 05:24:58 Done.
476 } 493 }
477 494
495 void AsyncCallStackTracker::trace(Visitor* visitor)
496 {
497 visitor->trace(m_currentAsyncCallChain);
498 visitor->trace(m_executionContextDataMap);
499 }
500
478 } // namespace blink 501 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/inspector/AsyncCallStackTracker.h ('k') | Source/core/inspector/InspectorDebuggerAgent.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698