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

Side by Side Diff: content/browser/service_worker/service_worker_controllee_request_handler.cc

Issue 445883003: ServiceWorker: Consolidate version change messages (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_provider_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/service_worker/service_worker_controllee_request_handl er.h" 5 #include "content/browser/service_worker/service_worker_controllee_request_handl er.h"
6 6
7 #include "content/browser/service_worker/service_worker_context_core.h" 7 #include "content/browser/service_worker/service_worker_context_core.h"
8 #include "content/browser/service_worker/service_worker_metrics.h" 8 #include "content/browser/service_worker/service_worker_metrics.h"
9 #include "content/browser/service_worker/service_worker_provider_host.h" 9 #include "content/browser/service_worker/service_worker_provider_host.h"
10 #include "content/browser/service_worker/service_worker_registration.h" 10 #include "content/browser/service_worker/service_worker_registration.h"
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 original_url_via_service_worker); 108 original_url_via_service_worker);
109 } 109 }
110 110
111 void ServiceWorkerControlleeRequestHandler::PrepareForMainResource( 111 void ServiceWorkerControlleeRequestHandler::PrepareForMainResource(
112 const GURL& url) { 112 const GURL& url) {
113 DCHECK(job_.get()); 113 DCHECK(job_.get());
114 DCHECK(context_); 114 DCHECK(context_);
115 // The corresponding provider_host may already have associated a registration 115 // The corresponding provider_host may already have associated a registration
116 // in redirect case, unassociate it now. 116 // in redirect case, unassociate it now.
117 provider_host_->UnassociateRegistration(); 117 provider_host_->UnassociateRegistration();
118 provider_host_->SetControllerVersion(NULL);
119 118
120 GURL stripped_url = net::SimplifyUrlForRequest(url); 119 GURL stripped_url = net::SimplifyUrlForRequest(url);
121 provider_host_->SetDocumentUrl(stripped_url); 120 provider_host_->SetDocumentUrl(stripped_url);
122 context_->storage()->FindRegistrationForDocument( 121 context_->storage()->FindRegistrationForDocument(
123 stripped_url, 122 stripped_url,
124 base::Bind(&self::DidLookupRegistrationForMainResource, 123 base::Bind(&self::DidLookupRegistrationForMainResource,
125 weak_factory_.GetWeakPtr())); 124 weak_factory_.GetWeakPtr()));
126 } 125 }
127 126
128 void 127 void
(...skipping 30 matching lines...) Expand all
159 return; 158 return;
160 } 159 }
161 160
162 if (!active_version || 161 if (!active_version ||
163 active_version->status() != ServiceWorkerVersion::ACTIVATED) { 162 active_version->status() != ServiceWorkerVersion::ACTIVATED) {
164 job_->FallbackToNetwork(); 163 job_->FallbackToNetwork();
165 return; 164 return;
166 } 165 }
167 166
168 provider_host_->AssociateRegistration(registration); 167 provider_host_->AssociateRegistration(registration);
169 provider_host_->SetControllerVersion(registration->active_version());
170
171 job_->ForwardToServiceWorker(); 168 job_->ForwardToServiceWorker();
172 } 169 }
173 170
174 void ServiceWorkerControlleeRequestHandler::OnVersionStatusChanged( 171 void ServiceWorkerControlleeRequestHandler::OnVersionStatusChanged(
175 ServiceWorkerRegistration* registration, 172 ServiceWorkerRegistration* registration,
176 ServiceWorkerVersion* version) { 173 ServiceWorkerVersion* version) {
177 if (version != registration->active_version() || 174 if (version != registration->active_version() ||
178 version->status() != ServiceWorkerVersion::ACTIVATED) { 175 version->status() != ServiceWorkerVersion::ACTIVATED) {
179 job_->FallbackToNetwork(); 176 job_->FallbackToNetwork();
180 return; 177 return;
181 } 178 }
182 179
183 provider_host_->AssociateRegistration(registration); 180 provider_host_->AssociateRegistration(registration);
184 provider_host_->SetControllerVersion(registration->active_version());
185
186 job_->ForwardToServiceWorker(); 181 job_->ForwardToServiceWorker();
187 } 182 }
188 183
189 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() { 184 void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() {
190 DCHECK(job_.get()); 185 DCHECK(job_.get());
191 DCHECK(context_); 186 DCHECK(context_);
192 DCHECK(provider_host_->active_version()); 187 DCHECK(provider_host_->active_version());
193 job_->ForwardToServiceWorker(); 188 job_->ForwardToServiceWorker();
194 } 189 }
195 190
196 } // namespace content 191 } // namespace content
OLDNEW
« 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