Chromium Code Reviews| 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 8db5e59d2af5dd2613339268bc1ae17722559c0a..543676e2411c1351b691b0961d71af58810abe4e 100644 |
| --- a/content/browser/appcache/appcache_request_handler.cc |
| +++ b/content/browser/appcache/appcache_request_handler.cc |
| @@ -302,6 +302,10 @@ void AppCacheRequestHandler::DeliverAppCachedResponse( |
| host_->NotifyMainResourceIsNamespaceEntry(namespace_entry_url); |
| job_->DeliverAppCachedResponse(manifest_url, cache_id, entry, is_fallback); |
| + // In the network service world, we need to release the AppCacheJob instance |
| + // created for handling navigation requests. These instances will get |
|
kinuko
2017/07/28 09:50:28
nit: extra space
ananta
2017/07/28 22:59:22
Done.
|
| + // destroyed when the client disconnects. |
| + navigation_request_job_.release(); |
| } |
| void AppCacheRequestHandler::DeliverErrorResponse() { |
| @@ -309,6 +313,10 @@ void AppCacheRequestHandler::DeliverErrorResponse() { |
| DCHECK_EQ(kAppCacheNoCacheId, cache_id_); |
| DCHECK(manifest_url_.is_empty()); |
| job_->DeliverErrorResponse(); |
| + // In the network service world, we need to release the AppCacheJob instance |
| + // created for handling navigation requests. These instances will get |
|
kinuko
2017/07/28 09:50:28
ditto
ananta
2017/07/28 22:59:22
Done.
|
| + // destroyed when the client disconnects. |
| + navigation_request_job_.release(); |
| } |
| void AppCacheRequestHandler::DeliverNetworkResponse() { |
| @@ -316,6 +324,10 @@ void AppCacheRequestHandler::DeliverNetworkResponse() { |
| DCHECK_EQ(kAppCacheNoCacheId, cache_id_); |
| DCHECK(manifest_url_.is_empty()); |
| job_->DeliverNetworkResponse(); |
| + |
| + // In the network service world, we need to destroy the AppCacheJob instance |
| + // created for handling navigation requests. |
|
kinuko
2017/07/28 09:50:28
ditto
ananta
2017/07/28 22:59:22
Done.
|
| + navigation_request_job_.reset(nullptr); |
| } |
| void AppCacheRequestHandler::OnPrepareToRestart() { |
| @@ -354,8 +366,10 @@ std::unique_ptr<AppCacheJob> AppCacheRequestHandler::CreateJob( |
| std::unique_ptr<AppCacheJob> AppCacheRequestHandler::MaybeCreateJobForFallback( |
| net::NetworkDelegate* network_delegate) { |
| - if (!base::FeatureList::IsEnabled(features::kNetworkService)) |
| + if (!base::FeatureList::IsEnabled(features::kNetworkService) || |
| + IsMainResourceType(resource_type_)) { |
| return CreateJob(network_delegate); |
| + } |
| // In network service land, the job initiates a fallback request. We reuse |
| // the existing job to deliver the fallback response. |
|
kinuko
2017/07/28 09:50:28
This comment doesn't explain why we have IsMainRes
|
| DCHECK(job_.get()); |
| @@ -580,6 +594,8 @@ void AppCacheRequestHandler::MaybeCreateLoader( |
| std::move(callback).Run(StartLoaderCallback()); |
| return; |
| } |
| + // The AppCacheJob for the navigation request will get destroyed when the |
| + // client connection is dropped. |
|
michaeln
2017/07/28 19:11:02
the lifetime is explained well enough in other com
ananta
2017/07/28 22:59:22
Thanks. Removed
|
| navigation_request_job_->AsURLLoaderJob()->set_main_resource_loader_callback( |
| std::move(callback)); |
| } |
| @@ -595,4 +611,24 @@ AppCacheRequestHandler::MaybeCreateSubresourceFactory() { |
| return factory_ptr; |
| } |
| +bool AppCacheRequestHandler::MaybeCreateLoaderForResponse( |
| + const ResourceResponseHead& response, |
| + mojom::URLLoaderPtr* loader, |
| + mojom::URLLoaderClientRequest* client_request) { |
| + request_->AsURLLoaderRequest()->set_response(response); |
| + // The AppCacheJob will get destroyed when the client connection is |
| + // dropped. |
| + AppCacheJob* job = MaybeLoadFallbackForResponse(nullptr); |
| + if (job) { |
| + mojom::URLLoaderClientPtr client; |
| + *client_request = mojo::MakeRequest(&client); |
| + mojom::URLLoaderRequest loader_request = mojo::MakeRequest(loader); |
| + |
| + job->AsURLLoaderJob()->BindRequest(std::move(client), |
| + std::move(loader_request)); |
| + return true; |
| + } |
| + return false; |
| +} |
| + |
| } // namespace content |