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

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

Issue 1478103002: [WIP] [service worker] Fix detach controller and fallback to network mechanism (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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_url_request_job.h" 5 #include "content/browser/service_worker/service_worker_url_request_job.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 568 matching lines...) Expand 10 before | Expand all | Expand 10 after
579 DeliverErrorResponse(); 579 DeliverErrorResponse();
580 return; 580 return;
581 } 581 }
582 582
583 if (status != SERVICE_WORKER_OK) { 583 if (status != SERVICE_WORKER_OK) {
584 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_ERROR_FETCH_EVENT_DISPATCH); 584 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_ERROR_FETCH_EVENT_DISPATCH);
585 if (is_main_resource_load_) { 585 if (is_main_resource_load_) {
586 // Using the service worker failed, so fallback to network. Detach the 586 // Using the service worker failed, so fallback to network. Detach the
587 // controller so subresource requests also skip the worker. 587 // controller so subresource requests also skip the worker.
588 provider_host_->NotifyControllerLost(); 588 provider_host_->NotifyControllerLost();
589 response_type_ = FALLBACK_TO_NETWORK; 589 fall_back_required_ = true;
590 NotifyRestartRequired(); 590 CreateResponseHeader(400, "Service Worker Fallback Required",
591 ServiceWorkerHeaderMap());
592 CommitResponseHeader();
591 } else { 593 } else {
592 DeliverErrorResponse(); 594 DeliverErrorResponse();
593 } 595 }
594 return; 596 return;
595 } 597 }
596 598
597 if (fetch_result == SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK) { 599 if (fetch_result == SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK) {
598 ServiceWorkerMetrics::RecordFallbackedRequestMode(request_mode_); 600 ServiceWorkerMetrics::RecordFallbackedRequestMode(request_mode_);
599 // When the request_mode is |CORS| or |CORS-with-forced-preflight| and the 601 // When the request_mode is |CORS| or |CORS-with-forced-preflight| and the
600 // origin of the request URL is different from the security origin of the 602 // origin of the request URL is different from the security origin of the
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 } 797 }
796 if (!waiting_stream_url_.is_empty()) { 798 if (!waiting_stream_url_.is_empty()) {
797 StreamRegistry* stream_registry = 799 StreamRegistry* stream_registry =
798 GetStreamContextForResourceContext(resource_context_)->registry(); 800 GetStreamContextForResourceContext(resource_context_)->registry();
799 stream_registry->RemoveRegisterObserver(waiting_stream_url_); 801 stream_registry->RemoveRegisterObserver(waiting_stream_url_);
800 stream_registry->AbortPendingStream(waiting_stream_url_); 802 stream_registry->AbortPendingStream(waiting_stream_url_);
801 } 803 }
802 } 804 }
803 805
804 } // namespace content 806 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698