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

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

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: Remove dependency 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_url_request_job.cc » ('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.h
diff --git a/content/browser/service_worker/service_worker_url_request_job.h b/content/browser/service_worker/service_worker_url_request_job.h
index 029871bed969260948766f54e73c318123c609b3..f77ff43de7e57c73d1ecf2ad3a4bdd91c47ea001 100644
--- a/content/browser/service_worker/service_worker_url_request_job.h
+++ b/content/browser/service_worker/service_worker_url_request_job.h
@@ -103,7 +103,16 @@ class CONTENT_EXPORT ServiceWorkerURLRequestJob
~ServiceWorkerURLRequestJob() override;
// Sets the response type.
+ // When an in-flight request possibly needs CORS check, use
+ // FallbackToNetworkOrRenderer. This method will decide whether the request
+ // can directly go to the network or should fallback to a renderer to send
+ // CORS preflight. You can use FallbackToNetwork only when, like main resource
+ // or foreign fetch cases, it's apparent that the request should go to the
+ // network directly.
+ // TODO(shimazu): Update the comment when what should we do at foreign fetch
+ // fallback is determined: crbug.com/604084
void FallbackToNetwork();
+ void FallbackToNetworkOrRenderer();
void ForwardToServiceWorker();
bool ShouldFallbackToNetwork() const {
@@ -156,6 +165,7 @@ class CONTENT_EXPORT ServiceWorkerURLRequestJob
enum ResponseType {
NOT_DETERMINED,
FALLBACK_TO_NETWORK,
+ FALLBACK_TO_RENDERER, // Use this when falling back with CORS check
FORWARD_TO_SERVICE_WORKER,
};
@@ -199,6 +209,19 @@ class CONTENT_EXPORT ServiceWorkerURLRequestJob
// Creates and commits a response header indicating error.
void DeliverErrorResponse();
+ // Restarts this job to fallback to network.
+ // This can be called after StartRequest.
+ void FinalizeFallbackToNetwork();
+
+ // Sends back a response with fall_back_required set as true to trigger
+ // subsequent network requests with CORS checking.
+ // This can be called after StartRequest.
+ void FinalizeFallbackToRenderer();
+
+ // True if need to send back a response with fall_back_required set as true to
+ // trigger subsequent network requests with CORS checking.
+ bool IsFallbackToRendererNeeded() const;
+
// For UMA.
void SetResponseBodyType(ResponseBodyType type);
bool ShouldRecordResult();
« no previous file with comments | « no previous file | content/browser/service_worker/service_worker_url_request_job.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698