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

Unified Diff: gin/v8_platform.cc

Issue 2478813002: When an Isolate is configured to use lockers, foreground tasks need to lock (Closed)
Patch Set: Created 4 years, 1 month 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
« no previous file with comments | « gin/per_isolate_data.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gin/v8_platform.cc
diff --git a/gin/v8_platform.cc b/gin/v8_platform.cc
index 945eee0cc3d9798730130ebbe44d3d5acb92d4f7..bbbf4d076a287c6b6a62c1cb0247e6d5ce6d5270 100644
--- a/gin/v8_platform.cc
+++ b/gin/v8_platform.cc
@@ -17,6 +17,11 @@ namespace {
base::LazyInstance<V8Platform>::Leaky g_v8_platform = LAZY_INSTANCE_INITIALIZER;
+void RunWithLocker(v8::Isolate* isolate, v8::Task* task) {
+ v8::Locker lock(isolate);
+ task->Run();
+}
+
} // namespace
// static
@@ -49,8 +54,15 @@ void V8Platform::CallOnBackgroundThread(
}
void V8Platform::CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) {
- PerIsolateData::From(isolate)->task_runner()->PostTask(
- FROM_HERE, base::Bind(&v8::Task::Run, base::Owned(task)));
+ PerIsolateData* data = PerIsolateData::From(isolate);
ulan 2016/11/04 14:28:30 The same change should apply to other Call*OnForeg
+ if (data->access_mode() == IsolateHolder::kUseLocker) {
+ data->task_runner()->PostTask(
+ FROM_HERE, base::Bind(RunWithLocker, base::Unretained(isolate),
+ base::Owned(task)));
+ } else {
+ data->task_runner()->PostTask(
+ FROM_HERE, base::Bind(&v8::Task::Run, base::Owned(task)));
+ }
}
void V8Platform::CallDelayedOnForegroundThread(v8::Isolate* isolate,
« no previous file with comments | « gin/per_isolate_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698