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

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: rebase to tip 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..a4c19503c9101d10690714bed956a6bf5f493dd5 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,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
+ // destroyed when the client disconnects.
+ navigation_request_job_.release();
}
void AppCacheRequestHandler::DeliverNetworkResponse() {
@@ -316,6 +324,9 @@ 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.
+ navigation_request_job_.reset(nullptr);
}
void AppCacheRequestHandler::OnPrepareToRestart() {
@@ -354,8 +365,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());
@@ -595,4 +608,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
« no previous file with comments | « content/browser/appcache/appcache_request_handler.h ('k') | content/browser/appcache/appcache_url_loader_job.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698