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

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

Issue 855383002: DevTools: use async operation id instead of AsyncCallChain (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Addressed comments Created 5 years, 11 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef AsyncCallChainMap_h 5 #ifndef AsyncCallChainMap_h
6 #define AsyncCallChainMap_h 6 #define AsyncCallChainMap_h
7 7
8 #include "core/inspector/AsyncCallChain.h" 8 #include "core/inspector/AsyncCallChain.h"
9 #include "core/inspector/InspectorDebuggerAgent.h" 9 #include "core/inspector/InspectorDebuggerAgent.h"
10 #include "platform/heap/Handle.h" 10 #include "platform/heap/Handle.h"
11 #include "wtf/HashMap.h" 11 #include "wtf/HashMap.h"
12 #include "wtf/PassRefPtr.h" 12 #include "wtf/PassRefPtr.h"
13 #include "wtf/RefPtr.h" 13 #include "wtf/RefPtr.h"
14 14
15 namespace blink { 15 namespace blink {
16 16
17 template <class K> 17 template <class K>
18 class AsyncCallChainMap final { 18 class AsyncCallChainMap final {
19 ALLOW_ONLY_INLINE_ALLOCATION(); 19 ALLOW_ONLY_INLINE_ALLOCATION();
20 public: 20 public:
21 using MapType = WillBeHeapHashMap<K, RefPtrWillBeMember<AsyncCallChain>>; 21 using MapType = WillBeHeapHashMap<K, int>;
22 explicit AsyncCallChainMap(InspectorDebuggerAgent* debuggerAgent) 22 explicit AsyncCallChainMap(InspectorDebuggerAgent* debuggerAgent)
23 : m_debuggerAgent(debuggerAgent) 23 : m_debuggerAgent(debuggerAgent)
24 { 24 {
25 } 25 }
26 26
27 ~AsyncCallChainMap() 27 ~AsyncCallChainMap()
28 { 28 {
29 // Verify that this object has been explicitly disposed. 29 // Verify that this object has been explicitly disposed.
30 ASSERT(hasBeenDisposed()); 30 ASSERT(hasBeenDisposed());
31 } 31 }
32 32
33 #if ENABLE(ASSERT) 33 #if ENABLE(ASSERT)
34 bool hasBeenDisposed() const 34 bool hasBeenDisposed() const
35 { 35 {
36 return !m_debuggerAgent; 36 return !m_debuggerAgent;
37 } 37 }
38 #endif 38 #endif
39 39
40 void dispose() 40 void dispose()
41 { 41 {
42 clear(); 42 clear();
43 m_debuggerAgent = nullptr; 43 m_debuggerAgent = nullptr;
44 } 44 }
45 45
46 void clear() 46 void clear()
47 { 47 {
48 ASSERT(m_debuggerAgent); 48 ASSERT(m_debuggerAgent);
49 for (auto it : m_asyncCallChains) 49 for (auto it : m_asyncCallChains)
50 m_debuggerAgent->traceAsyncOperationCompleted(it.value.get()); 50 m_debuggerAgent->traceAsyncOperationCompleted(it.value);
51 m_asyncCallChains.clear(); 51 m_asyncCallChains.clear();
52 } 52 }
53 53
54 void set(typename MapType::KeyPeekInType key, PassRefPtrWillBeRawPtr<AsyncCa llChain> chain) 54 void set(typename MapType::KeyPeekInType key, int operationId)
55 { 55 {
56 m_asyncCallChains.set(key, chain); 56 m_asyncCallChains.set(key, operationId);
57 } 57 }
58 58
59 bool contains(typename MapType::KeyPeekInType key) const 59 bool contains(typename MapType::KeyPeekInType key) const
60 { 60 {
61 return m_asyncCallChains.contains(key); 61 return m_asyncCallChains.contains(key);
62 } 62 }
63 63
64 PassRefPtrWillBeRawPtr<AsyncCallChain> get(typename MapType::KeyPeekInType k ey) const 64 int get(typename MapType::KeyPeekInType key) const
65 { 65 {
66 return m_asyncCallChains.get(key); 66 return m_asyncCallChains.get(key);
67 } 67 }
68 68
69 void remove(typename MapType::KeyPeekInType key) 69 void remove(typename MapType::KeyPeekInType key)
70 { 70 {
71 ASSERT(m_debuggerAgent); 71 ASSERT(m_debuggerAgent);
72 RefPtrWillBeRawPtr<AsyncCallChain> chain = m_asyncCallChains.take(key); 72 int operationId = m_asyncCallChains.take(key);
73 if (chain) 73 if (operationId)
74 m_debuggerAgent->traceAsyncOperationCompleted(chain.get()); 74 m_debuggerAgent->traceAsyncOperationCompleted(operationId);
75 } 75 }
76 76
77 void trace(Visitor* visitor) 77 void trace(Visitor* visitor)
78 { 78 {
79 visitor->trace(m_debuggerAgent); 79 visitor->trace(m_debuggerAgent);
80 visitor->trace(m_asyncCallChains); 80 visitor->trace(m_asyncCallChains);
81 } 81 }
82 82
83 private: 83 private:
84 RawPtrWillBeMember<InspectorDebuggerAgent> m_debuggerAgent; 84 RawPtrWillBeMember<InspectorDebuggerAgent> m_debuggerAgent;
85 MapType m_asyncCallChains; 85 MapType m_asyncCallChains;
86 }; 86 };
87 87
88 } // namespace blink 88 } // namespace blink
89 89
90 90
91 #endif // AsyncCallChainMap_h 91 #endif // AsyncCallChainMap_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/inspector/AsyncCallTracker.h » ('j') | Source/core/inspector/InspectorDebuggerAgent.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698