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..1afc4e8fcdcac54c9063dfd753d1d87d90712863 |
| --- /dev/null |
| +++ b/Source/core/inspector/PromiseTracker.h |
| @@ -0,0 +1,71 @@ |
| +// 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 <v8.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" |
| + |
| +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*, const ScopedPersistent<v8::Object>& promise, const ScopedPersistent<v8::Object>& parentPromise, int status); |
| + |
| + class PromiseData : public RefCounted<PromiseData> { |
| + public: |
| + PromiseData(const ScopedPersistent<v8::Object>& promise, const ScopedPersistent<v8::Object>& parentPromise, int status, ScriptState*, PromiseTracker*, bool captureStack = false); |
| + |
| + private: |
| + RefPtr<ScriptState> m_scriptState; |
| + PromiseTracker* m_promiseTracker; |
| + |
| + ScopedPersistent<v8::Object> m_promise; |
| + ScriptCallFrame m_callFrame; |
| + ScopedPersistent<v8::Object> m_parentPromise; |
| + int m_status; |
| + |
| + WeakPtrFactory<PromiseData> m_weakPtrFactory; |
| + |
| + friend class PromiseTracker; |
| + }; |
| + |
| + struct PromiseDataWrapper; |
| + |
| + void didRemovePromise(ScriptState*, ScopedPersistent<v8::Object>& promise); |
|
aandrey
2014/08/04 16:58:48
should not be public
Alexandra Mikhaylova
2014/08/06 13:28:39
Done.
|
| + |
| +private: |
| + void didCreatePromise(ScriptState*, const ScopedPersistent<v8::Object>& promise); |
| + void didUpdatePromiseParent(ScriptState*, const ScopedPersistent<v8::Object>& promise, const ScopedPersistent<v8::Object>& parentPromise); |
| + void didUpdatePromiseStatus(ScriptState*, const ScopedPersistent<v8::Object>& promise, int status); |
| + |
| + typedef Vector<RefPtr<PromiseData> > PromiseDataVector; |
| + PromiseDataVector* promiseVector(ScriptState*, const ScopedPersistent<v8::Object>& promise); |
| + |
| + bool m_isEnabled; |
| + typedef HashMap<int, PromiseDataVector> PromiseDataMap; |
| + PromiseDataMap m_promiseDataMap; |
| +}; |
| + |
| +} // namespace blink |
| + |
| +#endif // !defined(PromiseTracker_h) |