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

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

Issue 1282193002: Reland of Skip the Service Worker CORS fallback for same origin requests. [2/2 chromium] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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
« no previous file with comments | « no previous file | no next file » | 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_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 585 matching lines...) Expand 10 before | Expand all | Expand 10 after
596 response_type_ = FALLBACK_TO_NETWORK; 596 response_type_ = FALLBACK_TO_NETWORK;
597 NotifyRestartRequired(); 597 NotifyRestartRequired();
598 } else { 598 } else {
599 DeliverErrorResponse(); 599 DeliverErrorResponse();
600 } 600 }
601 return; 601 return;
602 } 602 }
603 603
604 if (fetch_result == SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK) { 604 if (fetch_result == SERVICE_WORKER_FETCH_EVENT_RESULT_FALLBACK) {
605 ServiceWorkerMetrics::RecordFallbackedRequestMode(request_mode_); 605 ServiceWorkerMetrics::RecordFallbackedRequestMode(request_mode_);
606 // When the request_mode is |CORS| or |CORS-with-forced-preflight| we can't 606 // When the request_mode is |CORS| or |CORS-with-forced-preflight| and the
607 // simply fallback to the network in the browser process. It is because the 607 // origin of the request URL is different from the security origin of the
608 // CORS preflight logic is implemented in the renderer. So we returns a 608 // document, we can't simply fallback to the network in the browser process.
609 // fall_back_required response to the renderer. 609 // It is because the CORS preflight logic is implemented in the renderer. So
610 if (request_mode_ == FETCH_REQUEST_MODE_CORS || 610 // we returns a fall_back_required response to the renderer.
611 request_mode_ == FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT) { 611 if ((request_mode_ == FETCH_REQUEST_MODE_CORS ||
612 request_mode_ == FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT) &&
613 provider_host_->document_url().GetOrigin() !=
614 request()->url().GetOrigin()) {
612 fall_back_required_ = true; 615 fall_back_required_ = true;
613 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_FALLBACK_FOR_CORS); 616 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_FALLBACK_FOR_CORS);
614 CreateResponseHeader( 617 CreateResponseHeader(
615 400, "Service Worker Fallback Required", ServiceWorkerHeaderMap()); 618 400, "Service Worker Fallback Required", ServiceWorkerHeaderMap());
616 CommitResponseHeader(); 619 CommitResponseHeader();
617 return; 620 return;
618 } 621 }
619 // Change the response type and restart the request to fallback to 622 // Change the response type and restart the request to fallback to
620 // the network. 623 // the network.
621 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_FALLBACK_RESPONSE); 624 RecordResult(ServiceWorkerMetrics::REQUEST_JOB_FALLBACK_RESPONSE);
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 } 802 }
800 if (!waiting_stream_url_.is_empty()) { 803 if (!waiting_stream_url_.is_empty()) {
801 StreamRegistry* stream_registry = 804 StreamRegistry* stream_registry =
802 GetStreamContextForResourceContext(resource_context_)->registry(); 805 GetStreamContextForResourceContext(resource_context_)->registry();
803 stream_registry->RemoveRegisterObserver(waiting_stream_url_); 806 stream_registry->RemoveRegisterObserver(waiting_stream_url_);
804 stream_registry->AbortPendingStream(waiting_stream_url_); 807 stream_registry->AbortPendingStream(waiting_stream_url_);
805 } 808 }
806 } 809 }
807 810
808 } // namespace content 811 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698