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

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

Issue 2108573002: ServiceWorker: Add an API to fallback to renderer for CORS preflight (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update comment and move the check of foreign fetch Created 4 years, 5 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
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 <memory> 7 #include <memory>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 10
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 ServiceWorkerVersion* version) { 278 ServiceWorkerVersion* version) {
279 // The job may have been canceled and then destroyed before this was invoked. 279 // The job may have been canceled and then destroyed before this was invoked.
280 if (!job_) 280 if (!job_)
281 return; 281 return;
282 282
283 if (provider_host_) 283 if (provider_host_)
284 provider_host_->SetAllowAssociation(true); 284 provider_host_->SetAllowAssociation(true);
285 if (version != registration->active_version() || 285 if (version != registration->active_version() ||
286 version->status() != ServiceWorkerVersion::ACTIVATED || 286 version->status() != ServiceWorkerVersion::ACTIVATED ||
287 !provider_host_) { 287 !provider_host_) {
288 job_->FallbackToNetwork(); 288 job_->FallbackToNetworkOrRenderer();
falken 2016/07/07 01:11:12 Sorry I no longer understand this. We only get her
shimazu 2016/07/07 05:02:32 Ah, yes, it seems correct. Actually I'd like to us
289 return; 289 return;
290 } 290 }
291 291
292 ServiceWorkerMetrics::CountControlledPageLoad( 292 ServiceWorkerMetrics::CountControlledPageLoad(
293 stripped_url_, version->has_fetch_handler(), is_main_frame_load_); 293 stripped_url_, version->has_fetch_handler(), is_main_frame_load_);
294 294
295 provider_host_->AssociateRegistration(registration, 295 provider_host_->AssociateRegistration(registration,
296 false /* notify_controllerchange */); 296 false /* notify_controllerchange */);
297 job_->ForwardToServiceWorker(); 297 job_->ForwardToServiceWorker();
298 } 298 }
299 299
300 void ServiceWorkerControlleeRequestHandler::DidUpdateRegistration( 300 void ServiceWorkerControlleeRequestHandler::DidUpdateRegistration(
301 const scoped_refptr<ServiceWorkerRegistration>& original_registration, 301 const scoped_refptr<ServiceWorkerRegistration>& original_registration,
302 ServiceWorkerStatusCode status, 302 ServiceWorkerStatusCode status,
303 const std::string& status_message, 303 const std::string& status_message,
304 int64_t registration_id) { 304 int64_t registration_id) {
305 DCHECK(force_update_started_); 305 DCHECK(force_update_started_);
306 306
307 // The job may have been canceled and then destroyed before this was invoked. 307 // The job may have been canceled and then destroyed before this was invoked.
308 if (!job_) 308 if (!job_)
309 return; 309 return;
310 310
311 if (!context_) { 311 if (!context_) {
312 job_->FallbackToNetwork(); 312 job_->FallbackToNetworkOrRenderer();
313 return; 313 return;
314 } 314 }
315 if (status != SERVICE_WORKER_OK || 315 if (status != SERVICE_WORKER_OK ||
316 !original_registration->installing_version()) { 316 !original_registration->installing_version()) {
317 // Update failed. Look up the registration again since the original 317 // Update failed. Look up the registration again since the original
318 // registration was possibly unregistered in the meantime. 318 // registration was possibly unregistered in the meantime.
319 context_->storage()->FindRegistrationForDocument( 319 context_->storage()->FindRegistrationForDocument(
320 stripped_url_, base::Bind(&self::DidLookupRegistrationForMainResource, 320 stripped_url_, base::Bind(&self::DidLookupRegistrationForMainResource,
321 weak_factory_.GetWeakPtr())); 321 weak_factory_.GetWeakPtr()));
322 return; 322 return;
(...skipping 12 matching lines...) Expand all
335 } 335 }
336 336
337 void ServiceWorkerControlleeRequestHandler::OnUpdatedVersionStatusChanged( 337 void ServiceWorkerControlleeRequestHandler::OnUpdatedVersionStatusChanged(
338 const scoped_refptr<ServiceWorkerRegistration>& registration, 338 const scoped_refptr<ServiceWorkerRegistration>& registration,
339 const scoped_refptr<ServiceWorkerVersion>& version) { 339 const scoped_refptr<ServiceWorkerVersion>& version) {
340 // The job may have been canceled and then destroyed before this was invoked. 340 // The job may have been canceled and then destroyed before this was invoked.
341 if (!job_) 341 if (!job_)
342 return; 342 return;
343 343
344 if (!context_) { 344 if (!context_) {
345 job_->FallbackToNetwork(); 345 job_->FallbackToNetworkOrRenderer();
346 return; 346 return;
347 } 347 }
348 if (version->status() == ServiceWorkerVersion::ACTIVATED || 348 if (version->status() == ServiceWorkerVersion::ACTIVATED ||
349 version->status() == ServiceWorkerVersion::REDUNDANT) { 349 version->status() == ServiceWorkerVersion::REDUNDANT) {
350 // When the status is REDUNDANT, the update failed (eg: script error), we 350 // When the status is REDUNDANT, the update failed (eg: script error), we
351 // continue with the incumbent version. 351 // continue with the incumbent version.
352 // In case unregister job may have run, look up the registration again. 352 // In case unregister job may have run, look up the registration again.
353 context_->storage()->FindRegistrationForDocument( 353 context_->storage()->FindRegistrationForDocument(
354 stripped_url_, base::Bind(&self::DidLookupRegistrationForMainResource, 354 stripped_url_, base::Bind(&self::DidLookupRegistrationForMainResource,
355 weak_factory_.GetWeakPtr())); 355 weak_factory_.GetWeakPtr()));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 DCHECK(provider_host_); 401 DCHECK(provider_host_);
402 // Detach the controller so subresource requests also skip the worker. 402 // Detach the controller so subresource requests also skip the worker.
403 provider_host_->NotifyControllerLost(); 403 provider_host_->NotifyControllerLost();
404 } 404 }
405 405
406 void ServiceWorkerControlleeRequestHandler::ClearJob() { 406 void ServiceWorkerControlleeRequestHandler::ClearJob() {
407 job_.reset(); 407 job_.reset();
408 } 408 }
409 409
410 } // namespace content 410 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698