Commit a0620196 authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Commit Bot

OffMT service worker startup: Create EmbeddedWorkerInstanceClient on the IO thread

Post a task to the IO thread to create EmbeddedWorkerInstanceClient
when off-the-main-thread service worker startup is enabled.

This is a tentative workaround to avoid some race conditions which
happen when we make EmbeddedWorkerInstanceClient independent from
RenderThreadImpl (see crbug.com/995134). Ideally we shouldn't need
to post a task. Instead we should bind EmbeddedWorkerInstanceClient
on the IO thread.

Bug: 538751
Change-Id: I4bdb54232fb7abde7d6d1dccf1ac3cb58db16a92
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1761888Reviewed-by: default avatarMatt Falkenhagen <falken@chromium.org>
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688436}
parent 4215da5d
...@@ -2090,9 +2090,30 @@ void RenderThreadImpl::CreateFrameProxy( ...@@ -2090,9 +2090,30 @@ void RenderThreadImpl::CreateFrameProxy(
replicated_state, devtools_frame_token); replicated_state, devtools_frame_token);
} }
void StartEmbeddedWorkerInstanceClientOnIOThread(
mojo::PendingReceiver<blink::mojom::EmbeddedWorkerInstanceClient>
client_receiver,
scoped_refptr<base::SingleThreadTaskRunner> io_task_runner) {
DCHECK(io_task_runner->BelongsToCurrentThread());
EmbeddedWorkerInstanceClientImpl::Create(std::move(client_receiver),
std::move(io_task_runner));
}
void RenderThreadImpl::SetUpEmbeddedWorkerChannelForServiceWorker( void RenderThreadImpl::SetUpEmbeddedWorkerChannelForServiceWorker(
mojo::PendingReceiver<blink::mojom::EmbeddedWorkerInstanceClient> mojo::PendingReceiver<blink::mojom::EmbeddedWorkerInstanceClient>
client_receiver) { client_receiver) {
// TODO(bashi): This is a tentative workaround to start service worker on the
// IO thread. We should decouple EmbeddedWorkerInstanceClient from Renderer
// and bind EmbeddedWorkerInstanceClient on the IO thread.
if (base::FeatureList::IsEnabled(
blink::features::kOffMainThreadServiceWorkerStartup)) {
GetIOTaskRunner()->PostTask(
FROM_HERE,
base::BindOnce(&StartEmbeddedWorkerInstanceClientOnIOThread,
std::move(client_receiver), GetIOTaskRunner()));
return;
}
EmbeddedWorkerInstanceClientImpl::Create( EmbeddedWorkerInstanceClientImpl::Create(
std::move(client_receiver), std::move(client_receiver),
GetWebMainThreadScheduler()->DefaultTaskRunner()); GetWebMainThreadScheduler()->DefaultTaskRunner());
......
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