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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/V8PerIsolateData.h

Issue 2687943004: Abstract out ThreadDebugger from V8PerIsolateData (Closed)
Patch Set: Initialize HiddenValue and PrivateProperty in V8Initializer Created 3 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
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS 16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
23 * THE POSSIBILITY OF SUCH DAMAGE. 23 * THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef V8PerIsolateData_h 26 #ifndef V8PerIsolateData_h
27 #define V8PerIsolateData_h 27 #define V8PerIsolateData_h
28 28
29 #include <v8.h>
Yuki 2017/02/15 10:00:40 Please use the following instead. #include "v8/in
30 #include <memory>
Yuki 2017/02/15 10:00:40 Chromium's style guide recommends to put an empty
adithyas 2017/02/15 18:12:12 Running git cl format reordered the headers like t
29 #include "bindings/core/v8/ScopedPersistent.h" 31 #include "bindings/core/v8/ScopedPersistent.h"
30 #include "bindings/core/v8/ScriptState.h" 32 #include "bindings/core/v8/ScriptState.h"
31 #include "bindings/core/v8/ScriptWrappableVisitor.h" 33 #include "bindings/core/v8/ScriptWrappableVisitor.h"
32 #include "bindings/core/v8/V8HiddenValue.h"
33 #include "bindings/core/v8/WrapperTypeInfo.h" 34 #include "bindings/core/v8/WrapperTypeInfo.h"
34 #include "core/CoreExport.h" 35 #include "core/CoreExport.h"
35 #include "gin/public/isolate_holder.h" 36 #include "gin/public/isolate_holder.h"
36 #include "gin/public/v8_idle_task_runner.h" 37 #include "gin/public/v8_idle_task_runner.h"
37 #include "platform/heap/Handle.h" 38 #include "platform/heap/Handle.h"
38 #include "wtf/HashMap.h" 39 #include "wtf/HashMap.h"
39 #include "wtf/Noncopyable.h" 40 #include "wtf/Noncopyable.h"
40 #include "wtf/Vector.h" 41 #include "wtf/Vector.h"
41 #include <memory>
42 #include <v8.h>
43 42
44 namespace blink { 43 namespace blink {
45 44
46 class ActiveScriptWrappableBase; 45 class ActiveScriptWrappableBase;
47 class DOMDataStore; 46 class DOMDataStore;
48 class StringCache; 47 class StringCache;
49 class ThreadDebugger;
50 class V8PrivateProperty;
51 class WebTaskRunner; 48 class WebTaskRunner;
52 struct WrapperTypeInfo; 49 struct WrapperTypeInfo;
53 50
54 typedef WTF::Vector<DOMDataStore*> DOMDataStoreList; 51 typedef WTF::Vector<DOMDataStore*> DOMDataStoreList;
55 52
56 class CORE_EXPORT V8PerIsolateData { 53 class CORE_EXPORT V8PerIsolateData {
57 USING_FAST_MALLOC(V8PerIsolateData); 54 USING_FAST_MALLOC(V8PerIsolateData);
58 WTF_MAKE_NONCOPYABLE(V8PerIsolateData); 55 WTF_MAKE_NONCOPYABLE(V8PerIsolateData);
59 56
60 public: 57 public:
(...skipping 22 matching lines...) Expand all
83 } 80 }
84 ~UseCounterDisabledScope() { 81 ~UseCounterDisabledScope() {
85 m_perIsolateData->m_useCounterDisabled = m_originalUseCounterDisabled; 82 m_perIsolateData->m_useCounterDisabled = m_originalUseCounterDisabled;
86 } 83 }
87 84
88 private: 85 private:
89 V8PerIsolateData* m_perIsolateData; 86 V8PerIsolateData* m_perIsolateData;
90 const bool m_originalUseCounterDisabled; 87 const bool m_originalUseCounterDisabled;
91 }; 88 };
92 89
90 class CORE_EXPORT Data {
91 WTF_MAKE_NONCOPYABLE(Data);
Yuki 2017/02/15 10:00:40 Why do we want Data to be non-copyable? I know sub
adithyas 2017/02/15 18:12:12 Yeah it doesn't need to be non-copyable, I've chan
92
93 public:
94 explicit Data() {}
jbroman 2017/02/14 18:10:48 nit: if you do keep this interface, you don't need
adithyas 2017/02/15 18:12:12 Removed.
95 virtual ~Data() {}
96 };
97
93 static v8::Isolate* initialize(WebTaskRunner*); 98 static v8::Isolate* initialize(WebTaskRunner*);
94 99
95 static V8PerIsolateData* from(v8::Isolate* isolate) { 100 static V8PerIsolateData* from(v8::Isolate* isolate) {
96 ASSERT(isolate); 101 ASSERT(isolate);
97 ASSERT(isolate->GetData(gin::kEmbedderBlink)); 102 ASSERT(isolate->GetData(gin::kEmbedderBlink));
98 return static_cast<V8PerIsolateData*>( 103 return static_cast<V8PerIsolateData*>(
99 isolate->GetData(gin::kEmbedderBlink)); 104 isolate->GetData(gin::kEmbedderBlink));
100 } 105 }
101 106
102 static void willBeDestroyed(v8::Isolate*); 107 static void willBeDestroyed(v8::Isolate*);
(...skipping 12 matching lines...) Expand all
115 bool isHandlingRecursionLevelError() const { 120 bool isHandlingRecursionLevelError() const {
116 return m_isHandlingRecursionLevelError; 121 return m_isHandlingRecursionLevelError;
117 } 122 }
118 void setIsHandlingRecursionLevelError(bool value) { 123 void setIsHandlingRecursionLevelError(bool value) {
119 m_isHandlingRecursionLevelError = value; 124 m_isHandlingRecursionLevelError = value;
120 } 125 }
121 126
122 bool isReportingException() const { return m_isReportingException; } 127 bool isReportingException() const { return m_isReportingException; }
123 void setReportingException(bool value) { m_isReportingException = value; } 128 void setReportingException(bool value) { m_isReportingException = value; }
124 129
125 V8HiddenValue* hiddenValue() { return m_hiddenValue.get(); } 130 Data* hiddenValue() { return m_hiddenValue.get(); }
126 V8PrivateProperty* privateProperty() { return m_privateProperty.get(); } 131 void setHiddenValue(Data* hiddenValue) { m_hiddenValue.reset(hiddenValue); }
132
133 Data* privateProperty() { return m_privateProperty.get(); }
134 void setPrivateProperty(Data* privateProperty) {
135 m_privateProperty.reset(privateProperty);
136 }
137
138 Data* threadDebugger() { return m_threadDebugger.get(); }
139 void setThreadDebugger(Data* threadDebugger) {
jbroman 2017/02/14 18:10:48 Please pass ownership by std::unique_ptr, not raw
adithyas 2017/02/15 18:12:12 Done.
140 m_threadDebugger.reset(threadDebugger);
141 }
127 142
128 // Accessors to the cache of interface templates. 143 // Accessors to the cache of interface templates.
129 v8::Local<v8::FunctionTemplate> findInterfaceTemplate(const DOMWrapperWorld&, 144 v8::Local<v8::FunctionTemplate> findInterfaceTemplate(const DOMWrapperWorld&,
130 const void* key); 145 const void* key);
131 void setInterfaceTemplate(const DOMWrapperWorld&, 146 void setInterfaceTemplate(const DOMWrapperWorld&,
132 const void* key, 147 const void* key,
133 v8::Local<v8::FunctionTemplate>); 148 v8::Local<v8::FunctionTemplate>);
134 149
135 // Accessor to the cache of cross-origin accessible operation's templates. 150 // Accessor to the cache of cross-origin accessible operation's templates.
136 // Created templates get automatically cached. 151 // Created templates get automatically cached.
(...skipping 13 matching lines...) Expand all
150 void clearScriptRegexpContext(); 165 void clearScriptRegexpContext();
151 166
152 // EndOfScopeTasks are run when control is returning 167 // EndOfScopeTasks are run when control is returning
153 // to C++ from script, after executing a script task (e.g. callback, 168 // to C++ from script, after executing a script task (e.g. callback,
154 // event) or microtasks (e.g. promise). This is explicitly needed for 169 // event) or microtasks (e.g. promise). This is explicitly needed for
155 // Indexed DB transactions per spec, but should in general be avoided. 170 // Indexed DB transactions per spec, but should in general be avoided.
156 void addEndOfScopeTask(std::unique_ptr<EndOfScopeTask>); 171 void addEndOfScopeTask(std::unique_ptr<EndOfScopeTask>);
157 void runEndOfScopeTasks(); 172 void runEndOfScopeTasks();
158 void clearEndOfScopeTasks(); 173 void clearEndOfScopeTasks();
159 174
160 void setThreadDebugger(std::unique_ptr<ThreadDebugger>);
161 ThreadDebugger* threadDebugger();
162
163 using ActiveScriptWrappableSet = 175 using ActiveScriptWrappableSet =
164 HeapHashSet<WeakMember<ActiveScriptWrappableBase>>; 176 HeapHashSet<WeakMember<ActiveScriptWrappableBase>>;
165 void addActiveScriptWrappable(ActiveScriptWrappableBase*); 177 void addActiveScriptWrappable(ActiveScriptWrappableBase*);
166 const ActiveScriptWrappableSet* activeScriptWrappables() const { 178 const ActiveScriptWrappableSet* activeScriptWrappables() const {
167 return m_activeScriptWrappables.get(); 179 return m_activeScriptWrappables.get();
168 } 180 }
169 181
170 class TemporaryScriptWrappableVisitorScope { 182 class TemporaryScriptWrappableVisitorScope {
171 WTF_MAKE_NONCOPYABLE(TemporaryScriptWrappableVisitorScope); 183 WTF_MAKE_NONCOPYABLE(TemporaryScriptWrappableVisitorScope);
172 STACK_ALLOCATED(); 184 STACK_ALLOCATED();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 235
224 // m_interfaceTemplateMapFor{,Non}MainWorld holds function templates for 236 // m_interfaceTemplateMapFor{,Non}MainWorld holds function templates for
225 // the inerface objects. 237 // the inerface objects.
226 V8FunctionTemplateMap m_interfaceTemplateMapForMainWorld; 238 V8FunctionTemplateMap m_interfaceTemplateMapForMainWorld;
227 V8FunctionTemplateMap m_interfaceTemplateMapForNonMainWorld; 239 V8FunctionTemplateMap m_interfaceTemplateMapForNonMainWorld;
228 // m_operationTemplateMapFor{,Non}MainWorld holds function templates for 240 // m_operationTemplateMapFor{,Non}MainWorld holds function templates for
229 // the cross-origin accessible DOM operations. 241 // the cross-origin accessible DOM operations.
230 V8FunctionTemplateMap m_operationTemplateMapForMainWorld; 242 V8FunctionTemplateMap m_operationTemplateMapForMainWorld;
231 V8FunctionTemplateMap m_operationTemplateMapForNonMainWorld; 243 V8FunctionTemplateMap m_operationTemplateMapForNonMainWorld;
232 244
245 std::unique_ptr<Data> m_hiddenValue;
jbroman 2017/02/14 18:10:48 V8HiddenValue is going away, and V8PrivateProperty
haraken 2017/02/15 00:06:01 Yeah, agreed.
adithyas 2017/02/15 18:12:12 Okay, I reverted the changes to V8PrivateProperty
246 std::unique_ptr<Data> m_privateProperty;
247 std::unique_ptr<Data> m_threadDebugger;
jbroman 2017/02/14 18:10:48 I'm of two minds on this. On the short-term-fix s
haraken 2017/02/15 00:06:01 I don't have any strong opinion. The current Data
jbroman 2017/02/15 02:25:23 Alright, okay to leave m_threadDebugger as-is (mod
adithyas 2017/02/15 18:12:12 Done!
248
233 std::unique_ptr<StringCache> m_stringCache; 249 std::unique_ptr<StringCache> m_stringCache;
234 std::unique_ptr<V8HiddenValue> m_hiddenValue;
235 std::unique_ptr<V8PrivateProperty> m_privateProperty;
236 ScopedPersistent<v8::Value> m_liveRoot; 250 ScopedPersistent<v8::Value> m_liveRoot;
237 RefPtr<ScriptState> m_scriptRegexpScriptState; 251 RefPtr<ScriptState> m_scriptRegexpScriptState;
238 252
239 bool m_constructorMode; 253 bool m_constructorMode;
240 friend class ConstructorMode; 254 friend class ConstructorMode;
241 255
242 bool m_useCounterDisabled; 256 bool m_useCounterDisabled;
243 friend class UseCounterDisabledScope; 257 friend class UseCounterDisabledScope;
244 258
245 bool m_isHandlingRecursionLevelError; 259 bool m_isHandlingRecursionLevelError;
246 bool m_isReportingException; 260 bool m_isReportingException;
247 261
248 Vector<std::unique_ptr<EndOfScopeTask>> m_endOfScopeTasks; 262 Vector<std::unique_ptr<EndOfScopeTask>> m_endOfScopeTasks;
249 std::unique_ptr<ThreadDebugger> m_threadDebugger;
250 263
251 Persistent<ActiveScriptWrappableSet> m_activeScriptWrappables; 264 Persistent<ActiveScriptWrappableSet> m_activeScriptWrappables;
252 std::unique_ptr<ScriptWrappableVisitor> m_scriptWrappableVisitor; 265 std::unique_ptr<ScriptWrappableVisitor> m_scriptWrappableVisitor;
253 }; 266 };
254 267
255 } // namespace blink 268 } // namespace blink
256 269
257 #endif // V8PerIsolateData_h 270 #endif // V8PerIsolateData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698