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

Unified Diff: content/browser/appcache/appcache_request_handler.cc

Issue 2974733002: Add support for subresource request fallback in AppCache for the network service.. (Closed)
Patch Set: Fix DCHECK Created 3 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/appcache/appcache_request_handler.cc
diff --git a/content/browser/appcache/appcache_request_handler.cc b/content/browser/appcache/appcache_request_handler.cc
index 652eff24a7acf59b8edd790ac25b29a544e3b5f2..b8eaaf2a0419b330b99071b8b8329be3c30b6c0b 100644
--- a/content/browser/appcache/appcache_request_handler.cc
+++ b/content/browser/appcache/appcache_request_handler.cc
@@ -127,19 +127,24 @@ AppCacheJob* AppCacheRequestHandler::MaybeLoadFallbackForRedirect(
if (request_->GetURL().GetOrigin() == location.GetOrigin())
return NULL;
- DCHECK(!job_.get()); // our jobs never generate redirects
+ // In network service land, the existing job initiates a fallback request.
+ if (!base::FeatureList::IsEnabled(features::kNetworkService)) {
+ DCHECK(!job_.get()); // our jobs never generate redirects
+ } else {
+ DCHECK(job_.get());
+ }
std::unique_ptr<AppCacheJob> job;
if (found_fallback_entry_.has_response_id()) {
+ job = MaybeCreateJobForFallback(network_delegate);
// 6.9.6, step 4: If this results in a redirect to another origin,
// get the resource of the fallback entry.
- job = CreateJob(network_delegate);
DeliverAppCachedResponse(found_fallback_entry_, found_cache_id_,
found_manifest_url_, true,
found_namespace_entry_url_);
} else if (!found_network_namespace_) {
// 6.9.6, step 6: Fail the resource load.
- job = CreateJob(network_delegate);
+ job = MaybeCreateJobForFallback(network_delegate);
DeliverErrorResponse();
} else {
// 6.9.6 step 3 and 5: Fetch the resource normally.
@@ -163,7 +168,7 @@ AppCacheJob* AppCacheRequestHandler::MaybeLoadFallbackForResponse(
}
// We don't fallback for responses that we delivered.
- if (job_.get()) {
+ if (job_.get() && !base::FeatureList::IsEnabled(features::kNetworkService)) {
DCHECK(!job_->IsDeliveringNetworkResponse());
return NULL;
}
@@ -186,7 +191,12 @@ AppCacheJob* AppCacheRequestHandler::MaybeLoadFallbackForResponse(
// 6.9.6, step 4: If this results in a 4xx or 5xx status code
// or there were network errors, get the resource of the fallback entry.
- std::unique_ptr<AppCacheJob> job = CreateJob(network_delegate);
+
+ // In network service land, the job initiates a fallback request. We reuse
+ // the existing job to deliver the fallback response.
+ std::unique_ptr<AppCacheJob> job =
+ MaybeCreateJobForFallback(network_delegate);
+
DeliverAppCachedResponse(found_fallback_entry_, found_cache_id_,
found_manifest_url_, true,
found_namespace_entry_url_);
@@ -342,6 +352,19 @@ std::unique_ptr<AppCacheJob> AppCacheRequestHandler::CreateJob(
return job;
}
+std::unique_ptr<AppCacheJob> AppCacheRequestHandler::MaybeCreateJobForFallback(
+ net::NetworkDelegate* network_delegate) {
+ std::unique_ptr<AppCacheJob> job;
+ // In network service land, the job initiates a fallback request. We reuse
+ // the existing job to deliver the fallback response.
+ if (!base::FeatureList::IsEnabled(features::kNetworkService)) {
+ job = CreateJob(network_delegate);
+ } else {
+ job.reset(job_.get());
+ }
+ return job;
+}
+
// Main-resource handling ----------------------------------------------
std::unique_ptr<AppCacheJob> AppCacheRequestHandler::MaybeLoadMainResource(

Powered by Google App Engine
This is Rietveld 408576698