Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: third_party/WebKit/Source/core/inspector/PromiseTracker.h

Issue 1650283002: DevTools: remove DOM and Bindings dependencies from inspector/v8. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: for landing Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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/V8GlobalValueMap.h"
9 #include "core/CoreExport.h"
10 #include "core/InspectorFrontend.h"
11 #include "core/InspectorTypeBuilder.h"
12 #include "wtf/HashMap.h"
13 #include "wtf/Noncopyable.h"
14 #include "wtf/PassOwnPtr.h"
15 #include "wtf/RefPtr.h"
16 #include "wtf/Vector.h"
17 #include "wtf/WeakPtr.h"
18 #include <v8.h>
19
20 namespace blink {
21
22 class PromiseTracker final {
23 WTF_MAKE_NONCOPYABLE(PromiseTracker);
24 USING_FAST_MALLOC(PromiseTracker);
25 public:
26 class CORE_EXPORT Listener {
27 public:
28 virtual ~Listener() { }
29 virtual void didUpdatePromise(InspectorFrontend::Debugger::EventType::En um, PassRefPtr<TypeBuilder::Debugger::PromiseDetails>) = 0;
30 };
31
32 static PassOwnPtr<PromiseTracker> create(Listener* listener, v8::Isolate* is olate)
33 {
34 return adoptPtr(new PromiseTracker(listener, isolate));
35 }
36
37 ~PromiseTracker();
38
39 bool isEnabled() const { return m_isEnabled; }
40 void setEnabled(bool enabled, bool captureStacks);
41 void clear();
42 void didReceiveV8PromiseEvent(v8::Local<v8::Context>, v8::Local<v8::Object> promise, v8::Local<v8::Value> parentPromise, int status);
43 v8::Local<v8::Object> promiseById(int promiseId);
44
45 private:
46 PromiseTracker(Listener*, v8::Isolate*);
47
48 int circularSequentialId();
49 int promiseId(v8::Local<v8::Object> promise, bool* isNewPromise);
50
51 int m_circularSequentialId;
52 bool m_isEnabled;
53 bool m_captureStacks;
54 Listener* m_listener;
55
56 v8::Isolate* m_isolate;
57 v8::Persistent<v8::NativeWeakMap> m_promiseToId;
58
59 WeakPtrFactory<PromiseTracker> m_weakPtrFactory;
60
61 class PromiseWeakCallbackData;
62 class IdToPromiseMapTraits : public V8GlobalValueMapTraits<int, v8::Object, v8::kWeakWithParameter> {
63 public:
64 // Weak traits:
65 typedef PromiseWeakCallbackData WeakCallbackDataType;
66 typedef v8::GlobalValueMap<int, v8::Object, IdToPromiseMapTraits> MapTyp e;
67
68 static WeakCallbackDataType* WeakCallbackParameter(MapType*, int key, v8 ::Local<v8::Object>& value);
69 static void OnWeakCallback(const v8::WeakCallbackInfo<WeakCallbackDataTy pe>&) { }
70 // This method will be called if the value is removed from the map.
71 static void DisposeCallbackData(WeakCallbackDataType*);
72 // This method is called if weakly referenced value is collected.
73 static void DisposeWeak(const v8::WeakCallbackInfo<WeakCallbackDataType> &);
74
75 static MapType* MapFromWeakCallbackInfo(const v8::WeakCallbackInfo<WeakC allbackDataType>&);
76 static int KeyFromWeakCallbackInfo(const v8::WeakCallbackInfo<WeakCallba ckDataType>&);
77 };
78
79 IdToPromiseMapTraits::MapType m_idToPromise;
80 };
81
82 } // namespace blink
83
84 #endif // !defined(PromiseTracker_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698