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

Unified Diff: content/browser/storage_partition_impl.cc

Issue 2958173002: Cache the NetworkService interface pointer in the browser. (Closed)
Patch Set: 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/storage_partition_impl.cc
diff --git a/content/browser/storage_partition_impl.cc b/content/browser/storage_partition_impl.cc
index 446cce06e957d73ade8de5468e585514d448511f..e5e92e136f4c4d7b099c433ad3fc5aa26a1e56c2 100644
--- a/content/browser/storage_partition_impl.cc
+++ b/content/browser/storage_partition_impl.cc
@@ -10,7 +10,8 @@
#include <vector>
#include "base/bind.h"
-#include "base/command_line.h"
+#include "base/command_line.h"
+#include "base/lazy_instance.h"
#include "base/location.h"
#include "base/sequenced_task_runner.h"
#include "base/single_thread_task_runner.h"
@@ -532,15 +533,18 @@ std::unique_ptr<StoragePartitionImpl> StoragePartitionImpl::Create(
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
switches::kEnableNetworkService)) {
- mojom::NetworkServicePtr network_service;
- ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface(
- mojom::kNetworkServiceName, &network_service);
+ static base::LazyInstance<mojom::NetworkServicePtr>::Leaky
Ken Rockot(use gerrit already) 2017/06/27 22:52:39 I'm pretty sure the fact that we now have thread-s
Ken Rockot(use gerrit already) 2017/06/27 22:52:39 Is there any reason to use LazyInstance now? Why n
jam 2017/06/27 23:42:18 Done.
+ g_network_service = LAZY_INSTANCE_INITIALIZER;
+ if (!g_network_service.Get()) {
+ ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface(
+ mojom::kNetworkServiceName, &g_network_service.Get());
+ }
mojom::NetworkContextParamsPtr context_params =
mojom::NetworkContextParams::New();
// TODO: fill this
// context_params->cache_dir =
// context_params->cookie_path =
- network_service->CreateNetworkContext(
+ g_network_service.Get()->CreateNetworkContext(
MakeRequest(&partition->network_context_), std::move(context_params));
BlobURLLoaderFactory::BlobContextGetter blob_getter =
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698