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).get(), |
| 155 content::BrowserThread::UnsafeGetMessageLoopForThread( |
| 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_) << "Main URLRequestContextGetter already initialized"; | 163 DCHECK(!main_getter_) << "Main URLRequestContextGetter already initialized"; |
154 main_getter_ = new MainURLRequestContextGetter(this, | 164 main_getter_ = new MainURLRequestContextGetter(this, |
155 browser_context, | 165 browser_context, |
156 protocol_handlers, | 166 protocol_handlers, |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 | 204 |
195 ssl_config_service_ = new net::SSLConfigServiceDefaults; | 205 ssl_config_service_ = new net::SSLConfigServiceDefaults; |
196 | 206 |
197 transport_security_state_.reset(new net::TransportSecurityState()); | 207 transport_security_state_.reset(new net::TransportSecurityState()); |
198 http_auth_handler_factory_.reset( | 208 http_auth_handler_factory_.reset( |
199 net::HttpAuthHandlerFactory::CreateDefault(host_resolver_.get())); | 209 net::HttpAuthHandlerFactory::CreateDefault(host_resolver_.get())); |
200 | 210 |
201 http_server_properties_.reset(new net::HttpServerPropertiesImpl); | 211 http_server_properties_.reset(new net::HttpServerPropertiesImpl); |
202 | 212 |
203 proxy_service_.reset(net::ProxyService::CreateUsingSystemProxyResolver( | 213 proxy_service_.reset(net::ProxyService::CreateUsingSystemProxyResolver( |
204 net::ProxyService::CreateSystemProxyConfigService( | 214 proxy_config_service_.release(), 0, NULL)); |
205 content::BrowserThread::GetMessageLoopProxyForThread( | |
206 content::BrowserThread::IO).get(), | |
207 content::BrowserThread::UnsafeGetMessageLoopForThread( | |
208 content::BrowserThread::FILE)), | |
209 0, | |
210 NULL)); | |
211 system_dependencies_initialized_ = true; | 215 system_dependencies_initialized_ = true; |
212 } | 216 } |
213 | 217 |
214 void URLRequestContextFactory::InitializeMainContextDependencies( | 218 void URLRequestContextFactory::InitializeMainContextDependencies( |
215 net::HttpTransactionFactory* transaction_factory, | 219 net::HttpTransactionFactory* transaction_factory, |
216 content::ProtocolHandlerMap* protocol_handlers, | 220 content::ProtocolHandlerMap* protocol_handlers, |
217 content::URLRequestInterceptorScopedVector request_interceptors) { | 221 content::URLRequestInterceptorScopedVector request_interceptors) { |
218 if (main_dependencies_initialized_) | 222 if (main_dependencies_initialized_) |
219 return; | 223 return; |
220 | 224 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 http_user_agent_settings_.get()); | 381 http_user_agent_settings_.get()); |
378 | 382 |
379 main_context->set_http_transaction_factory( | 383 main_context->set_http_transaction_factory( |
380 main_transaction_factory_.get()); | 384 main_transaction_factory_.get()); |
381 main_context->set_job_factory(main_job_factory_.get()); | 385 main_context->set_job_factory(main_job_factory_.get()); |
382 return main_context; | 386 return main_context; |
383 } | 387 } |
384 | 388 |
385 } // namespace shell | 389 } // namespace shell |
386 } // namespace chromecast | 390 } // namespace chromecast |
OLD | NEW |