Chromium Code Reviews| 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 14 matching lines...) Expand all Loading... | |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 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 #ifndef AsyncCallStackTracker_h | 31 #ifndef AsyncCallStackTracker_h |
| 32 #define AsyncCallStackTracker_h | 32 #define AsyncCallStackTracker_h |
| 33 | 33 |
| 34 #include "bindings/core/v8/ScriptValue.h" | 34 #include "bindings/core/v8/ScriptValue.h" |
| 35 #include "core/dom/ContextLifecycleObserver.h" | |
| 36 #include "wtf/Deque.h" | 35 #include "wtf/Deque.h" |
| 37 #include "wtf/HashMap.h" | 36 #include "wtf/HashMap.h" |
| 38 #include "wtf/HashSet.h" | 37 #include "wtf/HashSet.h" |
| 39 #include "wtf/Noncopyable.h" | 38 #include "wtf/Noncopyable.h" |
| 40 #include "wtf/PassRefPtr.h" | 39 #include "wtf/PassRefPtr.h" |
| 41 #include "wtf/RefPtr.h" | 40 #include "wtf/RefPtr.h" |
| 42 | 41 |
| 43 namespace blink { | 42 namespace blink { |
| 44 | 43 |
| 45 class Event; | 44 class Event; |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 71 public: | 70 public: |
| 72 AsyncCallChain() { } | 71 AsyncCallChain() { } |
| 73 AsyncCallChain(const AsyncCallChain& t) : m_callStacks(t.m_callStacks) { } | 72 AsyncCallChain(const AsyncCallChain& t) : m_callStacks(t.m_callStacks) { } |
| 74 AsyncCallStackVector callStacks() const { return m_callStacks; } | 73 AsyncCallStackVector callStacks() const { return m_callStacks; } |
| 75 void trace(Visitor*); | 74 void trace(Visitor*); |
| 76 private: | 75 private: |
| 77 friend class AsyncCallStackTracker; | 76 friend class AsyncCallStackTracker; |
| 78 AsyncCallStackVector m_callStacks; | 77 AsyncCallStackVector m_callStacks; |
| 79 }; | 78 }; |
| 80 | 79 |
| 81 class ExecutionContextData final : public NoBaseWillBeGarbageCollectedFinali zed<ExecutionContextData>, public ContextLifecycleObserver { | |
| 82 WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED; | |
| 83 public: | |
| 84 ExecutionContextData(AsyncCallStackTracker* tracker, ExecutionContext* e xecutionContext) | |
| 85 : ContextLifecycleObserver(executionContext) | |
| 86 , m_circularSequentialID(0) | |
| 87 , m_tracker(tracker) | |
| 88 { | |
| 89 } | |
| 90 | |
| 91 virtual void contextDestroyed() override; | |
| 92 | |
| 93 int circularSequentialID(); | |
| 94 | |
| 95 void trace(Visitor*); | |
| 96 | |
| 97 private: | |
| 98 int m_circularSequentialID; | |
| 99 | |
| 100 public: | |
| 101 RawPtrWillBeMember<AsyncCallStackTracker> m_tracker; | |
| 102 HashSet<int> m_intervalTimerIds; | |
| 103 WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_timerCallC hains; | |
| 104 WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_animationF rameCallChains; | |
| 105 WillBeHeapHashMap<RawPtrWillBeMember<Event>, RefPtrWillBeMember<AsyncCal lChain> > m_eventCallChains; | |
| 106 WillBeHeapHashMap<RawPtrWillBeMember<EventTarget>, RefPtrWillBeMember<As yncCallChain> > m_xhrCallChains; | |
| 107 WillBeHeapHashMap<RawPtrWillBeMember<MutationObserver>, RefPtrWillBeMemb er<AsyncCallChain> > m_mutationObserverCallChains; | |
| 108 WillBeHeapHashMap<ExecutionContextTask*, RefPtrWillBeMember<AsyncCallCha in> > m_executionContextTaskCallChains; | |
| 109 WillBeHeapHashMap<String, RefPtrWillBeMember<AsyncCallChain> > m_v8Async TaskCallChains; | |
| 110 WillBeHeapHashMap<int, RefPtrWillBeMember<AsyncCallChain> > m_asyncOpera tionCallChains; | |
| 111 }; | |
| 112 | |
| 113 AsyncCallStackTracker(); | 80 AsyncCallStackTracker(); |
| 114 | 81 |
| 115 bool isEnabled() const { return m_maxAsyncCallStackDepth; } | 82 bool isEnabled() const { return m_maxAsyncCallStackDepth; } |
| 116 void setAsyncCallStackDepth(int); | 83 void setAsyncCallStackDepth(int); |
| 117 const AsyncCallChain* currentAsyncCallChain() const; | 84 const AsyncCallChain* currentAsyncCallChain() const; |
| 118 | 85 |
| 119 void didInstallTimer(ExecutionContext*, int timerId, bool singleShot, const ScriptValue& callFrames); | 86 void didInstallTimer(ExecutionContext*, int timerId, bool singleShot, const ScriptValue& callFrames); |
| 120 void didRemoveTimer(ExecutionContext*, int timerId); | 87 void didRemoveTimer(ExecutionContext*, int timerId); |
| 121 void willFireTimer(ExecutionContext*, int timerId); | 88 void willFireTimer(ExecutionContext*, int timerId); |
| 122 | 89 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 154 | 121 |
| 155 private: | 122 private: |
| 156 void willHandleXHREvent(XMLHttpRequest*, Event*); | 123 void willHandleXHREvent(XMLHttpRequest*, Event*); |
| 157 | 124 |
| 158 PassRefPtrWillBeRawPtr<AsyncCallChain> createAsyncCallChain(const String& de scription, const ScriptValue& callFrames); | 125 PassRefPtrWillBeRawPtr<AsyncCallChain> createAsyncCallChain(const String& de scription, const ScriptValue& callFrames); |
| 159 void setCurrentAsyncCallChain(ExecutionContext*, PassRefPtrWillBeRawPtr<Asyn cCallChain>); | 126 void setCurrentAsyncCallChain(ExecutionContext*, PassRefPtrWillBeRawPtr<Asyn cCallChain>); |
| 160 void clearCurrentAsyncCallChain(); | 127 void clearCurrentAsyncCallChain(); |
| 161 static void ensureMaxAsyncCallChainDepth(AsyncCallChain*, unsigned); | 128 static void ensureMaxAsyncCallChainDepth(AsyncCallChain*, unsigned); |
| 162 bool validateCallFrames(const ScriptValue& callFrames); | 129 bool validateCallFrames(const ScriptValue& callFrames); |
| 163 | 130 |
| 131 class ExecutionContextData; | |
| 164 ExecutionContextData* createContextDataIfNeeded(ExecutionContext*); | 132 ExecutionContextData* createContextDataIfNeeded(ExecutionContext*); |
| 165 | 133 |
| 166 unsigned m_maxAsyncCallStackDepth; | 134 unsigned m_maxAsyncCallStackDepth; |
| 167 RefPtrWillBeMember<AsyncCallChain> m_currentAsyncCallChain; | 135 RefPtrWillBeMember<AsyncCallChain> m_currentAsyncCallChain; |
| 168 unsigned m_nestedAsyncCallCount; | 136 unsigned m_nestedAsyncCallCount; |
| 169 typedef WillBeHeapHashMap<RawPtrWillBeMember<ExecutionContext>, OwnPtrWillBe Member<ExecutionContextData> > ExecutionContextDataMap; | 137 // Cannot use OwnPtrWillBeMember<ExecutionContextData> w/o making ExecutionC ontextData a complete public type. |
|
yurys
2014/11/11 12:31:37
I guess adding explicit destructor and moving its
| |
| 138 typedef WillBeHeapHashMap<RawPtrWillBeMember<ExecutionContext>, RawPtrWillBe Member<ExecutionContextData> > ExecutionContextDataMap; | |
| 170 ExecutionContextDataMap m_executionContextDataMap; | 139 ExecutionContextDataMap m_executionContextDataMap; |
| 171 }; | 140 }; |
| 172 | 141 |
| 173 } // namespace blink | 142 } // namespace blink |
| 174 | 143 |
| 175 #endif // !defined(AsyncCallStackTracker_h) | 144 #endif // !defined(AsyncCallStackTracker_h) |
| OLD | NEW |