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/shell/browser/url_request_context_factory.h" | 5 #include "chromecast/shell/browser/url_request_context_factory.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 : is_media_(is_media), | 56 : is_media_(is_media), |
57 factory_(factory) { | 57 factory_(factory) { |
58 } | 58 } |
59 | 59 |
60 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE { | 60 virtual net::URLRequestContext* GetURLRequestContext() OVERRIDE { |
61 if (!request_context_) { | 61 if (!request_context_) { |
62 if (is_media_) { | 62 if (is_media_) { |
63 request_context_.reset(factory_->CreateMediaRequestContext()); | 63 request_context_.reset(factory_->CreateMediaRequestContext()); |
64 } else { | 64 } else { |
65 request_context_.reset(factory_->CreateSystemRequestContext()); | 65 request_context_.reset(factory_->CreateSystemRequestContext()); |
| 66 #if defined(USE_NSS) |
66 // Set request context used by NSS for Crl requests. | 67 // Set request context used by NSS for Crl requests. |
67 net::SetURLRequestContextForNSSHttpIO(request_context_.get()); | 68 net::SetURLRequestContextForNSSHttpIO(request_context_.get()); |
| 69 #endif // defined(USE_NSS) |
68 } | 70 } |
69 } | 71 } |
70 return request_context_.get(); | 72 return request_context_.get(); |
71 } | 73 } |
72 | 74 |
73 virtual scoped_refptr<base::SingleThreadTaskRunner> | 75 virtual scoped_refptr<base::SingleThreadTaskRunner> |
74 GetNetworkTaskRunner() const OVERRIDE { | 76 GetNetworkTaskRunner() const OVERRIDE { |
75 return content::BrowserThread::GetMessageLoopProxyForThread( | 77 return content::BrowserThread::GetMessageLoopProxyForThread( |
76 content::BrowserThread::IO); | 78 content::BrowserThread::IO); |
77 } | 79 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 | 139 |
138 URLRequestContextFactory::~URLRequestContextFactory() { | 140 URLRequestContextFactory::~URLRequestContextFactory() { |
139 } | 141 } |
140 | 142 |
141 void URLRequestContextFactory::InitializeOnUIThread() { | 143 void URLRequestContextFactory::InitializeOnUIThread() { |
142 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 144 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
143 // Cast http user agent settings must be initialized in UI thread | 145 // Cast http user agent settings must be initialized in UI thread |
144 // because it registers itself to pref notification observer which is not | 146 // because it registers itself to pref notification observer which is not |
145 // thread safe. | 147 // thread safe. |
146 http_user_agent_settings_.reset(new CastHttpUserAgentSettings()); | 148 http_user_agent_settings_.reset(new CastHttpUserAgentSettings()); |
| 149 |
| 150 // Proxy config service should be initialized in UI thread, since |
| 151 // ProxyConfigServiceDelegate on Android expects UI thread. |
| 152 proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService( |
| 153 content::BrowserThread::GetMessageLoopProxyForThread( |
| 154 content::BrowserThread::IO), |
| 155 content::BrowserThread::GetMessageLoopProxyForThread( |
| 156 content::BrowserThread::FILE))); |
147 } | 157 } |
148 | 158 |
149 net::URLRequestContextGetter* URLRequestContextFactory::CreateMainGetter( | 159 net::URLRequestContextGetter* URLRequestContextFactory::CreateMainGetter( |
150 content::BrowserContext* browser_context, | 160 content::BrowserContext* browser_context, |
151 content::ProtocolHandlerMap* protocol_handlers, | 161 content::ProtocolHandlerMap* protocol_handlers, |
152 content::URLRequestInterceptorScopedVector request_interceptors) { | 162 content::URLRequestInterceptorScopedVector request_interceptors) { |
153 DCHECK(!main_getter_.get()) | 163 DCHECK(!main_getter_.get()) |
154 << "Main URLRequestContextGetter already initialized"; | 164 << "Main URLRequestContextGetter already initialized"; |
155 main_getter_ = new MainURLRequestContextGetter(this, | 165 main_getter_ = new MainURLRequestContextGetter(this, |
156 browser_context, | 166 browser_context, |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 205 |
196 ssl_config_service_ = new net::SSLConfigServiceDefaults; | 206 ssl_config_service_ = new net::SSLConfigServiceDefaults; |
197 | 207 |
198 transport_security_state_.reset(new net::TransportSecurityState()); | 208 transport_security_state_.reset(new net::TransportSecurityState()); |
199 http_auth_handler_factory_.reset( | 209 http_auth_handler_factory_.reset( |
200 net::HttpAuthHandlerFactory::CreateDefault(host_resolver_.get())); | 210 net::HttpAuthHandlerFactory::CreateDefault(host_resolver_.get())); |
201 | 211 |
202 http_server_properties_.reset(new net::HttpServerPropertiesImpl); | 212 http_server_properties_.reset(new net::HttpServerPropertiesImpl); |
203 | 213 |
204 proxy_service_.reset(net::ProxyService::CreateUsingSystemProxyResolver( | 214 proxy_service_.reset(net::ProxyService::CreateUsingSystemProxyResolver( |
205 net::ProxyService::CreateSystemProxyConfigService( | 215 proxy_config_service_.release(), 0, NULL)); |
206 content::BrowserThread::GetMessageLoopProxyForThread( | |
207 content::BrowserThread::IO), | |
208 content::BrowserThread::GetMessageLoopProxyForThread( | |
209 content::BrowserThread::FILE)), | |
210 0, | |
211 NULL)); | |
212 system_dependencies_initialized_ = true; | 216 system_dependencies_initialized_ = true; |
213 } | 217 } |
214 | 218 |
215 void URLRequestContextFactory::InitializeMainContextDependencies( | 219 void URLRequestContextFactory::InitializeMainContextDependencies( |
216 net::HttpTransactionFactory* transaction_factory, | 220 net::HttpTransactionFactory* transaction_factory, |
217 content::ProtocolHandlerMap* protocol_handlers, | 221 content::ProtocolHandlerMap* protocol_handlers, |
218 content::URLRequestInterceptorScopedVector request_interceptors) { | 222 content::URLRequestInterceptorScopedVector request_interceptors) { |
219 if (main_dependencies_initialized_) | 223 if (main_dependencies_initialized_) |
220 return; | 224 return; |
221 | 225 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 http_user_agent_settings_.get()); | 382 http_user_agent_settings_.get()); |
379 | 383 |
380 main_context->set_http_transaction_factory( | 384 main_context->set_http_transaction_factory( |
381 main_transaction_factory_.get()); | 385 main_transaction_factory_.get()); |
382 main_context->set_job_factory(main_job_factory_.get()); | 386 main_context->set_job_factory(main_job_factory_.get()); |
383 return main_context; | 387 return main_context; |
384 } | 388 } |
385 | 389 |
386 } // namespace shell | 390 } // namespace shell |
387 } // namespace chromecast | 391 } // namespace chromecast |
OLD | NEW |