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 dbb2c0e48ce297657a6a427b3789bb7ba8675364..70efb61c1374c5b630bfbd40d309e5b3e8de3544 100644 |
| --- a/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h |
| +++ b/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.h |
| @@ -59,6 +59,12 @@ class PLATFORM_EXPORT V8PerIsolateData { |
| WTF_MAKE_NONCOPYABLE(V8PerIsolateData); |
| public: |
| + enum class V8ContextMode { |
| + kTakeSnapshot, |
| + kDontUseSnapshot, |
| + kUseSnapshot, |
| + }; |
| + |
| class EndOfScopeTask { |
| USING_FAST_MALLOC(EndOfScopeTask); |
| @@ -100,7 +106,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); |
| @@ -117,6 +125,7 @@ class PLATFORM_EXPORT V8PerIsolateData { |
| std::unique_ptr<gin::V8IdleTaskRunner>); |
| v8::Isolate* GetIsolate() { return isolate_holder_.isolate(); } |
| + v8::SnapshotCreator* GetSnapshotCreator() { return snapshot_creator_.get(); } |
| StringCache* GetStringCache() { return string_cache_.get(); } |
| @@ -140,6 +149,8 @@ class PLATFORM_EXPORT V8PerIsolateData { |
| void SetInterfaceTemplate(const DOMWrapperWorld&, |
| const void* key, |
| v8::Local<v8::FunctionTemplate>); |
| + void ClearPersistents(); |
|
Yuki
2017/05/30 14:35:58
Add a comment what this function does (and why we
peria
2017/06/01 08:33:34
Done.
|
| + V8ContextMode GetV8ContextMode() const { return v8_context_mode_; } |
|
Yuki
2017/05/30 14:35:58
GetV8ContextMode() seems relevant to GetSnapshotCr
peria
2017/06/01 08:33:34
Done.
|
| // Accessor to the cache of cross-origin accessible operation's templates. |
| // Created templates get automatically cached. |
| @@ -221,11 +232,13 @@ class PLATFORM_EXPORT V8PerIsolateData { |
| } |
| private: |
| - explicit V8PerIsolateData(WebTaskRunner*); |
| + V8PerIsolateData(WebTaskRunner*, intptr_t* reference_table, V8ContextMode); |
| + // To create with v8::SnapshotCreator. |
| + 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, |
| @@ -235,12 +248,27 @@ class PLATFORM_EXPORT V8PerIsolateData { |
| v8::Local<v8::Value>, |
| V8FunctionTemplateMap&); |
| + // Members requried for snapshotted context, and should be instantiate |
| + // before IsolateHolder. |
|
Yuki
2017/05/30 14:35:58
Members required for snapshotted contexts.
Need to
peria
2017/06/01 08:33:34
Done.
|
| + std::unique_ptr<v8::SnapshotCreator> snapshot_creator_; |
| + v8::StartupData startup_data_; |
| + |
| 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_; |
| + |
| + // Members requried for snapshotted context. |
| + using CopyablePersistent = |
|
Yuki
2017/05/30 14:35:58
I think that it's worth commenting that this is us
peria
2017/06/01 08:33:34
Acknowledged.
|
| + v8::Persistent<v8::FunctionTemplate, |
| + v8::CopyablePersistentTraits<v8::FunctionTemplate>>; |
| + using V8FunctionTemplatePersistentMap = |
| + HashMap<const void*, CopyablePersistent>; |
| + V8FunctionTemplatePersistentMap interface_template_persistent_map_; |
|
Yuki
2017/05/30 14:35:58
interface_template_maps_for_snapshot_;
would be cl
peria
2017/06/01 08:33:34
Done.
|
| + V8ContextMode v8_context_mode_; |
| + |
| // m_operationTemplateMapFor{,Non}MainWorld holds function templates for |
| // the cross-origin accessible DOM operations. |
| V8FunctionTemplateMap operation_template_map_for_main_world_; |