Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "chrome/browser/net/system_network_context_manager.h" | |
| 6 | |
| 7 #include "base/feature_list.h" | |
| 8 #include "base/logging.h" | |
| 9 #include "content/public/browser/browser_thread.h" | |
| 10 #include "content/public/browser/network_service_instance.h" | |
| 11 #include "content/public/common/content_features.h" | |
| 12 #include "content/public/common/service_names.mojom.h" | |
| 13 #include "mojo/public/cpp/bindings/associated_interface_ptr.h" | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 content::mojom::NetworkContextParamsPtr CreateNetworkContextParams() { | |
| 18 // TODO(mmenke): Set up parameters here (No cache, in memory cookie store, | |
| 19 // etc). | |
| 20 return content::mojom::NetworkContextParams::New(); | |
| 21 } | |
| 22 | |
| 23 } // namespace | |
| 24 | |
| 25 base::LazyInstance<SystemNetworkContextManager>::Leaky | |
| 26 g_system_network_context_manager = LAZY_INSTANCE_INITIALIZER; | |
| 27 | |
| 28 content::mojom::NetworkContext* SystemNetworkContextManager::Context() { | |
| 29 return GetInstance()->GetContext(); | |
| 30 } | |
| 31 | |
| 32 void SystemNetworkContextManager::SetUp( | |
| 33 content::mojom::NetworkContextRequest* network_context_request, | |
| 34 content::mojom::NetworkContextParamsPtr* network_context_params) { | |
| 35 if (base::FeatureList::IsEnabled(features::kNetworkService)) { | |
| 36 DCHECK(!GetInstance()->io_thread_network_context_); | |
| 37 *network_context_request = | |
| 38 mojo::MakeRequest(&GetInstance()->io_thread_network_context_); | |
| 39 } else { | |
| 40 DCHECK(!GetInstance()->system_network_context_); | |
| 41 *network_context_request = | |
| 42 mojo::MakeRequest(&GetInstance()->system_network_context_); | |
| 43 } | |
| 44 *network_context_params = CreateNetworkContextParams(); | |
| 45 } | |
| 46 | |
| 47 SystemNetworkContextManager* SystemNetworkContextManager::GetInstance() { | |
| 48 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | |
| 49 return g_system_network_context_manager.Pointer(); | |
| 50 } | |
| 51 | |
| 52 SystemNetworkContextManager::SystemNetworkContextManager() {} | |
| 53 | |
| 54 SystemNetworkContextManager::~SystemNetworkContextManager() {} | |
| 55 | |
| 56 content::mojom::NetworkContext* SystemNetworkContextManager::GetContext() { | |
| 57 if (!system_network_context_) { | |
| 58 // SetUp() should already have been called, and set | |
| 59 // |system_network_context_| if the network service is disabled. | |
| 60 DCHECK(base::FeatureList::IsEnabled(features::kNetworkService)); | |
| 61 | |
| 62 content::mojom::NetworkContextParamsPtr context_params = | |
| 63 content::mojom::NetworkContextParams::New(); | |
|
asanka
2017/07/13 01:52:29
did you mean to call CreateNetworkContextParams()
mmenke
2017/07/13 16:15:18
Actually, I meant to just remove this line after I
| |
| 64 content::mojom::NetworkContextRequest system_network_context_request = | |
| 65 mojo::MakeRequest(&GetInstance()->system_network_context_); | |
| 66 content::GetNetworkService()->CreateNetworkContext( | |
| 67 MakeRequest(&system_network_context_), CreateNetworkContextParams()); | |
| 68 } | |
| 69 | |
| 70 return system_network_context_.get(); | |
| 71 } | |
| OLD | NEW |