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 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
68 , m_animationFrameCallChains(tracker->m_debuggerAgent) | 68 , m_animationFrameCallChains(tracker->m_debuggerAgent) |
69 , m_eventCallChains(tracker->m_debuggerAgent) | 69 , m_eventCallChains(tracker->m_debuggerAgent) |
70 , m_xhrCallChains(tracker->m_debuggerAgent) | 70 , m_xhrCallChains(tracker->m_debuggerAgent) |
71 , m_mutationObserverCallChains(tracker->m_debuggerAgent) | 71 , m_mutationObserverCallChains(tracker->m_debuggerAgent) |
72 , m_executionContextTaskCallChains(tracker->m_debuggerAgent) | 72 , m_executionContextTaskCallChains(tracker->m_debuggerAgent) |
73 , m_asyncOperationCallChains(tracker->m_debuggerAgent) | 73 , m_asyncOperationCallChains(tracker->m_debuggerAgent) |
74 , m_circularSequentialId(0) | 74 , m_circularSequentialId(0) |
75 { | 75 { |
76 } | 76 } |
77 | 77 |
78 virtual void contextDestroyed() override | 78 virtual void contextDestroyed() override |
haraken
2015/01/13 15:17:48
Who removes the ExecutionContextData from the obse
aandrey
2015/01/13 15:39:25
We could not unobserve from contextDestroyed() cal
| |
79 { | 79 { |
80 ASSERT(executionContext()); | 80 ASSERT(executionContext()); |
81 // It is possible that resetAsyncCallChains() is already called and thus | |
82 // this ExecutionContextData is removed from m_executionContextDataMap. | |
83 OwnPtrWillBeRawPtr<ExecutionContextData> self = m_tracker->m_executionCo ntextDataMap.take(executionContext()); | 81 OwnPtrWillBeRawPtr<ExecutionContextData> self = m_tracker->m_executionCo ntextDataMap.take(executionContext()); |
84 if (self) { | 82 ASSERT_UNUSED(self, self == this); |
85 dispose(); | |
86 } | |
87 ContextLifecycleObserver::contextDestroyed(); | 83 ContextLifecycleObserver::contextDestroyed(); |
84 clearLifecycleContext(); | |
85 disposeCallChains(); | |
86 } | |
87 | |
88 void unobserve() | |
89 { | |
90 disposeCallChains(); | |
91 dispose(); | |
88 } | 92 } |
89 | 93 |
90 int nextAsyncOperationUniqueId() | 94 int nextAsyncOperationUniqueId() |
91 { | 95 { |
92 do { | 96 do { |
93 ++m_circularSequentialId; | 97 ++m_circularSequentialId; |
94 if (m_circularSequentialId <= 0) | 98 if (m_circularSequentialId <= 0) |
95 m_circularSequentialId = 1; | 99 m_circularSequentialId = 1; |
96 } while (m_asyncOperationCallChains.contains(m_circularSequentialId)); | 100 } while (m_asyncOperationCallChains.contains(m_circularSequentialId)); |
97 return m_circularSequentialId; | 101 return m_circularSequentialId; |
98 } | 102 } |
99 | 103 |
100 virtual void trace(Visitor* visitor) override | 104 virtual void trace(Visitor* visitor) override |
101 { | 105 { |
102 visitor->trace(m_tracker); | 106 visitor->trace(m_tracker); |
103 #if ENABLE(OILPAN) | 107 #if ENABLE(OILPAN) |
104 visitor->trace(m_timerCallChains); | 108 visitor->trace(m_timerCallChains); |
105 visitor->trace(m_animationFrameCallChains); | 109 visitor->trace(m_animationFrameCallChains); |
106 visitor->trace(m_eventCallChains); | 110 visitor->trace(m_eventCallChains); |
107 visitor->trace(m_xhrCallChains); | 111 visitor->trace(m_xhrCallChains); |
108 visitor->trace(m_mutationObserverCallChains); | 112 visitor->trace(m_mutationObserverCallChains); |
109 visitor->trace(m_executionContextTaskCallChains); | 113 visitor->trace(m_executionContextTaskCallChains); |
110 visitor->trace(m_asyncOperationCallChains); | 114 visitor->trace(m_asyncOperationCallChains); |
111 #endif | 115 #endif |
112 ContextLifecycleObserver::trace(visitor); | 116 ContextLifecycleObserver::trace(visitor); |
113 } | 117 } |
114 | 118 |
115 void dispose() | |
116 { | |
117 m_timerCallChains.dispose(); | |
118 m_animationFrameCallChains.dispose(); | |
119 m_eventCallChains.dispose(); | |
120 m_xhrCallChains.dispose(); | |
121 m_mutationObserverCallChains.dispose(); | |
122 m_executionContextTaskCallChains.dispose(); | |
123 m_asyncOperationCallChains.dispose(); | |
124 } | |
125 | |
126 RawPtrWillBeMember<AsyncCallTracker> m_tracker; | 119 RawPtrWillBeMember<AsyncCallTracker> m_tracker; |
127 HashSet<int> m_intervalTimerIds; | 120 HashSet<int> m_intervalTimerIds; |
128 AsyncCallChainMap<int> m_timerCallChains; | 121 AsyncCallChainMap<int> m_timerCallChains; |
129 AsyncCallChainMap<int> m_animationFrameCallChains; | 122 AsyncCallChainMap<int> m_animationFrameCallChains; |
130 AsyncCallChainMap<RawPtrWillBeMember<Event> > m_eventCallChains; | 123 AsyncCallChainMap<RawPtrWillBeMember<Event> > m_eventCallChains; |
131 AsyncCallChainMap<RawPtrWillBeMember<EventTarget> > m_xhrCallChains; | 124 AsyncCallChainMap<RawPtrWillBeMember<EventTarget> > m_xhrCallChains; |
132 AsyncCallChainMap<RawPtrWillBeMember<MutationObserver> > m_mutationObserverC allChains; | 125 AsyncCallChainMap<RawPtrWillBeMember<MutationObserver> > m_mutationObserverC allChains; |
133 AsyncCallChainMap<ExecutionContextTask*> m_executionContextTaskCallChains; | 126 AsyncCallChainMap<ExecutionContextTask*> m_executionContextTaskCallChains; |
134 AsyncCallChainMap<int> m_asyncOperationCallChains; | 127 AsyncCallChainMap<int> m_asyncOperationCallChains; |
135 | 128 |
136 private: | 129 private: |
130 void disposeCallChains() | |
131 { | |
132 m_timerCallChains.dispose(); | |
133 m_animationFrameCallChains.dispose(); | |
134 m_eventCallChains.dispose(); | |
135 m_xhrCallChains.dispose(); | |
136 m_mutationObserverCallChains.dispose(); | |
137 m_executionContextTaskCallChains.dispose(); | |
138 m_asyncOperationCallChains.dispose(); | |
139 } | |
140 | |
137 int m_circularSequentialId; | 141 int m_circularSequentialId; |
138 }; | 142 }; |
139 | 143 |
140 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) | 144 static XMLHttpRequest* toXmlHttpRequest(EventTarget* eventTarget) |
141 { | 145 { |
142 const AtomicString& interfaceName = eventTarget->interfaceName(); | 146 const AtomicString& interfaceName = eventTarget->interfaceName(); |
143 if (interfaceName == EventTargetNames::XMLHttpRequest) | 147 if (interfaceName == EventTargetNames::XMLHttpRequest) |
144 return static_cast<XMLHttpRequest*>(eventTarget); | 148 return static_cast<XMLHttpRequest*>(eventTarget); |
145 if (interfaceName == EventTargetNames::XMLHttpRequestUpload) | 149 if (interfaceName == EventTargetNames::XMLHttpRequestUpload) |
146 return static_cast<XMLHttpRequestUpload*>(eventTarget)->xmlHttpRequest() ; | 150 return static_cast<XMLHttpRequestUpload*>(eventTarget)->xmlHttpRequest() ; |
(...skipping 12 matching lines...) Expand all Loading... | |
159 } | 163 } |
160 | 164 |
161 void AsyncCallTracker::asyncCallTrackingStateChanged(bool tracking) | 165 void AsyncCallTracker::asyncCallTrackingStateChanged(bool tracking) |
162 { | 166 { |
163 m_instrumentingAgents->setAsyncCallTracker(tracking ? this : nullptr); | 167 m_instrumentingAgents->setAsyncCallTracker(tracking ? this : nullptr); |
164 } | 168 } |
165 | 169 |
166 void AsyncCallTracker::resetAsyncCallChains() | 170 void AsyncCallTracker::resetAsyncCallChains() |
167 { | 171 { |
168 for (auto& it : m_executionContextDataMap) | 172 for (auto& it : m_executionContextDataMap) |
169 it.value->dispose(); | 173 it.value->unobserve(); |
170 m_executionContextDataMap.clear(); | 174 m_executionContextDataMap.clear(); |
171 } | 175 } |
172 | 176 |
173 void AsyncCallTracker::didInstallTimer(ExecutionContext* context, int timerId, i nt timeout, bool singleShot) | 177 void AsyncCallTracker::didInstallTimer(ExecutionContext* context, int timerId, i nt timeout, bool singleShot) |
174 { | 178 { |
175 ASSERT(context); | 179 ASSERT(context); |
176 ASSERT(m_debuggerAgent->trackingAsyncCalls()); | 180 ASSERT(m_debuggerAgent->trackingAsyncCalls()); |
177 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->createAsyncC allChain(singleShot ? setTimeoutName : setIntervalName); | 181 RefPtrWillBeRawPtr<AsyncCallChain> callChain = m_debuggerAgent->createAsyncC allChain(singleShot ? setTimeoutName : setIntervalName); |
178 if (!callChain) | 182 if (!callChain) |
179 return; | 183 return; |
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
447 { | 451 { |
448 #if ENABLE(OILPAN) | 452 #if ENABLE(OILPAN) |
449 visitor->trace(m_executionContextDataMap); | 453 visitor->trace(m_executionContextDataMap); |
450 visitor->trace(m_debuggerAgent); | 454 visitor->trace(m_debuggerAgent); |
451 visitor->trace(m_instrumentingAgents); | 455 visitor->trace(m_instrumentingAgents); |
452 #endif | 456 #endif |
453 InspectorDebuggerAgent::AsyncCallTrackingListener::trace(visitor); | 457 InspectorDebuggerAgent::AsyncCallTrackingListener::trace(visitor); |
454 } | 458 } |
455 | 459 |
456 } // namespace blink | 460 } // namespace blink |
OLD | NEW |