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

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

Issue 433653003: Support Promises event-based instrumentation on backend. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address comments + REBASE Created 6 years, 4 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 <v8.h>
9 #include "bindings/core/v8/ScopedPersistent.h"
10 #include "core/inspector/ScriptCallFrame.h"
11 #include "wtf/HashMap.h"
12 #include "wtf/Noncopyable.h"
13 #include "wtf/RefPtr.h"
14 #include "wtf/Vector.h"
15 #include "wtf/WeakPtr.h"
16
17 namespace blink {
18
19 class ScriptState;
20
21 class PromiseTracker {
22 WTF_MAKE_NONCOPYABLE(PromiseTracker);
23 public:
24 PromiseTracker() : m_isEnabled(false) { }
25
26 bool isEnabled() const { return m_isEnabled; }
27 void enable();
28 void disable();
29
30 void clear();
31
32 void didReceiveV8PromiseEvent(ScriptState*, const ScopedPersistent<v8::Objec t>& promise, const ScopedPersistent<v8::Object>& parentPromise, int status);
33
34 class PromiseData : public RefCounted<PromiseData> {
35 public:
36 PromiseData(const ScopedPersistent<v8::Object>& promise, const ScopedPer sistent<v8::Object>& parentPromise, int status, ScriptState*, PromiseTracker*, b ool captureStack = false);
37
38 private:
39 RefPtr<ScriptState> m_scriptState;
40 PromiseTracker* m_promiseTracker;
41
42 ScopedPersistent<v8::Object> m_promise;
43 ScriptCallFrame m_callFrame;
44 ScopedPersistent<v8::Object> m_parentPromise;
45 int m_status;
46
47 WeakPtrFactory<PromiseData> m_weakPtrFactory;
48
49 friend class PromiseTracker;
50 };
51
52 struct PromiseDataWrapper;
53
54 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.
55
56 private:
57 void didCreatePromise(ScriptState*, const ScopedPersistent<v8::Object>& prom ise);
58 void didUpdatePromiseParent(ScriptState*, const ScopedPersistent<v8::Object> & promise, const ScopedPersistent<v8::Object>& parentPromise);
59 void didUpdatePromiseStatus(ScriptState*, const ScopedPersistent<v8::Object> & promise, int status);
60
61 typedef Vector<RefPtr<PromiseData> > PromiseDataVector;
62 PromiseDataVector* promiseVector(ScriptState*, const ScopedPersistent<v8::Ob ject>& promise);
63
64 bool m_isEnabled;
65 typedef HashMap<int, PromiseDataVector> PromiseDataMap;
66 PromiseDataMap m_promiseDataMap;
67 };
68
69 } // namespace blink
70
71 #endif // !defined(PromiseTracker_h)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698