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..ed069706809da727df5a1a43632c6be8f2931859 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 V8ContextSnapshotMode { |
| + 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, |
| + V8ContextSnapshotMode); |
| static V8PerIsolateData* From(v8::Isolate* isolate) { |
| DCHECK(isolate); |
| @@ -144,6 +152,17 @@ class PLATFORM_EXPORT V8PerIsolateData { |
| const void* key, |
| v8::Local<v8::FunctionTemplate>); |
| + // When v8::SnapshotCreator::CreateBlob() is called, we must not have |
| + // persistent handles in Blink. This method clears them. |
| + void ClearPersistentsForV8ContextSnapshot(); |
| + |
| + v8::SnapshotCreator* GetSnapshotCreator() const { |
| + return isolate_holder_.snapshot_creator(); |
| + } |
| + V8ContextSnapshotMode GetV8ContextSnapshotMode() const { |
| + return v8_context_snapshot_mode_; |
| + } |
| + |
| // Accessor to the cache of cross-origin accessible operation's templates. |
| // Created templates get automatically cached. |
| v8::Local<v8::FunctionTemplate> FindOrCreateOperationTemplate( |
| @@ -224,11 +243,14 @@ class PLATFORM_EXPORT V8PerIsolateData { |
| } |
| private: |
| - explicit V8PerIsolateData(WebTaskRunner*); |
| + V8PerIsolateData(WebTaskRunner*, |
| + intptr_t* reference_table, |
| + V8ContextSnapshotMode); |
| + explicit 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 +260,14 @@ class PLATFORM_EXPORT V8PerIsolateData { |
| v8::Local<v8::Value>, |
| V8FunctionTemplateMap&); |
| + V8ContextSnapshotMode v8_context_snapshot_mode_; |
| gin::IsolateHolder isolate_holder_; |
|
haraken
2017/07/10 06:52:09
// This isolate_holder_ must be initialized before
peria
2017/07/10 10:18:44
Done.
|
| - // 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 +276,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 required for the V8 context snapshot. |
| + // v8::Context is created from this blob data image. This needs to be |
| + // instantiated before |isolate_holder_| gets instantiated. |
| + v8::StartupData startup_data_; |
| + // When taking a V8 context snapshot, we can't keep V8 objects with eternal |
| + // handles. So we use a special interface map that doesn't use eternal handles |
| + // instead of the default V8FunctionTemplateMap. |
| + V8GlobalValueMap<const WrapperTypeInfo*, v8::FunctionTemplate, v8::kNotWeak> |
| + interface_template_map_for_v8_context_snapshot_; |
| + |
| std::unique_ptr<StringCache> string_cache_; |
| std::unique_ptr<V8PrivateProperty> private_property_; |
| RefPtr<ScriptState> script_regexp_script_state_; |