From 0baf239ff8f9515304eff2aa26e6d90cf5671eba Mon Sep 17 00:00:00 2001 From: horo Date: Fri, 2 Oct 2015 02:09:48 -0700 Subject: Check the version_id in SWProviderContext::OnSetControllerServiceWorker(). If a SW error happens while fetching the SW controlled page's main resource, SWURLRequestJob::DidDispatchFetchEvent() calls SWProviderHost::NotifyControllerLost(). This method sends SetControllerServiceWorker IPC message with kInvalidServiceWorkerVersionId. In the current implementation, when ServiceWorkerProviderContext receives this message, it creates SWHandleReference with kInvalidServiceWorkerVersionId and set controller_. After that SWNetworkProvider::IsControlledByServiceWorker() will return true because it only checks the existence of the controller_. This makes inconsistency between the browser process and the page's rendere process. - The browser process treat as the page is not controlled by SW. - The the page's rendere process think as if it is controlled by SW. To fix this problem, this cl change SWProviderContext::OnSetControllerServiceWorker() to check the version_id. BUG=538512 Review URL: https://codereview.chromium.org/1385583002 Cr-Commit-Position: refs/heads/master@{#351983} --- .../child/service_worker/service_worker_provider_context.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'content/child') diff --git a/content/child/service_worker/service_worker_provider_context.cc b/content/child/service_worker/service_worker_provider_context.cc index 1a6deb0..a4b89db 100644 --- a/content/child/service_worker/service_worker_provider_context.cc +++ b/content/child/service_worker/service_worker_provider_context.cc @@ -93,11 +93,14 @@ void ServiceWorkerProviderContext::OnSetControllerServiceWorker( DCHECK(main_thread_task_runner_->RunsTasksOnCurrentThread()); DCHECK(registration_); - // This context is is the primary owner of this handle, keeps the - // initial reference until it goes away. - controller_ = - ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); - + if (info.version_id == kInvalidServiceWorkerVersionId) { + controller_.reset(); + } else { + // This context is is the primary owner of this handle, keeps the + // initial reference until it goes away. + controller_ = + ServiceWorkerHandleReference::Adopt(info, thread_safe_sender_.get()); + } // TODO(kinuko): We can forward the message to other threads here // when we support navigator.serviceWorker in dedicated workers. } -- cgit v1.1