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

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

Issue 2841443005: [Bindings] Create and use V8 context snapshots (Closed)
Patch Set: Fix some behaviors Created 3 years, 7 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
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 }; 93 };
94 94
95 // Use this class to abstract away types of members that are pointers to core/ 95 // Use this class to abstract away types of members that are pointers to core/
96 // objects, which are simply owned and released by V8PerIsolateData (see 96 // objects, which are simply owned and released by V8PerIsolateData (see
97 // m_threadDebugger for an example). 97 // m_threadDebugger for an example).
98 class PLATFORM_EXPORT Data { 98 class PLATFORM_EXPORT Data {
99 public: 99 public:
100 virtual ~Data() = default; 100 virtual ~Data() = default;
101 }; 101 };
102 102
103 static v8::Isolate* Initialize(WebTaskRunner*); 103 static v8::Isolate* Initialize(WebTaskRunner*, intptr_t*, bool);
Yuki 2017/05/12 15:20:10 Write argument names when they're not trivial. enu
peria 2017/05/30 08:25:43 V8SnapshotCreator is under bindings/core and is no
104 104
105 static V8PerIsolateData* From(v8::Isolate* isolate) { 105 static V8PerIsolateData* From(v8::Isolate* isolate) {
106 DCHECK(isolate); 106 DCHECK(isolate);
107 DCHECK(isolate->GetData(gin::kEmbedderBlink)); 107 DCHECK(isolate->GetData(gin::kEmbedderBlink));
108 return static_cast<V8PerIsolateData*>( 108 return static_cast<V8PerIsolateData*>(
109 isolate->GetData(gin::kEmbedderBlink)); 109 isolate->GetData(gin::kEmbedderBlink));
110 } 110 }
111 111
112 static void WillBeDestroyed(v8::Isolate*); 112 static void WillBeDestroyed(v8::Isolate*);
113 static void Destroy(v8::Isolate*); 113 static void Destroy(v8::Isolate*);
114 static v8::Isolate* MainThreadIsolate(); 114 static v8::Isolate* MainThreadIsolate();
115 115
116 static void EnableIdleTasks(v8::Isolate*, 116 static void EnableIdleTasks(v8::Isolate*,
117 std::unique_ptr<gin::V8IdleTaskRunner>); 117 std::unique_ptr<gin::V8IdleTaskRunner>);
118 118
119 v8::Isolate* GetIsolate() { return isolate_holder_.isolate(); } 119 v8::Isolate* GetIsolate() { return isolate_holder_.isolate(); }
120 v8::SnapshotCreator* GetSnapshotCreator() {
121 return isolate_holder_.snapshot_creator();
122 }
120 123
121 StringCache* GetStringCache() { return string_cache_.get(); } 124 StringCache* GetStringCache() { return string_cache_.get(); }
122 125
123 v8::Persistent<v8::Value>& EnsureLiveRoot(); 126 v8::Persistent<v8::Value>& EnsureLiveRoot();
124 127
125 bool IsHandlingRecursionLevelError() const { 128 bool IsHandlingRecursionLevelError() const {
126 return is_handling_recursion_level_error_; 129 return is_handling_recursion_level_error_;
127 } 130 }
128 void SetIsHandlingRecursionLevelError(bool value) { 131 void SetIsHandlingRecursionLevelError(bool value) {
129 is_handling_recursion_level_error_ = value; 132 is_handling_recursion_level_error_ = value;
130 } 133 }
131 134
132 bool IsReportingException() const { return is_reporting_exception_; } 135 bool IsReportingException() const { return is_reporting_exception_; }
133 void SetReportingException(bool value) { is_reporting_exception_ = value; } 136 void SetReportingException(bool value) { is_reporting_exception_ = value; }
134 137
135 bool IsUseCounterDisabled() const { return use_counter_disabled_; } 138 bool IsUseCounterDisabled() const { return use_counter_disabled_; }
136 139
137 V8PrivateProperty* PrivateProperty() { return private_property_.get(); } 140 V8PrivateProperty* PrivateProperty() { return private_property_.get(); }
138 141
139 // Accessors to the cache of interface templates. 142 // Accessors to the cache of interface templates.
140 v8::Local<v8::FunctionTemplate> FindInterfaceTemplate(const DOMWrapperWorld&, 143 v8::Local<v8::FunctionTemplate> FindInterfaceTemplate(const DOMWrapperWorld&,
141 const void* key); 144 const void* key);
145 v8::Local<v8::FunctionTemplate> FindInterfaceTemplateTemp(
146 const DOMWrapperWorld&,
147 const void* key);
142 void SetInterfaceTemplate(const DOMWrapperWorld&, 148 void SetInterfaceTemplate(const DOMWrapperWorld&,
143 const void* key, 149 const void* key,
144 v8::Local<v8::FunctionTemplate>); 150 v8::Local<v8::FunctionTemplate>);
151 void SetInterfaceTemplateTemp(const DOMWrapperWorld&,
152 const void* key,
153 v8::Local<v8::FunctionTemplate>);
154 void ClearAll();
Yuki 2017/05/15 09:37:29 This function does not actually clear *all*, right
peria 2017/05/30 08:25:43 Done.
145 155
146 // Accessor to the cache of cross-origin accessible operation's templates. 156 // Accessor to the cache of cross-origin accessible operation's templates.
147 // Created templates get automatically cached. 157 // Created templates get automatically cached.
148 v8::Local<v8::FunctionTemplate> FindOrCreateOperationTemplate( 158 v8::Local<v8::FunctionTemplate> FindOrCreateOperationTemplate(
149 const DOMWrapperWorld&, 159 const DOMWrapperWorld&,
150 const void* key, 160 const void* key,
151 v8::FunctionCallback, 161 v8::FunctionCallback,
152 v8::Local<v8::Value> data, 162 v8::Local<v8::Value> data,
153 v8::Local<v8::Signature>, 163 v8::Local<v8::Signature>,
154 int length); 164 int length);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 }; 225 };
216 226
217 void SetScriptWrappableVisitor( 227 void SetScriptWrappableVisitor(
218 std::unique_ptr<ScriptWrappableVisitor> visitor) { 228 std::unique_ptr<ScriptWrappableVisitor> visitor) {
219 script_wrappable_visitor_ = std::move(visitor); 229 script_wrappable_visitor_ = std::move(visitor);
220 } 230 }
221 ScriptWrappableVisitor* GetScriptWrappableVisitor() { 231 ScriptWrappableVisitor* GetScriptWrappableVisitor() {
222 return script_wrappable_visitor_.get(); 232 return script_wrappable_visitor_.get();
223 } 233 }
224 234
235 bool UseSnapshot() const {
Yuki 2017/05/12 15:20:10 Probably ShouldUseSnapshot()? This function is a
peria 2017/05/30 08:25:43 Acknowledged.
236 return isolate_holder_.v8_context_mode() ==
237 gin::IsolateHolder::kUseSnapshot;
238 }
239
225 private: 240 private:
226 explicit V8PerIsolateData(WebTaskRunner*); 241 explicit V8PerIsolateData(WebTaskRunner*, intptr_t*, bool);
Yuki 2017/05/12 15:20:10 s/explicit//
peria 2017/05/30 08:25:43 Done.
227 ~V8PerIsolateData(); 242 ~V8PerIsolateData();
228 243
244 using CopyableTraits = v8::CopyablePersistentTraits<v8::FunctionTemplate>;
Yuki 2017/05/12 15:20:10 Could you let me know why we need CopyablePersiste
peria 2017/05/30 08:25:43 This is abused to follow V8FunctionTemplateMap. I'
245 using CopyablePersistent =
246 v8::Persistent<v8::FunctionTemplate, CopyableTraits>;
Yuki 2017/05/12 15:20:10 If these types are only used at the following line
peria 2017/06/01 08:33:31 Acknowledged.
247 using V8TemporaryFunctionTemplateMap =
Yuki 2017/05/12 15:20:10 "Temporary" doesn't make much sense, or even misle
peria 2017/05/30 08:25:43 Done.
248 HashMap<const void*, CopyablePersistent>;
249
229 typedef HashMap<const void*, v8::Eternal<v8::FunctionTemplate>> 250 typedef HashMap<const void*, v8::Eternal<v8::FunctionTemplate>>
230 V8FunctionTemplateMap; 251 V8FunctionTemplateMap;
231 V8FunctionTemplateMap& SelectInterfaceTemplateMap(const DOMWrapperWorld&); 252 V8FunctionTemplateMap& SelectInterfaceTemplateMap(const DOMWrapperWorld&);
232 V8FunctionTemplateMap& SelectOperationTemplateMap(const DOMWrapperWorld&); 253 V8FunctionTemplateMap& SelectOperationTemplateMap(const DOMWrapperWorld&);
233 bool HasInstance(const WrapperTypeInfo* untrusted, 254 bool HasInstance(const WrapperTypeInfo* untrusted,
234 v8::Local<v8::Value>, 255 v8::Local<v8::Value>,
235 V8FunctionTemplateMap&); 256 V8FunctionTemplateMap&);
236 v8::Local<v8::Object> FindInstanceInPrototypeChain(const WrapperTypeInfo*, 257 v8::Local<v8::Object> FindInstanceInPrototypeChain(const WrapperTypeInfo*,
237 v8::Local<v8::Value>, 258 v8::Local<v8::Value>,
238 V8FunctionTemplateMap&); 259 V8FunctionTemplateMap&);
239 260
240 gin::IsolateHolder isolate_holder_; 261 gin::IsolateHolder isolate_holder_;
241 262
242 // m_interfaceTemplateMapFor{,Non}MainWorld holds function templates for 263 // interface_template_map_for_{,non_}main_world holds function templates for
243 // the inerface objects. 264 // the inerface objects.
244 V8FunctionTemplateMap interface_template_map_for_main_world_; 265 V8FunctionTemplateMap interface_template_map_for_main_world_;
245 V8FunctionTemplateMap interface_template_map_for_non_main_world_; 266 V8FunctionTemplateMap interface_template_map_for_non_main_world_;
267
268 V8TemporaryFunctionTemplateMap interface_template_temp_map_;
269
246 // m_operationTemplateMapFor{,Non}MainWorld holds function templates for 270 // m_operationTemplateMapFor{,Non}MainWorld holds function templates for
247 // the cross-origin accessible DOM operations. 271 // the cross-origin accessible DOM operations.
248 V8FunctionTemplateMap operation_template_map_for_main_world_; 272 V8FunctionTemplateMap operation_template_map_for_main_world_;
249 V8FunctionTemplateMap operation_template_map_for_non_main_world_; 273 V8FunctionTemplateMap operation_template_map_for_non_main_world_;
250 274
251 // Contains lists of eternal names, such as dictionary keys. 275 // Contains lists of eternal names, such as dictionary keys.
252 HashMap<const void*, Vector<v8::Eternal<v8::Name>>> eternal_name_cache_; 276 HashMap<const void*, Vector<v8::Eternal<v8::Name>>> eternal_name_cache_;
253 277
254 std::unique_ptr<StringCache> string_cache_; 278 std::unique_ptr<StringCache> string_cache_;
255 std::unique_ptr<V8PrivateProperty> private_property_; 279 std::unique_ptr<V8PrivateProperty> private_property_;
(...skipping 12 matching lines...) Expand all
268 Vector<std::unique_ptr<EndOfScopeTask>> end_of_scope_tasks_; 292 Vector<std::unique_ptr<EndOfScopeTask>> end_of_scope_tasks_;
269 std::unique_ptr<Data> thread_debugger_; 293 std::unique_ptr<Data> thread_debugger_;
270 294
271 Persistent<ActiveScriptWrappableSet> active_script_wrappables_; 295 Persistent<ActiveScriptWrappableSet> active_script_wrappables_;
272 std::unique_ptr<ScriptWrappableVisitor> script_wrappable_visitor_; 296 std::unique_ptr<ScriptWrappableVisitor> script_wrappable_visitor_;
273 }; 297 };
274 298
275 } // namespace blink 299 } // namespace blink
276 300
277 #endif // V8PerIsolateData_h 301 #endif // V8PerIsolateData_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698