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..8db5e59d2af5dd2613339268bc1ae17722559c0a 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,16 @@ std::unique_ptr<AppCacheJob> AppCacheRequestHandler::CreateJob( |
return job; |
} |
+std::unique_ptr<AppCacheJob> AppCacheRequestHandler::MaybeCreateJobForFallback( |
+ net::NetworkDelegate* network_delegate) { |
+ if (!base::FeatureList::IsEnabled(features::kNetworkService)) |
+ return CreateJob(network_delegate); |
+ // In network service land, the job initiates a fallback request. We reuse |
+ // the existing job to deliver the fallback response. |
+ DCHECK(job_.get()); |
+ return std::unique_ptr<AppCacheJob>(job_.get()); |
+} |
+ |
// Main-resource handling ---------------------------------------------- |
std::unique_ptr<AppCacheJob> AppCacheRequestHandler::MaybeLoadMainResource( |