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

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

Issue 2956373002: Add support for subresource request loads in AppCache for the network service. (Closed)
Patch Set: Moved the SubresourceLoadInfo structure to the appcache_url_loader_job.h/.cc files. Created 3 years, 6 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_subresource_url_factory.cc
diff --git a/content/browser/appcache/appcache_subresource_url_factory.cc b/content/browser/appcache/appcache_subresource_url_factory.cc
index d90257f3687e7677b5226e9e187ed7d4dd3d13b2..fb14303c50e7bf57af7e66ec841be92322bd8059 100644
--- a/content/browser/appcache/appcache_subresource_url_factory.cc
+++ b/content/browser/appcache/appcache_subresource_url_factory.cc
@@ -6,6 +6,7 @@
#include "base/bind.h"
#include "base/logging.h"
+#include "content/browser/appcache/appcache_host.h"
#include "content/browser/appcache/appcache_request_handler.h"
#include "content/browser/appcache/appcache_url_loader_job.h"
#include "content/browser/appcache/appcache_url_loader_request.h"
@@ -23,9 +24,11 @@ namespace content {
// Implements the URLLoaderFactory mojom for AppCache requests.
AppCacheSubresourceURLFactory::AppCacheSubresourceURLFactory(
mojom::URLLoaderFactoryRequest request,
- URLLoaderFactoryGetter* default_url_loader_factory_getter)
+ URLLoaderFactoryGetter* default_url_loader_factory_getter,
+ base::WeakPtr<AppCacheHost> host)
: binding_(this, std::move(request)),
- default_url_loader_factory_getter_(default_url_loader_factory_getter) {
+ default_url_loader_factory_getter_(default_url_loader_factory_getter),
+ appcache_host_(host->GetWeakPtr()) {
kinuko 2017/07/03 06:34:15 |host|'s already weakptr, isn't it?
ananta 2017/07/03 07:36:47 Sorry I missed this. Fixed
binding_.set_connection_error_handler(
base::Bind(&AppCacheSubresourceURLFactory::OnConnectionError,
base::Unretained(this)));
@@ -34,17 +37,17 @@ AppCacheSubresourceURLFactory::AppCacheSubresourceURLFactory(
AppCacheSubresourceURLFactory::~AppCacheSubresourceURLFactory() {}
// static
-mojom::URLLoaderFactoryPtr
+AppCacheSubresourceURLFactory*
AppCacheSubresourceURLFactory::CreateURLLoaderFactory(
- URLLoaderFactoryGetter* default_url_loader_factory_getter) {
- mojom::URLLoaderFactoryPtr loader_factory;
- mojom::URLLoaderFactoryRequest request = mojo::MakeRequest(&loader_factory);
+ URLLoaderFactoryGetter* default_url_loader_factory_getter,
+ base::WeakPtr<AppCacheHost> host,
+ mojom::URLLoaderFactoryPtr* loader_factory) {
+ mojom::URLLoaderFactoryRequest request = mojo::MakeRequest(loader_factory);
// This instance will get deleted when the client drops the connection.
// Please see OnConnectionError() for details.
- new AppCacheSubresourceURLFactory(std::move(request),
- default_url_loader_factory_getter);
- return loader_factory;
+ return new AppCacheSubresourceURLFactory(
+ std::move(request), default_url_loader_factory_getter, host);
}
void AppCacheSubresourceURLFactory::CreateLoaderAndStart(
@@ -57,11 +60,36 @@ void AppCacheSubresourceURLFactory::CreateLoaderAndStart(
const net::MutableNetworkTrafficAnnotationTag& traffic_annotation) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
DLOG(WARNING) << "Received request for loading : " << request.url.spec();
- default_url_loader_factory_getter_->GetNetworkFactory()
- ->get()
- ->CreateLoaderAndStart(mojom::URLLoaderAssociatedRequest(), routing_id,
- request_id, options, request, std::move(client),
- traffic_annotation);
+
+ // If the host is invalid, it means that the renderer has probably died.
+ // (Frame has navigated elsewhere?)
+ if (!appcache_host_.get())
+ return;
+
+ std::unique_ptr<AppCacheRequestHandler> handler =
+ appcache_host_->CreateRequestHandler(
+ AppCacheURLLoaderRequest::Create(request), request.resource_type,
+ request.should_reset_appcache);
+ if (!handler)
+ return;
+
+ handler->set_network_url_loader_factory_getter(
+ default_url_loader_factory_getter_.get());
+
+ std::unique_ptr<SubresourceLoadInfo> load_info(new SubresourceLoadInfo());
+ load_info->url_loader_request = std::move(url_loader_request);
+ load_info->routing_id = routing_id;
+ load_info->request_id = request_id;
+ load_info->options = options;
+ load_info->request = request;
+ load_info->client = std::move(client);
+ load_info->traffic_annotation = traffic_annotation;
+
+ handler->SetSubresourceRequestLoadInfo(std::move(load_info));
+
+ handler->MaybeLoadResource(nullptr);
+ // The handler is owned by the job.
+ handler.release();
kinuko 2017/07/03 06:34:15 MaybeLoadResource may not call CreateJob, then wou
ananta 2017/07/03 07:36:47 Thanks. done. I added a setter to the AppCacheURLL
}
void AppCacheSubresourceURLFactory::SyncLoad(int32_t routing_id,

Powered by Google App Engine
This is Rietveld 408576698