summaryrefslogtreecommitdiffstats
path: root/content/child
diff options
context:
space:
mode:
authorhoro <horo@chromium.org>2015-10-02 02:09:48 -0700
committerCommit bot <commit-bot@chromium.org>2015-10-02 09:10:43 +0000
commit0baf239ff8f9515304eff2aa26e6d90cf5671eba (patch)
tree1f295cf4e32d222019e6017e7d59ccb084707af6 /content/child
parent5a28015f3997b512f326736998b5cb4474cb7739 (diff)
downloadchromium_src-0baf239ff8f9515304eff2aa26e6d90cf5671eba.zip
chromium_src-0baf239ff8f9515304eff2aa26e6d90cf5671eba.tar.gz
chromium_src-0baf239ff8f9515304eff2aa26e6d90cf5671eba.tar.bz2
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}
Diffstat (limited to 'content/child')
-rw-r--r--content/child/service_worker/service_worker_provider_context.cc13
1 files changed, 8 insertions, 5 deletions
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.
}