Commit 7b9e6bc4 authored by rockot's avatar rockot Committed by Commit bot

Tolerate a null scheduler in V8 initialization

Some utility processes need to initailize Blink and V8, and V8
initialization now assumes the main thread provides a scheduler; but
a utility process' main thread does not in fact provide one.

This eliminates the recently introduced assumption of a non-null scheduler,
defaulting to the previous behavior (using the current ThreadTaskRunnerHandle)
when no scheduler is provided.

BUG=679911
R=jochen@chromium.org

Review-Url: https://codereview.chromium.org/2624033002
Cr-Commit-Position: refs/heads/master@{#442901}
parent 1db7f101
......@@ -29,7 +29,8 @@ PerIsolateData::PerIsolateData(
: isolate_(isolate),
allocator_(allocator),
access_mode_(access_mode),
task_runner_(task_runner) {
task_runner_(
task_runner ? task_runner : base::ThreadTaskRunnerHandle::Get()) {
isolate_->SetData(kEmbedderNativeGin, this);
}
......
......@@ -392,9 +392,11 @@ void V8Initializer::initializeMainThread() {
gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode,
v8ExtrasMode, &arrayBufferAllocator);
// NOTE: Some threads (namely utility threads) don't have a scheduler.
WebScheduler* scheduler = Platform::current()->currentThread()->scheduler();
v8::Isolate* isolate =
V8PerIsolateData::initialize(scheduler->timerTaskRunner());
v8::Isolate* isolate = V8PerIsolateData::initialize(
scheduler ? scheduler->timerTaskRunner()
: Platform::current()->currentThread()->getWebTaskRunner());
initializeV8Common(isolate);
......
......@@ -55,7 +55,7 @@ static void microtasksCompletedCallback(v8::Isolate* isolate) {
V8PerIsolateData::V8PerIsolateData(WebTaskRunner* taskRunner)
: m_isolateHolder(WTF::makeUnique<gin::IsolateHolder>(
taskRunner->toSingleThreadTaskRunner())),
taskRunner ? taskRunner->toSingleThreadTaskRunner() : nullptr)),
m_stringCache(WTF::wrapUnique(new StringCache(isolate()))),
m_hiddenValue(V8HiddenValue::create()),
m_privateProperty(V8PrivateProperty::create()),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment