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 "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/threading/worker_pool.h" | 10 #include "base/threading/worker_pool.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 : app_network_delegate_(CastNetworkDelegate::Create()), | 136 : app_network_delegate_(CastNetworkDelegate::Create()), |
137 system_network_delegate_(CastNetworkDelegate::Create()), | 137 system_network_delegate_(CastNetworkDelegate::Create()), |
138 system_dependencies_initialized_(false), | 138 system_dependencies_initialized_(false), |
139 main_dependencies_initialized_(false), | 139 main_dependencies_initialized_(false), |
140 media_dependencies_initialized_(false) { | 140 media_dependencies_initialized_(false) { |
141 } | 141 } |
142 | 142 |
143 URLRequestContextFactory::~URLRequestContextFactory() { | 143 URLRequestContextFactory::~URLRequestContextFactory() { |
144 } | 144 } |
145 | 145 |
146 void URLRequestContextFactory::InitializeOnUIThread() { | 146 void URLRequestContextFactory::InitializeOnUIThread(net::NetLog* net_log) { |
147 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 147 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
148 // Cast http user agent settings must be initialized in UI thread | 148 // Cast http user agent settings must be initialized in UI thread |
149 // because it registers itself to pref notification observer which is not | 149 // because it registers itself to pref notification observer which is not |
150 // thread safe. | 150 // thread safe. |
151 http_user_agent_settings_.reset(new CastHttpUserAgentSettings()); | 151 http_user_agent_settings_.reset(new CastHttpUserAgentSettings()); |
152 | 152 |
153 // Proxy config service should be initialized in UI thread, since | 153 // Proxy config service should be initialized in UI thread, since |
154 // ProxyConfigServiceDelegate on Android expects UI thread. | 154 // ProxyConfigServiceDelegate on Android expects UI thread. |
155 proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService( | 155 proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService( |
156 content::BrowserThread::GetMessageLoopProxyForThread( | 156 content::BrowserThread::GetMessageLoopProxyForThread( |
157 content::BrowserThread::IO), | 157 content::BrowserThread::IO), |
158 content::BrowserThread::GetMessageLoopProxyForThread( | 158 content::BrowserThread::GetMessageLoopProxyForThread( |
159 content::BrowserThread::FILE))); | 159 content::BrowserThread::FILE))); |
| 160 |
| 161 net_log_ = net_log; |
160 } | 162 } |
161 | 163 |
162 net::URLRequestContextGetter* URLRequestContextFactory::CreateMainGetter( | 164 net::URLRequestContextGetter* URLRequestContextFactory::CreateMainGetter( |
163 content::BrowserContext* browser_context, | 165 content::BrowserContext* browser_context, |
164 content::ProtocolHandlerMap* protocol_handlers, | 166 content::ProtocolHandlerMap* protocol_handlers, |
165 content::URLRequestInterceptorScopedVector request_interceptors) { | 167 content::URLRequestInterceptorScopedVector request_interceptors) { |
166 DCHECK(!main_getter_.get()) | 168 DCHECK(!main_getter_.get()) |
167 << "Main URLRequestContextGetter already initialized"; | 169 << "Main URLRequestContextGetter already initialized"; |
168 main_getter_ = new MainURLRequestContextGetter(this, | 170 main_getter_ = new MainURLRequestContextGetter(this, |
169 browser_context, | 171 browser_context, |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
321 system_context->set_http_server_properties( | 323 system_context->set_http_server_properties( |
322 http_server_properties_->GetWeakPtr()); | 324 http_server_properties_->GetWeakPtr()); |
323 system_context->set_http_transaction_factory( | 325 system_context->set_http_transaction_factory( |
324 system_transaction_factory_.get()); | 326 system_transaction_factory_.get()); |
325 system_context->set_http_user_agent_settings( | 327 system_context->set_http_user_agent_settings( |
326 http_user_agent_settings_.get()); | 328 http_user_agent_settings_.get()); |
327 system_context->set_job_factory(system_job_factory_.get()); | 329 system_context->set_job_factory(system_job_factory_.get()); |
328 system_context->set_cookie_store( | 330 system_context->set_cookie_store( |
329 content::CreateCookieStore(content::CookieStoreConfig())); | 331 content::CreateCookieStore(content::CookieStoreConfig())); |
330 system_context->set_network_delegate(system_network_delegate_.get()); | 332 system_context->set_network_delegate(system_network_delegate_.get()); |
| 333 system_context->set_net_log(net_log_); |
331 return system_context; | 334 return system_context; |
332 } | 335 } |
333 | 336 |
334 net::URLRequestContext* URLRequestContextFactory::CreateMediaRequestContext() { | 337 net::URLRequestContext* URLRequestContextFactory::CreateMediaRequestContext() { |
335 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 338 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
336 DCHECK(main_getter_.get()) | 339 DCHECK(main_getter_.get()) |
337 << "Getting MediaRequestContext before MainRequestContext"; | 340 << "Getting MediaRequestContext before MainRequestContext"; |
338 net::URLRequestContext* main_context = main_getter_->GetURLRequestContext(); | 341 net::URLRequestContext* main_context = main_getter_->GetURLRequestContext(); |
339 | 342 |
340 // Set non caching backend. | 343 // Set non caching backend. |
341 net::HttpNetworkSession* main_session = | 344 net::HttpNetworkSession* main_session = |
342 main_transaction_factory_->GetSession(); | 345 main_transaction_factory_->GetSession(); |
343 InitializeMediaContextDependencies( | 346 InitializeMediaContextDependencies( |
344 new net::HttpNetworkLayer(main_session)); | 347 new net::HttpNetworkLayer(main_session)); |
345 | 348 |
346 net::URLRequestContext* media_context = new net::URLRequestContext(); | 349 net::URLRequestContext* media_context = new net::URLRequestContext(); |
347 media_context->CopyFrom(main_context); | 350 media_context->CopyFrom(main_context); |
348 media_context->set_http_transaction_factory( | 351 media_context->set_http_transaction_factory( |
349 media_transaction_factory_.get()); | 352 media_transaction_factory_.get()); |
| 353 media_context->set_net_log(net_log_); |
350 return media_context; | 354 return media_context; |
351 } | 355 } |
352 | 356 |
353 net::URLRequestContext* URLRequestContextFactory::CreateMainRequestContext( | 357 net::URLRequestContext* URLRequestContextFactory::CreateMainRequestContext( |
354 content::BrowserContext* browser_context, | 358 content::BrowserContext* browser_context, |
355 content::ProtocolHandlerMap* protocol_handlers, | 359 content::ProtocolHandlerMap* protocol_handlers, |
356 content::URLRequestInterceptorScopedVector request_interceptors) { | 360 content::URLRequestInterceptorScopedVector request_interceptors) { |
357 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 361 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
358 InitializeSystemContextDependencies(); | 362 InitializeSystemContextDependencies(); |
359 | 363 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 main_context->set_http_server_properties( | 396 main_context->set_http_server_properties( |
393 http_server_properties_->GetWeakPtr()); | 397 http_server_properties_->GetWeakPtr()); |
394 main_context->set_cookie_store(cookie_store.get()); | 398 main_context->set_cookie_store(cookie_store.get()); |
395 main_context->set_http_user_agent_settings( | 399 main_context->set_http_user_agent_settings( |
396 http_user_agent_settings_.get()); | 400 http_user_agent_settings_.get()); |
397 | 401 |
398 main_context->set_http_transaction_factory( | 402 main_context->set_http_transaction_factory( |
399 main_transaction_factory_.get()); | 403 main_transaction_factory_.get()); |
400 main_context->set_job_factory(main_job_factory_.get()); | 404 main_context->set_job_factory(main_job_factory_.get()); |
401 main_context->set_network_delegate(app_network_delegate_.get()); | 405 main_context->set_network_delegate(app_network_delegate_.get()); |
| 406 main_context->set_net_log(net_log_); |
402 return main_context; | 407 return main_context; |
403 } | 408 } |
404 | 409 |
405 void URLRequestContextFactory::InitializeNetworkDelegates() { | 410 void URLRequestContextFactory::InitializeNetworkDelegates() { |
406 app_network_delegate_->Initialize(false); | 411 app_network_delegate_->Initialize(false); |
407 LOG(INFO) << "Initialized app network delegate."; | 412 LOG(INFO) << "Initialized app network delegate."; |
408 system_network_delegate_->Initialize(false); | 413 system_network_delegate_->Initialize(false); |
409 LOG(INFO) << "Initialized system network delegate."; | 414 LOG(INFO) << "Initialized system network delegate."; |
410 } | 415 } |
411 | 416 |
412 } // namespace shell | 417 } // namespace shell |
413 } // namespace chromecast | 418 } // namespace chromecast |
OLD | NEW |