This source file includes following definitions.
- Get
- CallOnBackgroundThread
- CallOnForegroundThread
#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;
}
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)));
}
}