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

Side by Side Diff: content/browser/storage_partition_impl.cc

Issue 2958173002: Cache the NetworkService interface pointer in the browser. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/storage_partition_impl.h" 5 #include "content/browser/storage_partition_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <set> 9 #include <set>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/lazy_instance.h"
14 #include "base/location.h" 15 #include "base/location.h"
15 #include "base/sequenced_task_runner.h" 16 #include "base/sequenced_task_runner.h"
16 #include "base/single_thread_task_runner.h" 17 #include "base/single_thread_task_runner.h"
17 #include "base/strings/utf_string_conversions.h" 18 #include "base/strings/utf_string_conversions.h"
18 #include "base/task_scheduler/post_task.h" 19 #include "base/task_scheduler/post_task.h"
19 #include "content/browser/blob_storage/chrome_blob_storage_context.h" 20 #include "content/browser/blob_storage/chrome_blob_storage_context.h"
20 #include "content/browser/browser_main_loop.h" 21 #include "content/browser/browser_main_loop.h"
21 #include "content/browser/browsing_data/storage_partition_http_cache_data_remove r.h" 22 #include "content/browser/browsing_data/storage_partition_http_cache_data_remove r.h"
22 #include "content/browser/fileapi/browser_file_system_helper.h" 23 #include "content/browser/fileapi/browser_file_system_helper.h"
23 #include "content/browser/gpu/shader_cache_factory.h" 24 #include "content/browser/gpu/shader_cache_factory.h"
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
525 526
526 partition->broadcast_channel_provider_ = new BroadcastChannelProvider(); 527 partition->broadcast_channel_provider_ = new BroadcastChannelProvider();
527 528
528 partition->bluetooth_allowed_devices_map_ = new BluetoothAllowedDevicesMap(); 529 partition->bluetooth_allowed_devices_map_ = new BluetoothAllowedDevicesMap();
529 530
530 scoped_refptr<ChromeBlobStorageContext> blob_context = 531 scoped_refptr<ChromeBlobStorageContext> blob_context =
531 ChromeBlobStorageContext::GetFor(context); 532 ChromeBlobStorageContext::GetFor(context);
532 533
533 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 534 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
534 switches::kEnableNetworkService)) { 535 switches::kEnableNetworkService)) {
535 mojom::NetworkServicePtr network_service; 536 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.
536 ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface( 537 g_network_service = LAZY_INSTANCE_INITIALIZER;
537 mojom::kNetworkServiceName, &network_service); 538 if (!g_network_service.Get()) {
539 ServiceManagerConnection::GetForProcess()->GetConnector()->BindInterface(
540 mojom::kNetworkServiceName, &g_network_service.Get());
541 }
538 mojom::NetworkContextParamsPtr context_params = 542 mojom::NetworkContextParamsPtr context_params =
539 mojom::NetworkContextParams::New(); 543 mojom::NetworkContextParams::New();
540 // TODO: fill this 544 // TODO: fill this
541 // context_params->cache_dir = 545 // context_params->cache_dir =
542 // context_params->cookie_path = 546 // context_params->cookie_path =
543 network_service->CreateNetworkContext( 547 g_network_service.Get()->CreateNetworkContext(
544 MakeRequest(&partition->network_context_), std::move(context_params)); 548 MakeRequest(&partition->network_context_), std::move(context_params));
545 549
546 BlobURLLoaderFactory::BlobContextGetter blob_getter = 550 BlobURLLoaderFactory::BlobContextGetter blob_getter =
547 base::BindOnce(&BlobStorageContextGetter, blob_context); 551 base::BindOnce(&BlobStorageContextGetter, blob_context);
548 partition->blob_url_loader_factory_ = new BlobURLLoaderFactory( 552 partition->blob_url_loader_factory_ = new BlobURLLoaderFactory(
549 std::move(blob_getter), partition->filesystem_context_); 553 std::move(blob_getter), partition->filesystem_context_);
550 554
551 partition->url_loader_factory_getter_ = new URLLoaderFactoryGetter(); 555 partition->url_loader_factory_getter_ = new URLLoaderFactoryGetter();
552 partition->url_loader_factory_getter_->Initialize(partition.get()); 556 partition->url_loader_factory_getter_->Initialize(partition.get());
553 } 557 }
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
989 media_url_request_context_ = media_url_request_context; 993 media_url_request_context_ = media_url_request_context;
990 } 994 }
991 995
992 void StoragePartitionImpl::GetQuotaSettings( 996 void StoragePartitionImpl::GetQuotaSettings(
993 storage::OptionalQuotaSettingsCallback callback) { 997 storage::OptionalQuotaSettingsCallback callback) {
994 GetContentClient()->browser()->GetQuotaSettings(browser_context_, this, 998 GetContentClient()->browser()->GetQuotaSettings(browser_context_, this,
995 std::move(callback)); 999 std::move(callback));
996 } 1000 }
997 1001
998 } // namespace content 1002 } // namespace content
OLDNEW
« 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