| OLD | NEW |
| 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 AsyncOperationMap_h |
| 6 #define AsyncCallChainMap_h | 6 #define AsyncOperationMap_h |
| 7 | 7 |
| 8 #include "core/inspector/AsyncCallChain.h" | |
| 9 #include "core/inspector/InspectorDebuggerAgent.h" | 8 #include "core/inspector/InspectorDebuggerAgent.h" |
| 10 #include "platform/heap/Handle.h" | 9 #include "platform/heap/Handle.h" |
| 11 #include "wtf/HashMap.h" | 10 #include "wtf/HashMap.h" |
| 12 #include "wtf/PassRefPtr.h" | 11 #include "wtf/PassRefPtr.h" |
| 13 #include "wtf/RefPtr.h" | 12 #include "wtf/RefPtr.h" |
| 14 | 13 |
| 15 namespace blink { | 14 namespace blink { |
| 16 | 15 |
| 17 template <class K> | 16 template <class K> |
| 18 class AsyncCallChainMap final { | 17 class AsyncOperationMap final { |
| 19 ALLOW_ONLY_INLINE_ALLOCATION(); | 18 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 20 public: | 19 public: |
| 21 using MapType = WillBeHeapHashMap<K, int>; | 20 using MapType = WillBeHeapHashMap<K, int>; |
| 22 explicit AsyncCallChainMap(InspectorDebuggerAgent* debuggerAgent) | 21 explicit AsyncOperationMap(InspectorDebuggerAgent* debuggerAgent) |
| 23 : m_debuggerAgent(debuggerAgent) | 22 : m_debuggerAgent(debuggerAgent) |
| 24 { | 23 { |
| 25 } | 24 } |
| 26 | 25 |
| 27 ~AsyncCallChainMap() | 26 ~AsyncOperationMap() |
| 28 { | 27 { |
| 29 // Verify that this object has been explicitly disposed. | 28 // Verify that this object has been explicitly disposed. |
| 30 ASSERT(hasBeenDisposed()); | 29 ASSERT(hasBeenDisposed()); |
| 31 } | 30 } |
| 32 | 31 |
| 33 #if ENABLE(ASSERT) | 32 #if ENABLE(ASSERT) |
| 34 bool hasBeenDisposed() const | 33 bool hasBeenDisposed() const |
| 35 { | 34 { |
| 36 return !m_debuggerAgent; | 35 return !m_debuggerAgent; |
| 37 } | 36 } |
| 38 #endif | 37 #endif |
| 39 | 38 |
| 40 void dispose() | 39 void dispose() |
| 41 { | 40 { |
| 42 clear(); | 41 clear(); |
| 43 m_debuggerAgent = nullptr; | 42 m_debuggerAgent = nullptr; |
| 44 } | 43 } |
| 45 | 44 |
| 46 void clear() | 45 void clear() |
| 47 { | 46 { |
| 48 ASSERT(m_debuggerAgent); | 47 ASSERT(m_debuggerAgent); |
| 49 for (auto it : m_asyncCallChains) | 48 for (auto it : m_asyncOperations) |
| 50 m_debuggerAgent->traceAsyncOperationCompleted(it.value); | 49 m_debuggerAgent->traceAsyncOperationCompleted(it.value); |
| 51 m_asyncCallChains.clear(); | 50 m_asyncOperations.clear(); |
| 52 } | 51 } |
| 53 | 52 |
| 54 void set(typename MapType::KeyPeekInType key, int operationId) | 53 void set(typename MapType::KeyPeekInType key, int operationId) |
| 55 { | 54 { |
| 56 m_asyncCallChains.set(key, operationId); | 55 m_asyncOperations.set(key, operationId); |
| 57 } | 56 } |
| 58 | 57 |
| 59 bool contains(typename MapType::KeyPeekInType key) const | 58 bool contains(typename MapType::KeyPeekInType key) const |
| 60 { | 59 { |
| 61 return m_asyncCallChains.contains(key); | 60 return m_asyncOperations.contains(key); |
| 62 } | 61 } |
| 63 | 62 |
| 64 int get(typename MapType::KeyPeekInType key) const | 63 int get(typename MapType::KeyPeekInType key) const |
| 65 { | 64 { |
| 66 return m_asyncCallChains.get(key); | 65 return m_asyncOperations.get(key); |
| 67 } | 66 } |
| 68 | 67 |
| 69 void remove(typename MapType::KeyPeekInType key) | 68 void remove(typename MapType::KeyPeekInType key) |
| 70 { | 69 { |
| 71 ASSERT(m_debuggerAgent); | 70 ASSERT(m_debuggerAgent); |
| 72 int operationId = m_asyncCallChains.take(key); | 71 int operationId = m_asyncOperations.take(key); |
| 73 if (operationId) | 72 if (operationId) |
| 74 m_debuggerAgent->traceAsyncOperationCompleted(operationId); | 73 m_debuggerAgent->traceAsyncOperationCompleted(operationId); |
| 75 } | 74 } |
| 76 | 75 |
| 77 void trace(Visitor* visitor) | 76 void trace(Visitor* visitor) |
| 78 { | 77 { |
| 79 visitor->trace(m_debuggerAgent); | 78 visitor->trace(m_debuggerAgent); |
| 80 visitor->trace(m_asyncCallChains); | 79 visitor->trace(m_asyncOperations); |
| 81 } | 80 } |
| 82 | 81 |
| 83 private: | 82 private: |
| 84 RawPtrWillBeMember<InspectorDebuggerAgent> m_debuggerAgent; | 83 RawPtrWillBeMember<InspectorDebuggerAgent> m_debuggerAgent; |
| 85 MapType m_asyncCallChains; | 84 MapType m_asyncOperations; |
| 86 }; | 85 }; |
| 87 | 86 |
| 88 } // namespace blink | 87 } // namespace blink |
| 89 | 88 |
| 90 | 89 |
| 91 #endif // AsyncCallChainMap_h | 90 #endif // AsyncOperationMap_h |
| OLD | NEW |