| 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 "platform/inspector_protocol/Allocator.h" | |
| 9 #include "platform/inspector_protocol/Collections.h" | |
| 10 #include "platform/inspector_protocol/Frontend.h" | |
| 11 #include "platform/inspector_protocol/TypeBuilder.h" | |
| 12 #include "wtf/PassOwnPtr.h" | |
| 13 #include <v8.h> | |
| 14 | |
| 15 namespace blink { | |
| 16 | |
| 17 class V8DebuggerAgentImpl; | |
| 18 | |
| 19 class PromiseTracker final { | |
| 20 PROTOCOL_DISALLOW_COPY(PromiseTracker); | |
| 21 public: | |
| 22 static PassOwnPtr<PromiseTracker> create(V8DebuggerAgentImpl* agent, v8::Iso
late* isolate) | |
| 23 { | |
| 24 return adoptPtr(new PromiseTracker(agent, isolate)); | |
| 25 } | |
| 26 | |
| 27 ~PromiseTracker(); | |
| 28 | |
| 29 bool isEnabled() const { return m_isEnabled; } | |
| 30 void setEnabled(bool enabled, bool captureStacks); | |
| 31 void clear(); | |
| 32 void didReceiveV8PromiseEvent(v8::Local<v8::Context>, v8::Local<v8::Object>
promise, v8::Local<v8::Value> parentPromise, int status); | |
| 33 v8::Local<v8::Object> promiseById(int promiseId); | |
| 34 | |
| 35 private: | |
| 36 class PromiseWrapper; | |
| 37 static void weakCallback(const v8::WeakCallbackInfo<PromiseWrapper>& data); | |
| 38 | |
| 39 PromiseTracker(V8DebuggerAgentImpl*, v8::Isolate*); | |
| 40 | |
| 41 int circularSequentialId(); | |
| 42 int promiseId(v8::Local<v8::Object> promise, bool* isNewPromise); | |
| 43 void promiseCollected(int id); | |
| 44 | |
| 45 int m_circularSequentialId; | |
| 46 bool m_isEnabled; | |
| 47 bool m_captureStacks; | |
| 48 V8DebuggerAgentImpl* m_agent; | |
| 49 | |
| 50 v8::Isolate* m_isolate; | |
| 51 v8::Persistent<v8::NativeWeakMap> m_promiseToId; | |
| 52 | |
| 53 protocol::HashMap<int, OwnPtr<PromiseWrapper>> m_idToPromise; | |
| 54 }; | |
| 55 | |
| 56 } // namespace blink | |
| 57 | |
| 58 #endif // !defined(PromiseTracker_h) | |
| OLD | NEW |