Chromium Code Reviews| Index: third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp |
| diff --git a/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp b/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp |
| index e9f59763e1d8b529a087d2ebbf12d64c4e4a18e3..ed7f49aaaf09c016aa3eafc48c1267d367bcddf6 100644 |
| --- a/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp |
| +++ b/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp |
| @@ -27,6 +27,7 @@ |
| #include <memory> |
| +#include "platform/RuntimeEnabledFeatures.h" |
| #include "platform/ScriptForbiddenScope.h" |
| #include "platform/WebTaskRunner.h" |
| #include "platform/bindings/DOMDataStore.h" |
| @@ -51,12 +52,17 @@ static void MicrotasksCompletedCallback(v8::Isolate* isolate) { |
| V8PerIsolateData::From(isolate)->RunEndOfScopeTasks(); |
| } |
| -V8PerIsolateData::V8PerIsolateData(WebTaskRunner* task_runner) |
| +V8PerIsolateData::V8PerIsolateData(WebTaskRunner* task_runner, |
| + intptr_t* table, |
| + bool take_snapshot) |
|
Yuki
2017/05/12 15:20:10
bool argument, which is ambiguous, is not recommen
peria
2017/05/30 08:25:43
Acknowledged.
|
| : isolate_holder_( |
| task_runner ? task_runner->ToSingleThreadTaskRunner() : nullptr, |
| gin::IsolateHolder::kSingleThread, |
| IsMainThread() ? gin::IsolateHolder::kDisallowAtomicsWait |
| - : gin::IsolateHolder::kAllowAtomicsWait), |
| + : gin::IsolateHolder::kAllowAtomicsWait, |
| + table, |
| + take_snapshot ? gin::IsolateHolder::kTakeSnapshot |
| + : gin::IsolateHolder::kDefault), |
| string_cache_(WTF::WrapUnique(new StringCache(GetIsolate()))), |
| private_property_(V8PrivateProperty::Create()), |
| constructor_mode_(ConstructorMode::kCreateNewObject), |
| @@ -78,8 +84,15 @@ v8::Isolate* V8PerIsolateData::MainThreadIsolate() { |
| return g_main_thread_per_isolate_data->GetIsolate(); |
| } |
| -v8::Isolate* V8PerIsolateData::Initialize(WebTaskRunner* task_runner) { |
| - V8PerIsolateData* data = new V8PerIsolateData(task_runner); |
| +v8::Isolate* V8PerIsolateData::Initialize(WebTaskRunner* task_runner, |
| + intptr_t* table, |
| + bool take_snapshot) { |
| + if (!take_snapshot && !RuntimeEnabledFeatures::v8ContextSnapshotEnabled()) { |
| + table = nullptr; |
| + } |
| + |
| + V8PerIsolateData* data = |
| + new V8PerIsolateData(task_runner, table, take_snapshot); |
| v8::Isolate* isolate = data->GetIsolate(); |
| isolate->SetData(gin::kEmbedderBlink, data); |
| return isolate; |
| @@ -185,6 +198,29 @@ void V8PerIsolateData::SetInterfaceTemplate( |
| map.insert(key, v8::Eternal<v8::FunctionTemplate>(GetIsolate(), value)); |
| } |
| +v8::Local<v8::FunctionTemplate> V8PerIsolateData::FindInterfaceTemplateTemp( |
| + const DOMWrapperWorld& world, |
| + const void* key) { |
| + auto& map = interface_template_temp_map_; |
| + auto result = map.find(key); |
| + if (result != map.end()) |
| + return result->value.Get(GetIsolate()); |
| + return v8::Local<v8::FunctionTemplate>(); |
| +} |
| + |
| +void V8PerIsolateData::SetInterfaceTemplateTemp( |
| + const DOMWrapperWorld& world, |
| + const void* key, |
| + v8::Local<v8::FunctionTemplate> value) { |
| + auto& map = interface_template_temp_map_; |
| + map.insert(key, CopyablePersistent(GetIsolate(), value)); |
| +} |
| + |
| +void V8PerIsolateData::ClearAll() { |
| + interface_template_temp_map_.clear(); |
| + private_property_.reset(); |
| +} |
| + |
| const v8::Eternal<v8::Name>* V8PerIsolateData::FindOrCreateEternalNameCache( |
| const void* lookup_key, |
| const char* const names[], |