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

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

Issue 707273003: Refactor AsyncCallStackTracker to hide private implementation inner class. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressed Created 6 years, 1 month 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 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32 #include "core/inspector/AsyncCallStackTracker.h" 32 #include "core/inspector/AsyncCallStackTracker.h"
33 33
34 #include "bindings/core/v8/V8Binding.h" 34 #include "bindings/core/v8/V8Binding.h"
35 #include "bindings/core/v8/V8RecursionScope.h" 35 #include "bindings/core/v8/V8RecursionScope.h"
36 #include "core/dom/ContextLifecycleObserver.h"
36 #include "core/dom/ExecutionContext.h" 37 #include "core/dom/ExecutionContext.h"
37 #include "core/dom/ExecutionContextTask.h" 38 #include "core/dom/ExecutionContextTask.h"
38 #include "core/dom/Microtask.h" 39 #include "core/dom/Microtask.h"
39 #include "core/events/Event.h" 40 #include "core/events/Event.h"
40 #include "core/events/EventTarget.h" 41 #include "core/events/EventTarget.h"
41 #include "core/xmlhttprequest/XMLHttpRequest.h" 42 #include "core/xmlhttprequest/XMLHttpRequest.h"
42 #include "core/xmlhttprequest/XMLHttpRequestUpload.h" 43 #include "core/xmlhttprequest/XMLHttpRequestUpload.h"
43 #include "wtf/text/StringBuilder.h" 44 #include "wtf/text/StringBuilder.h"
44 #include "wtf/text/StringHash.h" 45 #include "wtf/text/StringHash.h"
45 #include <v8.h> 46 #include <v8.h>
46 47
47 namespace { 48 namespace {
48 49
49 static const char setTimeoutName[] = "setTimeout"; 50 static const char setTimeoutName[] = "setTimeout";
50 static const char setIntervalName[] = "setInterval"; 51 static const char setIntervalName[] = "setInterval";
51 static const char requestAnimationFrameName[] = "requestAnimationFrame"; 52 static const char requestAnimationFrameName[] = "requestAnimationFrame";
52 static const char xhrSendName[] = "XMLHttpRequest.send"; 53 static const char xhrSendName[] = "XMLHttpRequest.send";
53 static const char enqueueMutationRecordName[] = "Mutation"; 54 static const char enqueueMutationRecordName[] = "Mutation";
54 55
55 } 56 }
56 57
57 namespace blink { 58 namespace blink {
58 59
59 void AsyncCallStackTracker::ExecutionContextData::contextDestroyed() 60 class AsyncCallStackTracker::ExecutionContextData final : public NoBaseWillBeGar bageCollectedFinalized<ExecutionContextData>, public ContextLifecycleObserver {
60 { 61 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
61 ASSERT(executionContext()); 62 public:
62 OwnPtrWillBeRawPtr<ExecutionContextData> self = m_tracker->m_executionContex tDataMap.take(executionContext()); 63 ExecutionContextData(AsyncCallStackTracker* tracker, ExecutionContext* execu tionContext)
63 ASSERT_UNUSED(self, self == this); 64 : ContextLifecycleObserver(executionContext)
64 ContextLifecycleObserver::contextDestroyed(); 65 , m_tracker(tracker)
65 } 66 , m_circularSequentialID(0)
67 {
68 }
66 69
67 int AsyncCallStackTracker::ExecutionContextData::circularSequentialID() 70 virtual void contextDestroyed() override
68 { 71 {
69 ++m_circularSequentialID; 72 ASSERT(executionContext());
70 if (m_circularSequentialID <= 0) 73 OwnPtrWillBeRawPtr<ExecutionContextData> self = m_tracker->m_executionCo ntextDataMap.take(executionContext());
71 m_circularSequentialID = 1; 74 ASSERT_UNUSED(self, self == this);
72 return m_circularSequentialID; 75 ContextLifecycleObserver::contextDestroyed();
73 } 76 }
74 77
75 void AsyncCallStackTracker::ExecutionContextData::trace(Visitor* visitor) 78 int circularSequentialID()
76 { 79 {
77 visitor->trace(m_tracker); 80 ++m_circularSequentialID;
81 if (m_circularSequentialID <= 0)
82 m_circularSequentialID = 1;
83 return m_circularSequentialID;
84 }
85
86 void trace(Visitor* visitor)
87 {
88 visitor->trace(m_tracker);
78 #if ENABLE(OILPAN) 89 #if ENABLE(OILPAN)
79 visitor->trace(m_timerCallChains); 90 visitor->trace(m_timerCallChains);
80 visitor->trace(m_animationFrameCallChains); 91 visitor->trace(m_animationFrameCallChains);
81 visitor->trace(m_eventCallChains); 92 visitor->trace(m_eventCallChains);
82 visitor->trace(m_xhrCallChains); 93 visitor->trace(m_xhrCallChains);
83 visitor->trace(m_mutationObserverCallChains); 94 visitor->trace(m_mutationObserverCallChains);
84 visitor->trace(m_executionContextTaskCallChains); 95 visitor->trace(m_executionContextTaskCallChains);
85 visitor->trace(m_v8AsyncTaskCallChains); 96 visitor->trace(m_v8AsyncTaskCallChains);
86 visitor->trace(m_asyncOperationCallChains); 97 visitor->trace(m_asyncOperationCallChains);
87 #endif 98 #endif
88 } 99 }
100
101 RawPtrWillBeMember<AsyncCallStackTracker> m_tracker;
102 HashSet<int> m_intervalTimerIds;
103 WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_timerCallChain s;
104 WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_animationFrame CallChains;
105 WillBeHeapHashMap<RawPtrWillBeMember<Event>, RefPtrWillBeMember<AsyncCallCha in> > m_eventCallChains;
106 WillBeHeapHashMap<RawPtrWillBeMember<EventTarget>, RefPtrWillBeMember<AsyncC allChain> > m_xhrCallChains;
107 WillBeHeapHashMap<RawPtrWillBeMember<MutationObserver>, RefPtrWillBeMember<A syncCallChain> > m_mutationObserverCallChains;
108 WillBeHeapHashMap<ExecutionContextTask*, RefPtrWillBeMember<AsyncCallChain> > m_executionContextTaskCallChains;
109 WillBeHeapHashMap<String, RefPtrWillBeMember<AsyncCallChain> > m_v8AsyncTask CallChains;
110 WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_asyncOperation CallChains;
111
112 private:
113 int m_circularSequentialID;
114 };
89 115
90 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) 116 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget)
91 { 117 {
92 const AtomicString& interfaceName = eventTarget->interfaceName(); 118 const AtomicString& interfaceName = eventTarget->interfaceName();
93 if (interfaceName == EventTargetNames::XMLHttpRequest) 119 if (interfaceName == EventTargetNames::XMLHttpRequest)
94 return static_cast<XMLHttpRequest*>(eventTarget); 120 return static_cast<XMLHttpRequest*>(eventTarget);
95 if (interfaceName == EventTargetNames::XMLHttpRequestUpload) 121 if (interfaceName == EventTargetNames::XMLHttpRequestUpload)
96 return static_cast<XMLHttpRequestUpload*>(eventTarget)->xmlHttpRequest() ; 122 return static_cast<XMLHttpRequestUpload*>(eventTarget)->xmlHttpRequest() ;
97 return 0; 123 return 0;
98 } 124 }
(...skipping 12 matching lines...) Expand all
111 AsyncCallStackTracker::AsyncCallStack::~AsyncCallStack() 137 AsyncCallStackTracker::AsyncCallStack::~AsyncCallStack()
112 { 138 {
113 } 139 }
114 140
115 AsyncCallStackTracker::AsyncCallStackTracker() 141 AsyncCallStackTracker::AsyncCallStackTracker()
116 : m_maxAsyncCallStackDepth(0) 142 : m_maxAsyncCallStackDepth(0)
117 , m_nestedAsyncCallCount(0) 143 , m_nestedAsyncCallCount(0)
118 { 144 {
119 } 145 }
120 146
147 DEFINE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(AsyncCallStackTracker);
148
121 void AsyncCallStackTracker::setAsyncCallStackDepth(int depth) 149 void AsyncCallStackTracker::setAsyncCallStackDepth(int depth)
122 { 150 {
123 if (depth <= 0) { 151 if (depth <= 0) {
124 m_maxAsyncCallStackDepth = 0; 152 m_maxAsyncCallStackDepth = 0;
125 clear(); 153 clear();
126 } else { 154 } else {
127 m_maxAsyncCallStackDepth = depth; 155 m_maxAsyncCallStackDepth = depth;
128 } 156 }
129 } 157 }
130 158
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 497
470 void AsyncCallStackTracker::trace(Visitor* visitor) 498 void AsyncCallStackTracker::trace(Visitor* visitor)
471 { 499 {
472 visitor->trace(m_currentAsyncCallChain); 500 visitor->trace(m_currentAsyncCallChain);
473 #if ENABLE(OILPAN) 501 #if ENABLE(OILPAN)
474 visitor->trace(m_executionContextDataMap); 502 visitor->trace(m_executionContextDataMap);
475 #endif 503 #endif
476 } 504 }
477 505
478 } // namespace blink 506 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698