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

Unified Diff: gin/v8_platform.cc

Issue 225413004: [gin] Add a v8::Platform implementation to allow for v8 posting tasks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 6 years, 9 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
« gin/public/v8_platform.h ('K') | « gin/public/v8_platform.h ('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
new file mode 100644
index 0000000000000000000000000000000000000000..d50ff24f8bf49d7aa2c947e6f4bb20a1cbaee6ab
--- /dev/null
+++ b/gin/v8_platform.cc
@@ -0,0 +1,42 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "gin/public/v8_platform.h"
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/message_loop/message_loop_proxy.h"
+#include "base/threading/worker_pool.h"
+#include "gin/per_isolate_data.h"
+
+namespace gin {
+
+namespace {
+
+base::LazyInstance<V8Platform>::Leaky g_v8_platform = LAZY_INSTANCE_INITIALIZER;
+
+} // namespace
+
+// static
+V8Platform* V8Platform::Get() { return g_v8_platform.Pointer(); }
+
+V8Platform::V8Platform() {}
+
+V8Platform::~V8Platform() {}
+
+void V8Platform::CallOnBackgroundThread(
+ v8::Task* task,
+ v8::Platform::ExpectedRuntime expected_runtime) {
+ base::WorkerPool::PostTask(
+ FROM_HERE,
+ base::Bind(&v8::Task::Run, base::Owned(task)),
+ expected_runtime == v8::Platform::kLongRunningTask);
+}
+
+void V8Platform::CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) {
+ PerIsolateData::From(isolate)->message_loop_proxy()->PostTask(
+ FROM_HERE, base::Bind(&v8::Task::Run, base::Owned(task)));
+}
+
+} // namespace gin
« gin/public/v8_platform.h ('K') | « gin/public/v8_platform.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698