Chromium Code Reviews| Index: third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h |
| diff --git a/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h b/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h |
| index 8af0f25c01ae503b222213bf66bf7fabf2d31bc4..e0af85f8a342b73df48f516947f23f3e0b07fb7d 100644 |
| --- a/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h |
| +++ b/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h |
| @@ -60,6 +60,12 @@ class PLATFORM_EXPORT V8PerIsolateData { |
| WTF_MAKE_NONCOPYABLE(V8PerIsolateData); |
| public: |
| + enum class V8ContextMode { |
| + kTakeSnapshot, |
| + kDontUseSnapshot, |
| + kUseSnapshot, |
| + }; |
| + |
| class EndOfScopeTask { |
| USING_FAST_MALLOC(EndOfScopeTask); |
| @@ -101,7 +107,9 @@ class PLATFORM_EXPORT V8PerIsolateData { |
| virtual ~Data() = default; |
| }; |
| - static v8::Isolate* Initialize(WebTaskRunner*); |
| + static v8::Isolate* Initialize(WebTaskRunner*, |
| + intptr_t* refernce_table, |
| + V8ContextMode); |
| static V8PerIsolateData* From(v8::Isolate* isolate) { |
| DCHECK(isolate); |
| @@ -144,6 +152,15 @@ class PLATFORM_EXPORT V8PerIsolateData { |
| const void* key, |
| v8::Local<v8::FunctionTemplate>); |
| + // When v8::SnapshotCreator::CreateBlob() is called, we must not have |
| + // persistent handles from Blink. This method clears them. |
|
Yuki
2017/06/20 14:20:11
s/from/in/
peria
2017/06/21 07:19:16
Done.
|
| + void ClearPersistentsForV8Snapshot(); |
| + |
| + v8::SnapshotCreator* GetSnapshotCreator() const { |
| + return isolate_holder_.snapshot_creator(); |
| + } |
| + V8ContextMode GetV8ContextMode() const { return v8_context_mode_; } |
| + |
| // Accessor to the cache of cross-origin accessible operation's templates. |
| // Created templates get automatically cached. |
| v8::Local<v8::FunctionTemplate> FindOrCreateOperationTemplate( |
| @@ -224,11 +241,12 @@ class PLATFORM_EXPORT V8PerIsolateData { |
| } |
| private: |
| - explicit V8PerIsolateData(WebTaskRunner*); |
| + V8PerIsolateData(WebTaskRunner*, intptr_t* reference_table, V8ContextMode); |
| + V8PerIsolateData(intptr_t* reference_table); |
| ~V8PerIsolateData(); |
| - typedef HashMap<const void*, v8::Eternal<v8::FunctionTemplate>> |
| - V8FunctionTemplateMap; |
| + using V8FunctionTemplateMap = |
| + HashMap<const void*, v8::Eternal<v8::FunctionTemplate>>; |
| V8FunctionTemplateMap& SelectInterfaceTemplateMap(const DOMWrapperWorld&); |
| V8FunctionTemplateMap& SelectOperationTemplateMap(const DOMWrapperWorld&); |
| bool HasInstance(const WrapperTypeInfo* untrusted, |
| @@ -238,12 +256,14 @@ class PLATFORM_EXPORT V8PerIsolateData { |
| v8::Local<v8::Value>, |
| V8FunctionTemplateMap&); |
| + V8ContextMode v8_context_mode_; |
| gin::IsolateHolder isolate_holder_; |
| - // m_interfaceTemplateMapFor{,Non}MainWorld holds function templates for |
| + // interface_template_map_for_{,non_}main_world holds function templates for |
| // the inerface objects. |
| V8FunctionTemplateMap interface_template_map_for_main_world_; |
| V8FunctionTemplateMap interface_template_map_for_non_main_world_; |
| + |
| // m_operationTemplateMapFor{,Non}MainWorld holds function templates for |
| // the cross-origin accessible DOM operations. |
| V8FunctionTemplateMap operation_template_map_for_main_world_; |
| @@ -252,6 +272,16 @@ class PLATFORM_EXPORT V8PerIsolateData { |
| // Contains lists of eternal names, such as dictionary keys. |
| HashMap<const void*, Vector<v8::Eternal<v8::Name>>> eternal_name_cache_; |
| + // Members requried for snapshotted context. |
| + // Snapshotted blob data image to create v8::Context's from. Needs to be |
| + // instantiated before |isoalte_holder_| gets instantiated. |
| + v8::StartupData startup_data_; |
| + // In taking V8 snapshot, we can't keep V8 objects with eternal handles. |
| + // So we keep some function templates with clearable handles when we take |
| + // snapshots. |
| + V8GlobalValueMap<const WrapperTypeInfo*, v8::FunctionTemplate, v8::kNotWeak> |
| + interface_template_map_for_v8_snapshot_; |
| + |
| std::unique_ptr<StringCache> string_cache_; |
| std::unique_ptr<V8PrivateProperty> private_property_; |
| RefPtr<ScriptState> script_regexp_script_state_; |