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

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

Issue 2982363002: Add support for fallback content for the frame. This includes main and subframes. (Closed)
Patch Set: Changed the MaybeCreateLoaderForResponse function to return the URLLoaderPtr and URLLoaderClientReq… 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 8db5e59d2af5dd2613339268bc1ae17722559c0a..6e828e0839d134033f19567a2433a4b1c3505a0a 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
+ // destroyed when the client disconnects.
+ navigation_request_job_.release();
}
void AppCacheRequestHandler::DeliverErrorResponse() {
@@ -309,13 +313,22 @@ 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
+ // destroyed when the client disconnects.
+ navigation_request_job_.release();
}
void AppCacheRequestHandler::DeliverNetworkResponse() {
DCHECK(job_.get() && job_->IsWaiting());
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.
+ navigation_request_job_.reset(nullptr);
}
void AppCacheRequestHandler::OnPrepareToRestart() {
@@ -354,8 +367,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.
DCHECK(job_.get());
@@ -580,6 +595,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.
navigation_request_job_->AsURLLoaderJob()->set_main_resource_loader_callback(
std::move(callback));
}
@@ -595,4 +612,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

Powered by Google App Engine
This is Rietveld 408576698