Chromium Code Reviews| Index: Source/core/inspector/PromiseTracker.h |
| diff --git a/Source/core/inspector/PromiseTracker.h b/Source/core/inspector/PromiseTracker.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f7c75d46195422f6ed06c0875c62b7f485cd1f16 |
| --- /dev/null |
| +++ b/Source/core/inspector/PromiseTracker.h |
| @@ -0,0 +1,64 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef PromiseTracker_h |
| +#define PromiseTracker_h |
| + |
| +#include "bindings/core/v8/ScopedPersistent.h" |
| +#include "core/inspector/ScriptCallFrame.h" |
| +#include "wtf/HashMap.h" |
| +#include "wtf/Noncopyable.h" |
| +#include "wtf/RefPtr.h" |
| +#include "wtf/Vector.h" |
| +#include "wtf/WeakPtr.h" |
| +#include <v8.h> |
| + |
| +namespace blink { |
| + |
| +class ScriptState; |
| + |
| +class PromiseTracker { |
| + WTF_MAKE_NONCOPYABLE(PromiseTracker); |
| +public: |
| + PromiseTracker() : m_isEnabled(false) { } |
| + |
| + bool isEnabled() const { return m_isEnabled; } |
| + void enable(); |
| + void disable(); |
| + |
| + void clear(); |
| + |
| + void didReceiveV8PromiseEvent(ScriptState*, v8::Handle<v8::Object> promise, v8::Handle<v8::Value> parentPromise, int status); |
| + |
| + 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
|
| + public: |
| + PromiseData(v8::Isolate*, int promiseHash, v8::Handle<v8::Object> promise); |
| + |
| + int promiseHash() const { return m_promiseHash; } |
| + ScopedPersistent<v8::Object>& promise() { return m_promise; } |
| + |
| + private: |
| + friend class PromiseTracker; |
| + |
| + int m_promiseHash; |
| + |
| + ScopedPersistent<v8::Object> m_promise; |
| + ScriptCallFrame m_callFrame; |
| + ScopedPersistent<v8::Object> m_parentPromise; |
| + int m_status; |
| + |
| + WeakPtrFactory<PromiseData> m_weakPtrFactory; |
| + }; |
| + |
| + typedef Vector<RefPtr<PromiseData> > PromiseDataVector; |
| + 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
|
| + |
| +private: |
| + bool m_isEnabled; |
| + PromiseDataMap m_promiseDataMap; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // !defined(PromiseTracker_h) |