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 PromiseTracker_h | |
6 #define PromiseTracker_h | |
7 | |
8 #include "bindings/core/v8/ScopedPersistent.h" | |
9 #include "core/inspector/ScriptCallFrame.h" | |
10 #include "wtf/HashMap.h" | |
11 #include "wtf/Noncopyable.h" | |
12 #include "wtf/RefPtr.h" | |
13 #include "wtf/Vector.h" | |
14 #include "wtf/WeakPtr.h" | |
15 #include <v8.h> | |
16 | |
17 namespace blink { | |
18 | |
19 class ScriptState; | |
20 | |
21 class PromiseTracker { | |
22 WTF_MAKE_NONCOPYABLE(PromiseTracker); | |
23 public: | |
24 PromiseTracker() : m_isEnabled(false) { } | |
25 | |
26 bool isEnabled() const { return m_isEnabled; } | |
27 void enable(); | |
28 void disable(); | |
29 | |
30 void clear(); | |
31 | |
32 void didReceiveV8PromiseEvent(ScriptState*, v8::Handle<v8::Object> promise, v8::Handle<v8::Value> parentPromise, int status); | |
33 | |
34 class PromiseData : public RefCounted<PromiseData> { | |
yurys
2014/08/26 14:06:36
Why is this public?
Alexandra Mikhaylova
2014/08/28 13:29:46
It's used in PromiseDataWrapper that's wrapped in
| |
35 public: | |
36 PromiseData(v8::Isolate*, int promiseHash, v8::Handle<v8::Object> promis e); | |
37 | |
38 int promiseHash() const { return m_promiseHash; } | |
39 ScopedPersistent<v8::Object>& promise() { return m_promise; } | |
40 | |
41 private: | |
42 friend class PromiseTracker; | |
43 | |
44 int m_promiseHash; | |
45 | |
46 ScopedPersistent<v8::Object> m_promise; | |
47 ScriptCallFrame m_callFrame; | |
48 ScopedPersistent<v8::Object> m_parentPromise; | |
49 int m_status; | |
50 | |
51 WeakPtrFactory<PromiseData> m_weakPtrFactory; | |
52 }; | |
53 | |
54 typedef Vector<RefPtr<PromiseData> > PromiseDataVector; | |
55 typedef HashMap<int, PromiseDataVector> PromiseDataMap; | |
yurys
2014/08/26 14:06:36
Why not use HashMap<Handle<Promise>, PromiseData>
Alexandra Mikhaylova
2014/08/28 13:29:46
We're going to migrate to WeakMap in future, using
| |
56 | |
57 private: | |
58 bool m_isEnabled; | |
59 PromiseDataMap m_promiseDataMap; | |
60 }; | |
61 | |
62 } // namespace blink | |
63 | |
64 #endif // !defined(PromiseTracker_h) | |
OLD | NEW |