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 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, RefPtrWillBeMember<AsyncCallChain>>; |
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 cleared already. | 29 // Verify that this object has been explicitly disposed. |
30 ASSERT(!m_debuggerAgent); | 30 ASSERT(hasBeenDisposed()); |
31 } | 31 } |
32 | 32 |
| 33 #if ENABLE(ASSERT) |
| 34 bool hasBeenDisposed() const |
| 35 { |
| 36 return !m_debuggerAgent; |
| 37 } |
| 38 #endif |
| 39 |
33 void dispose() | 40 void dispose() |
34 { | 41 { |
35 clear(); | 42 clear(); |
36 m_debuggerAgent = nullptr; | 43 m_debuggerAgent = nullptr; |
37 } | 44 } |
38 | 45 |
39 void clear() | 46 void clear() |
40 { | 47 { |
41 ASSERT(m_debuggerAgent); | 48 ASSERT(m_debuggerAgent); |
42 for (auto it : m_asyncCallChains) | 49 for (auto it : m_asyncCallChains) |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 82 |
76 private: | 83 private: |
77 RawPtrWillBeMember<InspectorDebuggerAgent> m_debuggerAgent; | 84 RawPtrWillBeMember<InspectorDebuggerAgent> m_debuggerAgent; |
78 MapType m_asyncCallChains; | 85 MapType m_asyncCallChains; |
79 }; | 86 }; |
80 | 87 |
81 } // namespace blink | 88 } // namespace blink |
82 | 89 |
83 | 90 |
84 #endif // AsyncCallChainMap_h | 91 #endif // AsyncCallChainMap_h |
OLD | NEW |