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

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

Issue 2255383002: Allow a foreign fetch event handler to not handle an event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/foreign-fetch-basics.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/service_worker/service_worker_url_request_job.cc
diff --git a/content/browser/service_worker/service_worker_url_request_job.cc b/content/browser/service_worker/service_worker_url_request_job.cc
index c69bc87efbda43e9e323c6b7e8319970108d142e..f572008fa1add91d2ea295e9d61e834f68209b3e 100644
--- a/content/browser/service_worker/service_worker_url_request_job.cc
+++ b/content/browser/service_worker/service_worker_url_request_job.cc
@@ -250,11 +250,7 @@ ServiceWorkerURLRequestJob::~ServiceWorkerURLRequestJob() {
void ServiceWorkerURLRequestJob::FallbackToNetwork() {
DCHECK_EQ(NOT_DETERMINED, response_type_);
- // TODO(shimazu): Remove the condition of FOREIGN_FETCH after figuring out
- // what to do about CORS preflight and fallbacks for foreign fetch events.
- // http://crbug.com/604084
- DCHECK(!IsFallbackToRendererNeeded() ||
- (fetch_type_ == ServiceWorkerFetchType::FOREIGN_FETCH));
+ DCHECK(!IsFallbackToRendererNeeded());
response_type_ = FALLBACK_TO_NETWORK;
MaybeStartRequest();
}
@@ -876,7 +872,8 @@ void ServiceWorkerURLRequestJob::FinalizeFallbackToNetwork() {
void ServiceWorkerURLRequestJob::FinalizeFallbackToRenderer() {
// TODO(mek): http://crbug.com/604084 Figure out what to do about CORS
// preflight and fallbacks for foreign fetch events.
- fall_back_required_ = fetch_type_ != ServiceWorkerFetchType::FOREIGN_FETCH;
+ DCHECK_NE(fetch_type_, ServiceWorkerFetchType::FOREIGN_FETCH);
+ fall_back_required_ = true;
if (ShouldRecordResult())
RecordResult(ServiceWorkerMetrics::REQUEST_JOB_FALLBACK_FOR_CORS);
CreateResponseHeader(400, "Service Worker Fallback Required",
@@ -891,7 +888,12 @@ bool ServiceWorkerURLRequestJob::IsFallbackToRendererNeeded() const {
// document, we can't simply fallback to the network in the browser process.
// It is because the CORS preflight logic is implemented in the renderer. So
// we return a fall_back_required response to the renderer.
+ // If fetch_type is |FOREIGN_FETCH| any required CORS checks will have already
+ // been done in the renderer (and if a preflight was necesary the request
+ // would never have reached foreign fetch), so such requests can always
+ // fallback to the network directly.
return !IsMainResourceLoad() &&
+ fetch_type_ != ServiceWorkerFetchType::FOREIGN_FETCH &&
(request_mode_ == FETCH_REQUEST_MODE_CORS ||
request_mode_ == FETCH_REQUEST_MODE_CORS_WITH_FORCED_PREFLIGHT) &&
!request()->initiator().IsSameOriginWith(
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/http/tests/serviceworker/foreign-fetch-basics.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698