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 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; |
| 56 |
| 57 private: |
| 58 friend class PromiseData; |
| 59 |
| 60 PromiseDataVector* promiseVector(int promiseHash); |
| 61 |
| 62 bool m_isEnabled; |
| 63 PromiseDataMap m_promiseDataMap; |
| 64 }; |
| 65 |
| 66 } // namespace blink |
| 67 |
| 68 #endif // !defined(PromiseTracker_h) |
OLD | NEW |