Chromium Code Reviews

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: Remove TODO Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
(Empty)
1 /*
2 * Copyright (C) 2014 Google Inc. All rights reserved.
aandrey 2014/08/01 08:28:12 use new copyright header
Alexandra Mikhaylova 2014/08/04 14:25:06 Done.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
6 * met:
7 *
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
13 * distribution.
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef PromiseTracker_h
32 #define PromiseTracker_h
33
34 #include <v8.h>
35 #include "bindings/core/v8/ScopedPersistent.h"
36 #include "core/inspector/ScriptCallFrame.h"
37 #include "wtf/HashMap.h"
38 #include "wtf/Noncopyable.h"
39 #include "wtf/RefPtr.h"
40 #include "wtf/Vector.h"
41 #include "wtf/WeakPtr.h"
42
43 namespace blink {
44
45 class ExecutionContext;
46
47 class PromiseTracker {
48 WTF_MAKE_NONCOPYABLE(PromiseTracker);
49 public:
50 PromiseTracker() : m_isEnabled(true) { }
aandrey 2014/08/01 08:28:12 default: false
Alexandra Mikhaylova 2014/08/04 14:25:06 Done.
51
52 bool isEnabled() const { return m_isEnabled; }
53 void enable();
54 void disable();
55
56 void clear();
57
58 void didCreatePromise(ExecutionContext*, v8::Handle<v8::Object> promise);
aandrey 2014/08/01 08:28:12 dont use v8::* here
Alexandra Mikhaylova 2014/08/04 14:25:06 Done.
59 void didUpdatePromiseParent(ExecutionContext*, v8::Handle<v8::Object> promis e, v8::Handle<v8::Object> parentPromise);
60 void didUpdatePromiseStatus(ExecutionContext*, v8::Handle<v8::Object> promis e, int status, v8::Handle<v8::Value>);
61
62 class PromiseData : public RefCounted<PromiseData> {
63 public:
64 PromiseData(v8::Handle<v8::Object> promise, v8::Handle<v8::Object> paren tPromise, int status, v8::Handle<v8::Value>, v8::Isolate*, PromiseTracker*, bool getCallStack = false);
65
66 v8::Isolate* m_isolate;
67 PromiseTracker* m_promiseTracker;
68
69 ScopedPersistent<v8::Object> m_promise;
aandrey 2014/08/01 08:28:12 should not be public
Alexandra Mikhaylova 2014/08/04 14:25:06 Done.
70 ScriptCallFrame m_functionDetails;
aandrey 2014/08/01 08:28:13 function details?
Alexandra Mikhaylova 2014/08/04 14:25:07 Renamed to m_callFrame.
71 ScopedPersistent<v8::Object> m_parentPromise;
72 int m_status;
73 ScopedPersistent<v8::Value> m_value;
74
75 WeakPtrFactory<PromiseData> m_weakPtrFactory;
76 };
77
78 struct PromiseDataWrapper {
aandrey 2014/08/01 08:28:12 remove from .h file
Alexandra Mikhaylova 2014/08/04 14:25:06 Done.
79 WTF_MAKE_NONCOPYABLE(PromiseDataWrapper);
80 public:
81 PromiseDataWrapper(WeakPtr<PromiseData> data)
82 : m_data(data)
83 {
84 }
85
86 WeakPtr<PromiseData> m_data;
87
88 static void didRemovePromise(const v8::WeakCallbackData<v8::Object, Prom iseDataWrapper>&);
89 };
90
91 void didRemovePromise(v8::Handle<v8::Object> promise);
92
93 private:
94 typedef Vector<RefPtr<PromiseData> > PromiseDataVector;
95 PromiseDataVector* getPromiseVector(v8::Handle<v8::Object> promise);
aandrey 2014/08/01 08:28:12 we dont use "get" prefix
Alexandra Mikhaylova 2014/08/04 14:25:06 Done.
96
97 bool m_isEnabled;
98 typedef HashMap<int, PromiseDataVector> PromiseDataMap;
99 PromiseDataMap m_promiseDataMap;
100 };
101
102 } // namespace blink
103
104 #endif // !defined(PromiseTracker_h)
OLDNEW

Powered by Google App Engine