summaryrefslogtreecommitdiffstats
path: root/content/browser/service_worker
diff options
context:
space:
mode:
authorhoro <horo@chromium.org>2015-08-10 15:57:44 -0700
committerCommit bot <commit-bot@chromium.org>2015-08-10 22:58:27 +0000
commitbc0572e34764db29e996a95470a2339b6f3eb242 (patch)
tree1c4279606b587f4b67677ab43760c674d353cbdd /content/browser/service_worker
parentb3131d5bf11ef55dbbb54c0e84ae4bdb787a7ec2 (diff)
downloadchromium_src-bc0572e34764db29e996a95470a2339b6f3eb242.zip
chromium_src-bc0572e34764db29e996a95470a2339b6f3eb242.tar.gz
chromium_src-bc0572e34764db29e996a95470a2339b6f3eb242.tar.bz2
Set skip_service_worker in ServiceWorkerControlleeRequestHandler only for subresource requests.
https://codereview.chromium.org/1274973002/ accidentally changed the Service Worker behavior of handling redirected page requests. If we set skip_service_worker for page requests, the final location of redirects will not correctly be handled by Service Worker. So this cl change to set |skip_service_worker| only for subresource requests. https://codereview.chromium.org/1280243002 will add LayoutTests for fallbacked subresource requests. BUG=517364, 512764, 518713 Review URL: https://codereview.chromium.org/1280133002 Cr-Commit-Position: refs/heads/master@{#342722}
Diffstat (limited to 'content/browser/service_worker')
-rw-r--r--content/browser/service_worker/service_worker_controllee_request_handler.cc16
-rw-r--r--content/browser/service_worker/service_worker_controllee_request_handler.h2
2 files changed, 13 insertions, 5 deletions
diff --git a/content/browser/service_worker/service_worker_controllee_request_handler.cc b/content/browser/service_worker/service_worker_controllee_request_handler.cc
index a8af415..3977e3c 100644
--- a/content/browser/service_worker/service_worker_controllee_request_handler.cc
+++ b/content/browser/service_worker/service_worker_controllee_request_handler.cc
@@ -86,11 +86,8 @@ net::URLRequestJob* ServiceWorkerControlleeRequestHandler::MaybeCreateJob(
// We've come here by restart, we already have original request and it
// tells we should fallback to network. (Case B-c)
- // Once the request was fallbacked to the network, skip-service-worker flag
- // must be set and the request shoud not go to the service worker.
if ((job_.get() && job_->ShouldFallbackToNetwork()) || skip_service_worker_) {
- skip_service_worker_ = true;
- job_ = NULL;
+ FallbackToNetwork();
return NULL;
}
@@ -112,7 +109,7 @@ net::URLRequestJob* ServiceWorkerControlleeRequestHandler::MaybeCreateJob(
// If we know we can fallback to network at this point (in case
// the storage lookup returned immediately), just return NULL here to
// fallback to network.
- job_ = NULL;
+ FallbackToNetwork();
return NULL;
}
@@ -276,4 +273,13 @@ void ServiceWorkerControlleeRequestHandler::PrepareForSubResource() {
job_->ForwardToServiceWorker();
}
+void ServiceWorkerControlleeRequestHandler::FallbackToNetwork() {
+ // Once a subresource request was fallbacked to the network, we set
+ // |skip_service_worker_| because the request should not go to the service
+ // worker.
+ if (!is_main_resource_load_)
+ skip_service_worker_ = true;
+ job_ = NULL;
+}
+
} // namespace content
diff --git a/content/browser/service_worker/service_worker_controllee_request_handler.h b/content/browser/service_worker/service_worker_controllee_request_handler.h
index ecc554a..6426e05 100644
--- a/content/browser/service_worker/service_worker_controllee_request_handler.h
+++ b/content/browser/service_worker/service_worker_controllee_request_handler.h
@@ -68,6 +68,8 @@ class CONTENT_EXPORT ServiceWorkerControlleeRequestHandler
// For sub resource case.
void PrepareForSubResource();
+ void FallbackToNetwork();
+
bool is_main_resource_load_;
scoped_refptr<ServiceWorkerURLRequestJob> job_;
FetchRequestMode request_mode_;