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

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

Issue 422273002: Oilpan: Prepare moving AsyncCallStackTracker to Oilpan (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 4 months 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
« no previous file with comments | « no previous file | Source/core/inspector/AsyncCallStackTracker.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 14 matching lines...) Expand all
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"
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 blink { 43 namespace blink {
43 44
44 class Event; 45 class Event;
45 class EventListener; 46 class EventListener;
46 class EventTarget; 47 class EventTarget;
47 class ExecutionContext; 48 class ExecutionContext;
48 class ExecutionContextTask; 49 class ExecutionContextTask;
49 class MutationObserver; 50 class MutationObserver;
50 class XMLHttpRequest; 51 class XMLHttpRequest;
51 52
52 class AsyncCallStackTracker { 53 class AsyncCallStackTracker FINAL : public NoBaseWillBeGarbageCollectedFinalized <AsyncCallStackTracker> {
53 WTF_MAKE_NONCOPYABLE(AsyncCallStackTracker); 54 WTF_MAKE_NONCOPYABLE(AsyncCallStackTracker);
54 public: 55 public:
55 class AsyncCallStack : public RefCounted<AsyncCallStack> { 56 class AsyncCallStack FINAL : public RefCountedWillBeGarbageCollectedFinalize d<AsyncCallStack> {
56 public: 57 public:
57 AsyncCallStack(const String&, const ScriptValue&); 58 AsyncCallStack(const String&, const ScriptValue&);
58 ~AsyncCallStack(); 59 ~AsyncCallStack();
60 void trace(Visitor*) { }
59 String description() const { return m_description; } 61 String description() const { return m_description; }
60 ScriptValue callFrames() const { return m_callFrames; } 62 ScriptValue callFrames() const { return m_callFrames; }
61 private: 63 private:
62 String m_description; 64 String m_description;
63 ScriptValue m_callFrames; 65 ScriptValue m_callFrames;
64 }; 66 };
65 67
66 typedef Deque<RefPtr<AsyncCallStack>, 4> AsyncCallStackVector; 68 typedef WillBeHeapDeque<RefPtrWillBeMember<AsyncCallStack>, 4> AsyncCallStac kVector;
67 69
68 class AsyncCallChain : public RefCounted<AsyncCallChain> { 70 class AsyncCallChain FINAL : public RefCountedWillBeGarbageCollected<AsyncCa llChain> {
69 public: 71 public:
70 AsyncCallChain() { } 72 AsyncCallChain() { }
71 AsyncCallChain(const AsyncCallChain& t) : m_callStacks(t.m_callStacks) { } 73 AsyncCallChain(const AsyncCallChain& t) : m_callStacks(t.m_callStacks) { }
72 AsyncCallStackVector callStacks() const { return m_callStacks; } 74 AsyncCallStackVector callStacks() const { return m_callStacks; }
75 void trace(Visitor*);
73 private: 76 private:
74 friend class AsyncCallStackTracker; 77 friend class AsyncCallStackTracker;
75 AsyncCallStackVector m_callStacks; 78 AsyncCallStackVector m_callStacks;
76 }; 79 };
77 80
81 class ExecutionContextData FINAL : public NoBaseWillBeGarbageCollectedFinali zed<ExecutionContextData>, public ContextLifecycleObserver {
aandrey 2014/08/26 08:39:04 It is very unfortunate that you had to move a priv
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
78 AsyncCallStackTracker(); 113 AsyncCallStackTracker();
79 114
80 bool isEnabled() const { return m_maxAsyncCallStackDepth; } 115 bool isEnabled() const { return m_maxAsyncCallStackDepth; }
81 void setAsyncCallStackDepth(int); 116 void setAsyncCallStackDepth(int);
82 const AsyncCallChain* currentAsyncCallChain() const; 117 const AsyncCallChain* currentAsyncCallChain() const;
83 118
84 void didInstallTimer(ExecutionContext*, int timerId, bool singleShot, const ScriptValue& callFrames); 119 void didInstallTimer(ExecutionContext*, int timerId, bool singleShot, const ScriptValue& callFrames);
85 void didRemoveTimer(ExecutionContext*, int timerId); 120 void didRemoveTimer(ExecutionContext*, int timerId);
86 void willFireTimer(ExecutionContext*, int timerId); 121 void willFireTimer(ExecutionContext*, int timerId);
87 122
(...skipping 20 matching lines...) Expand all
108 void didEnqueueV8AsyncTask(ExecutionContext*, const String& eventName, int i d, const ScriptValue& callFrames); 143 void didEnqueueV8AsyncTask(ExecutionContext*, const String& eventName, int i d, const ScriptValue& callFrames);
109 void willHandleV8AsyncTask(ExecutionContext*, const String& eventName, int i d); 144 void willHandleV8AsyncTask(ExecutionContext*, const String& eventName, int i d);
110 145
111 int traceAsyncOperationStarting(ExecutionContext*, const String& operationNa me, const ScriptValue& callFrames); 146 int traceAsyncOperationStarting(ExecutionContext*, const String& operationNa me, const ScriptValue& callFrames);
112 void traceAsyncOperationCompleted(ExecutionContext*, int operationId); 147 void traceAsyncOperationCompleted(ExecutionContext*, int operationId);
113 void traceAsyncCallbackStarting(ExecutionContext*, int operationId); 148 void traceAsyncCallbackStarting(ExecutionContext*, int operationId);
114 149
115 void didFireAsyncCall(); 150 void didFireAsyncCall();
116 void clear(); 151 void clear();
117 152
153 void trace(Visitor*);
154
118 private: 155 private:
119 void willHandleXHREvent(XMLHttpRequest*, Event*); 156 void willHandleXHREvent(XMLHttpRequest*, Event*);
120 157
121 PassRefPtr<AsyncCallChain> createAsyncCallChain(const String& description, c onst ScriptValue& callFrames); 158 PassRefPtrWillBeRawPtr<AsyncCallChain> createAsyncCallChain(const String& de scription, const ScriptValue& callFrames);
122 void setCurrentAsyncCallChain(ExecutionContext*, PassRefPtr<AsyncCallChain>) ; 159 void setCurrentAsyncCallChain(ExecutionContext*, PassRefPtrWillBeRawPtr<Asyn cCallChain>);
123 void clearCurrentAsyncCallChain(); 160 void clearCurrentAsyncCallChain();
124 static void ensureMaxAsyncCallChainDepth(AsyncCallChain*, unsigned); 161 static void ensureMaxAsyncCallChainDepth(AsyncCallChain*, unsigned);
125 bool validateCallFrames(const ScriptValue& callFrames); 162 bool validateCallFrames(const ScriptValue& callFrames);
126 163
127 class ExecutionContextData;
128 ExecutionContextData* createContextDataIfNeeded(ExecutionContext*); 164 ExecutionContextData* createContextDataIfNeeded(ExecutionContext*);
129 165
130 unsigned m_maxAsyncCallStackDepth; 166 unsigned m_maxAsyncCallStackDepth;
131 RefPtr<AsyncCallChain> m_currentAsyncCallChain; 167 RefPtrWillBeMember<AsyncCallChain> m_currentAsyncCallChain;
132 unsigned m_nestedAsyncCallCount; 168 unsigned m_nestedAsyncCallCount;
133 typedef HashMap<ExecutionContext*, ExecutionContextData*> ExecutionContextDa taMap; 169 typedef WillBeHeapHashMap<RawPtrWillBeMember<ExecutionContext>, OwnPtrWillBe Member<ExecutionContextData> > ExecutionContextDataMap;
134 ExecutionContextDataMap m_executionContextDataMap; 170 ExecutionContextDataMap m_executionContextDataMap;
135 }; 171 };
136 172
137 } // namespace blink 173 } // namespace blink
138 174
139 #endif // !defined(AsyncCallStackTracker_h) 175 #endif // !defined(AsyncCallStackTracker_h)
OLDNEW
« no previous file with comments | « no previous file | Source/core/inspector/AsyncCallStackTracker.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698