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

Side by Side 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, 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 unified diff | Download patch | Annotate | Revision Log
« gin/public/v8_platform.h ('K') | « gin/public/v8_platform.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "gin/public/v8_platform.h"
6
7 #include "base/bind.h"
8 #include "base/location.h"
9 #include "base/message_loop/message_loop_proxy.h"
10 #include "base/threading/worker_pool.h"
11 #include "gin/per_isolate_data.h"
12
13 namespace gin {
14
15 namespace {
16
17 base::LazyInstance<V8Platform>::Leaky g_v8_platform = LAZY_INSTANCE_INITIALIZER;
18
19 } // namespace
20
21 // static
22 V8Platform* V8Platform::Get() { return g_v8_platform.Pointer(); }
23
24 V8Platform::V8Platform() {}
25
26 V8Platform::~V8Platform() {}
27
28 void V8Platform::CallOnBackgroundThread(
29 v8::Task* task,
30 v8::Platform::ExpectedRuntime expected_runtime) {
31 base::WorkerPool::PostTask(
32 FROM_HERE,
33 base::Bind(&v8::Task::Run, base::Owned(task)),
34 expected_runtime == v8::Platform::kLongRunningTask);
35 }
36
37 void V8Platform::CallOnForegroundThread(v8::Isolate* isolate, v8::Task* task) {
38 PerIsolateData::From(isolate)->message_loop_proxy()->PostTask(
39 FROM_HERE, base::Bind(&v8::Task::Run, base::Owned(task)));
40 }
41
42 } // namespace gin
OLDNEW
« 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