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

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: Use FallbackToNetwork and update the comment 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
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..df6a2ebc8fdbc5b0ee3d2483d8b9cfc69c7141c1 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 need CORS check, use
falken 2016/07/07 05:15:34 needs
shimazu 2016/07/07 06:23:52 Done.
+ // 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();

Powered by Google App Engine
This is Rietveld 408576698