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