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/common/ScriptValue.h" | 34 #include "bindings/common/ScriptValue.h" |
| 35 #include "bindings/common/StackTrace.h" |
35 #include "wtf/Deque.h" | 36 #include "wtf/Deque.h" |
36 #include "wtf/HashMap.h" | 37 #include "wtf/HashMap.h" |
37 #include "wtf/HashSet.h" | 38 #include "wtf/HashSet.h" |
38 #include "wtf/Noncopyable.h" | 39 #include "wtf/Noncopyable.h" |
39 #include "wtf/PassRefPtr.h" | 40 #include "wtf/PassRefPtr.h" |
40 #include "wtf/RefPtr.h" | 41 #include "wtf/RefPtr.h" |
41 | 42 |
42 namespace WebCore { | 43 namespace WebCore { |
43 | 44 |
44 class EventListener; | 45 class EventListener; |
45 class EventTarget; | 46 class EventTarget; |
46 class ExecutionContext; | 47 class ExecutionContext; |
47 class ExecutionContextTask; | 48 class ExecutionContextTask; |
48 class MutationObserver; | 49 class MutationObserver; |
49 class XMLHttpRequest; | 50 class XMLHttpRequest; |
50 | 51 |
51 class AsyncCallStackTracker { | 52 class AsyncCallStackTracker { |
52 WTF_MAKE_NONCOPYABLE(AsyncCallStackTracker); | 53 WTF_MAKE_NONCOPYABLE(AsyncCallStackTracker); |
53 public: | 54 public: |
54 class AsyncCallStack : public RefCounted<AsyncCallStack> { | 55 class AsyncCallStack : public RefCounted<AsyncCallStack> { |
55 public: | 56 public: |
56 AsyncCallStack(const String&, const ScriptValue&); | 57 AsyncCallStack(const String&, const StackTrace&); |
57 ~AsyncCallStack(); | 58 ~AsyncCallStack(); |
58 String description() const { return m_description; } | 59 String description() const { return m_description; } |
59 ScriptValue callFrames() const { return m_callFrames; } | 60 StackTrace callFrames() const { return m_callFrames; } |
60 private: | 61 private: |
61 String m_description; | 62 String m_description; |
62 ScriptValue m_callFrames; | 63 StackTrace m_callFrames; |
63 }; | 64 }; |
64 | 65 |
65 typedef Deque<RefPtr<AsyncCallStack>, 4> AsyncCallStackVector; | 66 typedef Deque<RefPtr<AsyncCallStack>, 4> AsyncCallStackVector; |
66 | 67 |
67 class AsyncCallChain : public RefCounted<AsyncCallChain> { | 68 class AsyncCallChain : public RefCounted<AsyncCallChain> { |
68 public: | 69 public: |
69 AsyncCallChain() { } | 70 AsyncCallChain() { } |
70 AsyncCallChain(const AsyncCallChain& t) : m_callStacks(t.m_callStacks) {
} | 71 AsyncCallChain(const AsyncCallChain& t) : m_callStacks(t.m_callStacks) {
} |
71 AsyncCallStackVector callStacks() const { return m_callStacks; } | 72 AsyncCallStackVector callStacks() const { return m_callStacks; } |
72 private: | 73 private: |
73 friend class AsyncCallStackTracker; | 74 friend class AsyncCallStackTracker; |
74 AsyncCallStackVector m_callStacks; | 75 AsyncCallStackVector m_callStacks; |
75 }; | 76 }; |
76 | 77 |
77 AsyncCallStackTracker(); | 78 AsyncCallStackTracker(); |
78 | 79 |
79 bool isEnabled() const { return m_maxAsyncCallStackDepth; } | 80 bool isEnabled() const { return m_maxAsyncCallStackDepth; } |
80 void setAsyncCallStackDepth(int); | 81 void setAsyncCallStackDepth(int); |
81 const AsyncCallChain* currentAsyncCallChain() const; | 82 const AsyncCallChain* currentAsyncCallChain() const; |
82 | 83 |
83 void didInstallTimer(ExecutionContext*, int timerId, bool singleShot, const
ScriptValue& callFrames); | 84 void didInstallTimer(ExecutionContext*, int timerId, bool singleShot, const
StackTrace& callFrames); |
84 void didRemoveTimer(ExecutionContext*, int timerId); | 85 void didRemoveTimer(ExecutionContext*, int timerId); |
85 void willFireTimer(ExecutionContext*, int timerId); | 86 void willFireTimer(ExecutionContext*, int timerId); |
86 | 87 |
87 void didRequestAnimationFrame(ExecutionContext*, int callbackId, const Scrip
tValue& callFrames); | 88 void didRequestAnimationFrame(ExecutionContext*, int callbackId, const Stack
Trace& callFrames); |
88 void didCancelAnimationFrame(ExecutionContext*, int callbackId); | 89 void didCancelAnimationFrame(ExecutionContext*, int callbackId); |
89 void willFireAnimationFrame(ExecutionContext*, int callbackId); | 90 void willFireAnimationFrame(ExecutionContext*, int callbackId); |
90 | 91 |
91 void didAddEventListener(EventTarget*, const AtomicString& eventType, EventL
istener*, bool useCapture, const ScriptValue& callFrames); | 92 void didAddEventListener(EventTarget*, const AtomicString& eventType, EventL
istener*, bool useCapture, const StackTrace& callFrames); |
92 void didRemoveEventListener(EventTarget*, const AtomicString& eventType, Eve
ntListener*, bool useCapture); | 93 void didRemoveEventListener(EventTarget*, const AtomicString& eventType, Eve
ntListener*, bool useCapture); |
93 void didRemoveAllEventListeners(EventTarget*); | 94 void didRemoveAllEventListeners(EventTarget*); |
94 void willHandleEvent(EventTarget*, const AtomicString& eventType, EventListe
ner*, bool useCapture); | 95 void willHandleEvent(EventTarget*, const AtomicString& eventType, EventListe
ner*, bool useCapture); |
95 | 96 |
96 void willLoadXHR(XMLHttpRequest*, const ScriptValue& callFrames); | 97 void willLoadXHR(XMLHttpRequest*, const StackTrace& callFrames); |
97 | 98 |
98 void didEnqueueMutationRecord(ExecutionContext*, MutationObserver*, const Sc
riptValue& callFrames); | 99 void didEnqueueMutationRecord(ExecutionContext*, MutationObserver*, const St
ackTrace& callFrames); |
99 bool hasEnqueuedMutationRecord(ExecutionContext*, MutationObserver*); | 100 bool hasEnqueuedMutationRecord(ExecutionContext*, MutationObserver*); |
100 void didClearAllMutationRecords(ExecutionContext*, MutationObserver*); | 101 void didClearAllMutationRecords(ExecutionContext*, MutationObserver*); |
101 void willDeliverMutationRecords(ExecutionContext*, MutationObserver*); | 102 void willDeliverMutationRecords(ExecutionContext*, MutationObserver*); |
102 | 103 |
103 void didPostPromiseTask(ExecutionContext*, ExecutionContextTask*, bool isRes
olved, const ScriptValue& callFrames); | 104 void didPostPromiseTask(ExecutionContext*, ExecutionContextTask*, bool isRes
olved, const StackTrace& callFrames); |
104 void willPerformPromiseTask(ExecutionContext*, ExecutionContextTask*); | 105 void willPerformPromiseTask(ExecutionContext*, ExecutionContextTask*); |
105 | 106 |
106 void didFireAsyncCall(); | 107 void didFireAsyncCall(); |
107 void clear(); | 108 void clear(); |
108 | 109 |
109 private: | 110 private: |
110 void willHandleXHREvent(XMLHttpRequest*, EventTarget*, const AtomicString& e
ventType); | 111 void willHandleXHREvent(XMLHttpRequest*, EventTarget*, const AtomicString& e
ventType); |
111 | 112 |
112 PassRefPtr<AsyncCallChain> createAsyncCallChain(const String& description, c
onst ScriptValue& callFrames); | 113 PassRefPtr<AsyncCallChain> createAsyncCallChain(const String& description, c
onst StackTrace& callFrames); |
113 void setCurrentAsyncCallChain(PassRefPtr<AsyncCallChain>); | 114 void setCurrentAsyncCallChain(PassRefPtr<AsyncCallChain>); |
114 void clearCurrentAsyncCallChain(); | 115 void clearCurrentAsyncCallChain(); |
115 static void ensureMaxAsyncCallChainDepth(AsyncCallChain*, unsigned); | 116 static void ensureMaxAsyncCallChainDepth(AsyncCallChain*, unsigned); |
116 static bool validateCallFrames(const ScriptValue& callFrames); | 117 static bool validateCallFrames(const StackTrace& callFrames); |
117 | 118 |
118 class ExecutionContextData; | 119 class ExecutionContextData; |
119 ExecutionContextData* createContextDataIfNeeded(ExecutionContext*); | 120 ExecutionContextData* createContextDataIfNeeded(ExecutionContext*); |
120 | 121 |
121 unsigned m_maxAsyncCallStackDepth; | 122 unsigned m_maxAsyncCallStackDepth; |
122 RefPtr<AsyncCallChain> m_currentAsyncCallChain; | 123 RefPtr<AsyncCallChain> m_currentAsyncCallChain; |
123 unsigned m_nestedAsyncCallCount; | 124 unsigned m_nestedAsyncCallCount; |
124 typedef HashMap<ExecutionContext*, ExecutionContextData*> ExecutionContextDa
taMap; | 125 typedef HashMap<ExecutionContext*, ExecutionContextData*> ExecutionContextDa
taMap; |
125 ExecutionContextDataMap m_executionContextDataMap; | 126 ExecutionContextDataMap m_executionContextDataMap; |
126 }; | 127 }; |
127 | 128 |
128 } // namespace WebCore | 129 } // namespace WebCore |
129 | 130 |
130 #endif // !defined(AsyncCallStackTracker_h) | 131 #endif // !defined(AsyncCallStackTracker_h) |
OLD | NEW |