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

Unified Diff: content/browser/loader/navigation_url_loader_network_service.cc

Issue 2854723002: Network service: avoid requesting a new URLLoaderFactory for each NavigationURLLoaderNetworkService. (Closed)
Patch Set: . Created 3 years, 8 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/loader/navigation_url_loader_network_service.cc
diff --git a/content/browser/loader/navigation_url_loader_network_service.cc b/content/browser/loader/navigation_url_loader_network_service.cc
index b478bc68b5f1193c4f4845766fee62e387da7110..fc4fb7ebb44b3d03035eeaf15baa705b2ea4cc4b 100644
--- a/content/browser/loader/navigation_url_loader_network_service.cc
+++ b/content/browser/loader/navigation_url_loader_network_service.cc
@@ -30,9 +30,9 @@
namespace content {
namespace {
+
static base::LazyInstance<mojom::URLLoaderFactoryPtr>::Leaky
g_url_loader_factory = LAZY_INSTANCE_INITIALIZER;
-}
// This function is called on the IO thread for POST/PUT requests for
// attaching blob information to the request body.
@@ -51,6 +51,8 @@ void HandleRequestsWithBody(
url_loader, base::Passed(&request)));
}
+} // namespace
+
NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService(
ResourceContext* resource_context,
StoragePartition* storage_partition,
@@ -67,15 +69,6 @@ NavigationURLLoaderNetworkService::NavigationURLLoaderNetworkService(
request_info->common_params.navigation_start, "FrameTreeNode id",
request_info->frame_tree_node_id);
- // TODO(scottmg): Maybe some of this setup should be done only once, instead
- // of every time.
- if (g_url_loader_factory.Get().get()) {
- url_loader_factory_ = std::move(g_url_loader_factory.Get());
- } else {
- ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface(
- mojom::kNetworkServiceName, &url_loader_factory_);
- }
-
// TODO(scottmg): Port over stuff from RDHI::BeginNavigationRequest() here.
auto new_request = base::MakeUnique<ResourceRequest>();
@@ -206,10 +199,22 @@ void NavigationURLLoaderNetworkService::StartURLRequest(
mojom::URLLoaderClientPtr url_loader_client_ptr_to_pass;
binding_.Bind(&url_loader_client_ptr_to_pass);
- url_loader_factory_->CreateLoaderAndStart(
+ GetURLLoaderFactory().CreateLoaderAndStart(
mojo::MakeRequest(&url_loader_associated_ptr_), 0 /* routing_id? */,
0 /* request_id? */, mojom::kURLLoadOptionSendSSLInfo, *request,
std::move(url_loader_client_ptr_to_pass));
}
+mojom::URLLoaderFactory&
+NavigationURLLoaderNetworkService::GetURLLoaderFactory() {
+ // TODO(yzshen): We will need the ability to customize the factory per frame
+ // e.g., for appcache or service worker.
+ if (!g_url_loader_factory.Get()) {
+ ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface(
+ mojom::kNetworkServiceName, &g_url_loader_factory.Get());
+ }
+
+ return *g_url_loader_factory.Get();
+}
+
} // namespace content
« no previous file with comments | « content/browser/loader/navigation_url_loader_network_service.h ('k') | content/browser/site_per_process_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698