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

Unified Diff: third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp

Issue 2841443005: [Bindings] Create and use V8 context snapshots (Closed)
Patch Set: . Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
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..147da325a796661544b9c719ea5d6368ffef03da 100644
--- a/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp
+++ b/third_party/WebKit/Source/platform/bindings/V8PerIsolateData.cpp
@@ -51,12 +51,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)
: 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 +83,11 @@ 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) {
+ V8PerIsolateData* data =
+ new V8PerIsolateData(task_runner, table, take_snapshot);
v8::Isolate* isolate = data->GetIsolate();
isolate->SetData(gin::kEmbedderBlink, data);
return isolate;
@@ -185,6 +193,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[],

Powered by Google App Engine
This is Rietveld 408576698