OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "chromecast/browser/url_request_context_factory.h" | 5 #include "chromecast/browser/url_request_context_factory.h" |
6 | 6 |
| 7 #include <algorithm> |
7 #include <utility> | 8 #include <utility> |
8 | 9 |
9 #include "base/command_line.h" | 10 #include "base/command_line.h" |
10 #include "base/files/file_path.h" | 11 #include "base/files/file_path.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
13 #include "base/threading/worker_pool.h" | 14 #include "base/threading/worker_pool.h" |
14 #include "chromecast/base/chromecast_switches.h" | 15 #include "chromecast/base/chromecast_switches.h" |
| 16 #include "chromecast/browser/cast_browser_process.h" |
15 #include "chromecast/browser/cast_http_user_agent_settings.h" | 17 #include "chromecast/browser/cast_http_user_agent_settings.h" |
16 #include "chromecast/browser/cast_network_delegate.h" | 18 #include "chromecast/browser/cast_network_delegate.h" |
| 19 #include "components/proxy_config/pref_proxy_config_tracker_impl.h" |
17 #include "content/public/browser/browser_context.h" | 20 #include "content/public/browser/browser_context.h" |
18 #include "content/public/browser/browser_thread.h" | 21 #include "content/public/browser/browser_thread.h" |
19 #include "content/public/browser/cookie_store_factory.h" | 22 #include "content/public/browser/cookie_store_factory.h" |
20 #include "content/public/common/content_switches.h" | 23 #include "content/public/common/content_switches.h" |
21 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
22 #include "net/cert/cert_verifier.h" | 25 #include "net/cert/cert_verifier.h" |
23 #include "net/cert/ct_policy_enforcer.h" | 26 #include "net/cert/ct_policy_enforcer.h" |
24 #include "net/cert/ct_policy_status.h" | 27 #include "net/cert/ct_policy_status.h" |
25 #include "net/cert/do_nothing_ct_verifier.h" | 28 #include "net/cert/do_nothing_ct_verifier.h" |
26 #include "net/cert_net/nss_ocsp.h" | 29 #include "net/cert_net/nss_ocsp.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 | 165 |
163 URLRequestContextFactory::URLRequestContextFactory() | 166 URLRequestContextFactory::URLRequestContextFactory() |
164 : app_network_delegate_(CastNetworkDelegate::Create()), | 167 : app_network_delegate_(CastNetworkDelegate::Create()), |
165 system_network_delegate_(CastNetworkDelegate::Create()), | 168 system_network_delegate_(CastNetworkDelegate::Create()), |
166 system_dependencies_initialized_(false), | 169 system_dependencies_initialized_(false), |
167 main_dependencies_initialized_(false), | 170 main_dependencies_initialized_(false), |
168 media_dependencies_initialized_(false), | 171 media_dependencies_initialized_(false), |
169 enable_quic_(true) {} | 172 enable_quic_(true) {} |
170 | 173 |
171 URLRequestContextFactory::~URLRequestContextFactory() { | 174 URLRequestContextFactory::~URLRequestContextFactory() { |
| 175 pref_proxy_config_tracker_impl_->DetachFromPrefService(); |
172 } | 176 } |
173 | 177 |
174 void URLRequestContextFactory::InitializeOnUIThread(net::NetLog* net_log) { | 178 void URLRequestContextFactory::InitializeOnUIThread(net::NetLog* net_log) { |
175 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 179 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
176 // Cast http user agent settings must be initialized in UI thread | 180 // Cast http user agent settings must be initialized in UI thread |
177 // because it registers itself to pref notification observer which is not | 181 // because it registers itself to pref notification observer which is not |
178 // thread safe. | 182 // thread safe. |
179 http_user_agent_settings_.reset(new CastHttpUserAgentSettings()); | 183 http_user_agent_settings_.reset(new CastHttpUserAgentSettings()); |
180 | 184 |
181 // Proxy config service should be initialized in UI thread, since | 185 // Proxy config service should be initialized in UI thread, since |
182 // ProxyConfigServiceDelegate on Android expects UI thread. | 186 // ProxyConfigServiceDelegate on Android expects UI thread. |
183 proxy_config_service_ = net::ProxyService::CreateSystemProxyConfigService( | 187 pref_proxy_config_tracker_impl_ = |
184 content::BrowserThread::GetTaskRunnerForThread( | 188 base::WrapUnique<PrefProxyConfigTrackerImpl>( |
185 content::BrowserThread::IO), | 189 new PrefProxyConfigTrackerImpl( |
186 content::BrowserThread::GetTaskRunnerForThread( | 190 CastBrowserProcess::GetInstance()->pref_service(), |
187 content::BrowserThread::FILE)); | 191 content::BrowserThread::GetTaskRunnerForThread( |
| 192 content::BrowserThread::IO))); |
188 | 193 |
| 194 proxy_config_service_ = |
| 195 pref_proxy_config_tracker_impl_->CreateTrackingProxyConfigService( |
| 196 nullptr); |
| 197 DCHECK(proxy_config_service_.get()); |
189 net_log_ = net_log; | 198 net_log_ = net_log; |
190 } | 199 } |
191 | 200 |
192 net::URLRequestContextGetter* URLRequestContextFactory::CreateMainGetter( | 201 net::URLRequestContextGetter* URLRequestContextFactory::CreateMainGetter( |
193 content::BrowserContext* browser_context, | 202 content::BrowserContext* browser_context, |
194 content::ProtocolHandlerMap* protocol_handlers, | 203 content::ProtocolHandlerMap* protocol_handlers, |
195 content::URLRequestInterceptorScopedVector request_interceptors) { | 204 content::URLRequestInterceptorScopedVector request_interceptors) { |
196 DCHECK(!main_getter_.get()) | 205 DCHECK(!main_getter_.get()) |
197 << "Main URLRequestContextGetter already initialized"; | 206 << "Main URLRequestContextGetter already initialized"; |
198 main_getter_ = | 207 main_getter_ = |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 if (media_getter_) { | 473 if (media_getter_) { |
465 media_getter_->GetURLRequestContext() | 474 media_getter_->GetURLRequestContext() |
466 ->http_transaction_factory() | 475 ->http_transaction_factory() |
467 ->GetSession() | 476 ->GetSession() |
468 ->DisableQuic(); | 477 ->DisableQuic(); |
469 } | 478 } |
470 } | 479 } |
471 | 480 |
472 } // namespace shell | 481 } // namespace shell |
473 } // namespace chromecast | 482 } // namespace chromecast |
OLD | NEW |