Chromium Code Reviews| 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> { | |
| 35 public: | |
| 36 PromiseData(v8::Isolate*, v8::Handle<v8::Object> promise, v8::Handle<v8: :Object> parentPromise, int status, PromiseTracker*, bool captureStack = false); | |
| 37 | |
| 38 private: | |
| 39 friend class PromiseTracker; | |
| 40 | |
| 41 PromiseTracker* m_promiseTracker; | |
| 42 | |
| 43 int m_promiseHash; | |
| 44 | |
| 45 ScopedPersistent<v8::Object> m_promise; | |
| 46 ScriptCallFrame m_callFrame; | |
| 47 ScopedPersistent<v8::Object> m_parentPromise; | |
| 48 int m_status; | |
| 49 | |
| 50 WeakPtrFactory<PromiseData> m_weakPtrFactory; | |
| 51 }; | |
| 52 | |
| 53 struct PromiseDataWrapper; | |
|
aandrey
2014/08/06 16:31:31
remove
Alexandra Mikhaylova
2014/08/07 15:01:09
Done.
| |
| 54 | |
| 55 private: | |
| 56 friend struct PromiseDataWrapper; | |
|
aandrey
2014/08/06 16:31:32
remove
Alexandra Mikhaylova
2014/08/07 15:01:09
Done.
| |
| 57 | |
| 58 void didCreatePromise(ScriptState*, v8::Handle<v8::Object> promise); | |
| 59 void didUpdatePromiseParent(ScriptState*, v8::Handle<v8::Object> promise, v8 ::Handle<v8::Object> parentPromise); | |
| 60 void didUpdatePromiseStatus(ScriptState*, v8::Handle<v8::Object> promise, in t status); | |
| 61 void didRemovePromise(WeakPtr<PromiseData>&); | |
| 62 | |
| 63 typedef Vector<RefPtr<PromiseData> > PromiseDataVector; | |
| 64 PromiseDataVector* promiseVector(int promiseHash); | |
| 65 | |
| 66 bool m_isEnabled; | |
| 67 typedef HashMap<int, PromiseDataVector> PromiseDataMap; | |
| 68 PromiseDataMap m_promiseDataMap; | |
| 69 }; | |
| 70 | |
| 71 } // namespace blink | |
| 72 | |
| 73 #endif // !defined(PromiseTracker_h) | |
| OLD | NEW |