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

Side by Side Diff: third_party/WebKit/Source/core/inspector/AsyncOperationMap.h

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

Powered by Google App Engine
This is Rietveld 408576698