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