Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(172)

Unified Diff: content/browser/service_worker/service_worker_controllee_request_handler.cc

Issue 558873003: Better coordinate what's responsible for associating a registration to a document. During navigatio… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_provider_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_controllee_request_handler.cc
diff --git a/content/browser/service_worker/service_worker_controllee_request_handler.cc b/content/browser/service_worker/service_worker_controllee_request_handler.cc
index c290ee66aaee4ce35170e692a0029ddc4a0c3ea6..3cc931ad6c64790292baa3258b0a9490f88bb87c 100644
--- a/content/browser/service_worker/service_worker_controllee_request_handler.cc
+++ b/content/browser/service_worker/service_worker_controllee_request_handler.cc
@@ -45,6 +45,9 @@ ServiceWorkerControlleeRequestHandler::
else
provider_host_->active_version()->DeferScheduledUpdate();
}
+
+ if (is_main_resource_load_ && provider_host_)
+ provider_host_->SetAllowAssociation(true);
}
net::URLRequestJob* ServiceWorkerControlleeRequestHandler::MaybeCreateJob(
@@ -116,6 +119,10 @@ void ServiceWorkerControlleeRequestHandler::PrepareForMainResource(
// in redirect case, unassociate it now.
provider_host_->DisassociateRegistration();
+ // Also prevent a registrater job for establishing an association to a new
+ // registration while we're finding an existing registration.
+ provider_host_->SetAllowAssociation(false);
+
GURL stripped_url = net::SimplifyUrlForRequest(url);
provider_host_->SetDocumentUrl(stripped_url);
context_->storage()->FindRegistrationForDocument(
@@ -129,6 +136,7 @@ ServiceWorkerControlleeRequestHandler::DidLookupRegistrationForMainResource(
ServiceWorkerStatusCode status,
const scoped_refptr<ServiceWorkerRegistration>& registration) {
DCHECK(job_.get());
+ provider_host_->SetAllowAssociation(true);
if (status != SERVICE_WORKER_OK) {
job_->FallbackToNetwork();
TRACE_EVENT_ASYNC_END1(
@@ -155,6 +163,7 @@ ServiceWorkerControlleeRequestHandler::DidLookupRegistrationForMainResource(
// Wait until it's activated before firing fetch events.
if (active_version.get() &&
active_version->status() == ServiceWorkerVersion::ACTIVATING) {
+ provider_host_->SetAllowAssociation(false);
registration->active_version()->RegisterStatusChangeCallback(
base::Bind(&self::OnVersionStatusChanged,
weak_factory_.GetWeakPtr(),
@@ -196,12 +205,12 @@ ServiceWorkerControlleeRequestHandler::DidLookupRegistrationForMainResource(
void ServiceWorkerControlleeRequestHandler::OnVersionStatusChanged(
ServiceWorkerRegistration* registration,
ServiceWorkerVersion* version) {
+ provider_host_->SetAllowAssociation(true);
if (version != registration->active_version() ||
version->status() != ServiceWorkerVersion::ACTIVATED) {
job_->FallbackToNetwork();
return;
}
-
provider_host_->AssociateRegistration(registration);
job_->ForwardToServiceWorker();
}
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_provider_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698