Commit 13d8e7ec authored by Kenichi Ishibashi's avatar Kenichi Ishibashi Committed by Commit Bot

Use task runner for DCHECK in ServiceWorkerGlobalScopeProxy

There were some DCHECK(IsMainThread()) in
ServiceWorkerGlobalScopeProxy. When we move service worker
startup off the main thread, these DCHECKs will start
failing. Use |parent_task_runner_| instead.

Bug: 692909
Change-Id: I92c788184b9b3753bf6eb2eec5393471e70e439e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1732669Reviewed-by: default avatarHiroki Nakagawa <nhiroki@chromium.org>
Commit-Queue: Kenichi Ishibashi <bashi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#683485}
parent 5f31be18
......@@ -68,7 +68,7 @@ ServiceWorkerGlobalScopeProxy::Create(WebEmbeddedWorkerImpl& embedded_worker,
}
ServiceWorkerGlobalScopeProxy::~ServiceWorkerGlobalScopeProxy() {
DCHECK(IsMainThread());
DCHECK(parent_task_runner_->BelongsToCurrentThread());
// Verify that the proxy has been detached.
DCHECK(!embedded_worker_);
}
......@@ -312,19 +312,18 @@ ServiceWorkerGlobalScopeProxy::ServiceWorkerGlobalScopeProxy(
: embedded_worker_(&embedded_worker),
client_(&client),
worker_global_scope_(nullptr) {
DCHECK(IsMainThread());
DETACH_FROM_THREAD(worker_thread_checker_);
parent_task_runner_ = Thread::Current()->GetTaskRunner();
}
void ServiceWorkerGlobalScopeProxy::Detach() {
DCHECK(IsMainThread());
DCHECK(parent_task_runner_->BelongsToCurrentThread());
embedded_worker_ = nullptr;
client_ = nullptr;
}
void ServiceWorkerGlobalScopeProxy::TerminateWorkerContext() {
DCHECK(IsMainThread());
DCHECK(parent_task_runner_->BelongsToCurrentThread());
embedded_worker_->TerminateWorkerContext();
}
......
......@@ -62,6 +62,9 @@ class WebServiceWorkerContextClient;
// An instance of this class is supposed to outlive until
// workerThreadTerminated() is called by its corresponding
// WorkerGlobalScope.
//
// TODO(bashi): Update the above comment and method comments once we move
// creation of this class off the main thread.
class ServiceWorkerGlobalScopeProxy final : public WebServiceWorkerContextProxy,
public WorkerReportingProxy {
public:
......
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