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.
5 #ifndef PromiseTracker_h
6 #define PromiseTracker_h
8 #include "core/InspectorTypeBuilder.h"
9 #include "platform/heap/Handle.h"
10 #include "wtf/HashMap.h"
11 #include "wtf/Noncopyable.h"
12 #include "wtf/RefPtr.h"
13 #include "wtf/Vector.h"
21 class PromiseTracker FINAL : public NoBaseWillBeGarbageCollected<PromiseTracker> {
22 WTF_MAKE_NONCOPYABLE(PromiseTracker);
23 DECLARE_EMPTY_DESTRUCTOR_WILL_BE_REMOVED(PromiseTracker);
25 static PassOwnPtrWillBeRawPtr<PromiseTracker> create()
27 return adoptPtrWillBeNoop(new PromiseTracker());
30 bool isEnabled() const { return m_isEnabled; }
31 void setEnabled(bool);
35 void didReceiveV8PromiseEvent(ScriptState*, v8::Handle<v8::Object> promise, v8::Handle<v8::Value> parentPromise, int status);
37 PassRefPtr<TypeBuilder::Array<TypeBuilder::Debugger::PromiseDetails> > promises();
38 ScriptValue promiseById(int promiseId) const;
42 typedef WillBeHeapVector<RefPtrWillBeMember<PromiseData> > PromiseDataVector;
43 typedef WillBeHeapHashMap<int, PromiseDataVector> PromiseDataMap;
47 PromiseDataMap& promiseDataMap() { return m_promiseDataMap; }
52 int circularSequentialId();
53 PassRefPtrWillBeRawPtr<PromiseData> createPromiseDataIfNeeded(ScriptState*, v8::Handle<v8::Object> promise);
55 int m_circularSequentialId;
56 PromiseDataMap m_promiseDataMap;
62 #endif // !defined(PromiseTracker_h)