| 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 system_network_delegate_(CastNetworkDelegate::Create()), | 136 system_network_delegate_(CastNetworkDelegate::Create()), |
| 137 system_dependencies_initialized_(false), | 137 system_dependencies_initialized_(false), |
| 138 main_dependencies_initialized_(false), | 138 main_dependencies_initialized_(false), |
| 139 media_dependencies_initialized_(false) { | 139 media_dependencies_initialized_(false) { |
| 140 } | 140 } |
| 141 | 141 |
| 142 URLRequestContextFactory::~URLRequestContextFactory() { | 142 URLRequestContextFactory::~URLRequestContextFactory() { |
| 143 } | 143 } |
| 144 | 144 |
| 145 void URLRequestContextFactory::InitializeOnUIThread() { | 145 void URLRequestContextFactory::InitializeOnUIThread() { |
| 146 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 146 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 147 // Cast http user agent settings must be initialized in UI thread | 147 // Cast http user agent settings must be initialized in UI thread |
| 148 // because it registers itself to pref notification observer which is not | 148 // because it registers itself to pref notification observer which is not |
| 149 // thread safe. | 149 // thread safe. |
| 150 http_user_agent_settings_.reset(new CastHttpUserAgentSettings()); | 150 http_user_agent_settings_.reset(new CastHttpUserAgentSettings()); |
| 151 | 151 |
| 152 // Proxy config service should be initialized in UI thread, since | 152 // Proxy config service should be initialized in UI thread, since |
| 153 // ProxyConfigServiceDelegate on Android expects UI thread. | 153 // ProxyConfigServiceDelegate on Android expects UI thread. |
| 154 proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService( | 154 proxy_config_service_.reset(net::ProxyService::CreateSystemProxyConfigService( |
| 155 content::BrowserThread::GetMessageLoopProxyForThread( | 155 content::BrowserThread::GetMessageLoopProxyForThread( |
| 156 content::BrowserThread::IO), | 156 content::BrowserThread::IO), |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 290 params->ignore_certificate_errors = ignore_certificate_errors; | 290 params->ignore_certificate_errors = ignore_certificate_errors; |
| 291 params->proxy_service = proxy_service_.get(); | 291 params->proxy_service = proxy_service_.get(); |
| 292 | 292 |
| 293 // TODO(lcwu): http://crbug.com/329681. Remove this once spdy is enabled | 293 // TODO(lcwu): http://crbug.com/329681. Remove this once spdy is enabled |
| 294 // by default at the content level. | 294 // by default at the content level. |
| 295 params->next_protos = net::NextProtosSpdy31(); | 295 params->next_protos = net::NextProtosSpdy31(); |
| 296 params->use_alternate_protocols = true; | 296 params->use_alternate_protocols = true; |
| 297 } | 297 } |
| 298 | 298 |
| 299 net::URLRequestContext* URLRequestContextFactory::CreateSystemRequestContext() { | 299 net::URLRequestContext* URLRequestContextFactory::CreateSystemRequestContext() { |
| 300 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 300 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 301 InitializeSystemContextDependencies(); | 301 InitializeSystemContextDependencies(); |
| 302 net::HttpNetworkSession::Params system_params; | 302 net::HttpNetworkSession::Params system_params; |
| 303 PopulateNetworkSessionParams(false, &system_params); | 303 PopulateNetworkSessionParams(false, &system_params); |
| 304 system_transaction_factory_.reset(new net::HttpNetworkLayer( | 304 system_transaction_factory_.reset(new net::HttpNetworkLayer( |
| 305 new net::HttpNetworkSession(system_params))); | 305 new net::HttpNetworkSession(system_params))); |
| 306 system_job_factory_.reset(new net::URLRequestJobFactoryImpl()); | 306 system_job_factory_.reset(new net::URLRequestJobFactoryImpl()); |
| 307 | 307 |
| 308 net::URLRequestContext* system_context = new net::URLRequestContext(); | 308 net::URLRequestContext* system_context = new net::URLRequestContext(); |
| 309 system_context->set_host_resolver(host_resolver_.get()); | 309 system_context->set_host_resolver(host_resolver_.get()); |
| 310 system_context->set_channel_id_service(channel_id_service_.get()); | 310 system_context->set_channel_id_service(channel_id_service_.get()); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 322 system_context->set_http_user_agent_settings( | 322 system_context->set_http_user_agent_settings( |
| 323 http_user_agent_settings_.get()); | 323 http_user_agent_settings_.get()); |
| 324 system_context->set_job_factory(system_job_factory_.get()); | 324 system_context->set_job_factory(system_job_factory_.get()); |
| 325 system_context->set_cookie_store( | 325 system_context->set_cookie_store( |
| 326 content::CreateCookieStore(content::CookieStoreConfig())); | 326 content::CreateCookieStore(content::CookieStoreConfig())); |
| 327 system_context->set_network_delegate(system_network_delegate_.get()); | 327 system_context->set_network_delegate(system_network_delegate_.get()); |
| 328 return system_context; | 328 return system_context; |
| 329 } | 329 } |
| 330 | 330 |
| 331 net::URLRequestContext* URLRequestContextFactory::CreateMediaRequestContext() { | 331 net::URLRequestContext* URLRequestContextFactory::CreateMediaRequestContext() { |
| 332 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 332 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 333 DCHECK(main_getter_.get()) | 333 DCHECK(main_getter_.get()) |
| 334 << "Getting MediaRequestContext before MainRequestContext"; | 334 << "Getting MediaRequestContext before MainRequestContext"; |
| 335 net::URLRequestContext* main_context = main_getter_->GetURLRequestContext(); | 335 net::URLRequestContext* main_context = main_getter_->GetURLRequestContext(); |
| 336 | 336 |
| 337 // Set non caching backend. | 337 // Set non caching backend. |
| 338 net::HttpNetworkSession* main_session = | 338 net::HttpNetworkSession* main_session = |
| 339 main_transaction_factory_->GetSession(); | 339 main_transaction_factory_->GetSession(); |
| 340 InitializeMediaContextDependencies( | 340 InitializeMediaContextDependencies( |
| 341 new net::HttpNetworkLayer(main_session)); | 341 new net::HttpNetworkLayer(main_session)); |
| 342 | 342 |
| 343 net::URLRequestContext* media_context = new net::URLRequestContext(); | 343 net::URLRequestContext* media_context = new net::URLRequestContext(); |
| 344 media_context->CopyFrom(main_context); | 344 media_context->CopyFrom(main_context); |
| 345 media_context->set_http_transaction_factory( | 345 media_context->set_http_transaction_factory( |
| 346 media_transaction_factory_.get()); | 346 media_transaction_factory_.get()); |
| 347 return media_context; | 347 return media_context; |
| 348 } | 348 } |
| 349 | 349 |
| 350 net::URLRequestContext* URLRequestContextFactory::CreateMainRequestContext( | 350 net::URLRequestContext* URLRequestContextFactory::CreateMainRequestContext( |
| 351 content::BrowserContext* browser_context, | 351 content::BrowserContext* browser_context, |
| 352 content::ProtocolHandlerMap* protocol_handlers, | 352 content::ProtocolHandlerMap* protocol_handlers, |
| 353 content::URLRequestInterceptorScopedVector request_interceptors) { | 353 content::URLRequestInterceptorScopedVector request_interceptors) { |
| 354 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::IO)); | 354 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 355 InitializeSystemContextDependencies(); | 355 InitializeSystemContextDependencies(); |
| 356 | 356 |
| 357 bool ignore_certificate_errors = false; | 357 bool ignore_certificate_errors = false; |
| 358 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 358 base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 359 if (cmd_line->HasSwitch(switches::kIgnoreCertificateErrors)) { | 359 if (cmd_line->HasSwitch(switches::kIgnoreCertificateErrors)) { |
| 360 ignore_certificate_errors = true; | 360 ignore_certificate_errors = true; |
| 361 } | 361 } |
| 362 net::HttpNetworkSession::Params network_session_params; | 362 net::HttpNetworkSession::Params network_session_params; |
| 363 PopulateNetworkSessionParams(ignore_certificate_errors, | 363 PopulateNetworkSessionParams(ignore_certificate_errors, |
| 364 &network_session_params); | 364 &network_session_params); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 | 401 |
| 402 void URLRequestContextFactory::InitializeNetworkDelegates() { | 402 void URLRequestContextFactory::InitializeNetworkDelegates() { |
| 403 app_network_delegate_->Initialize(false); | 403 app_network_delegate_->Initialize(false); |
| 404 LOG(INFO) << "Initialized app network delegate."; | 404 LOG(INFO) << "Initialized app network delegate."; |
| 405 system_network_delegate_->Initialize(false); | 405 system_network_delegate_->Initialize(false); |
| 406 LOG(INFO) << "Initialized system network delegate."; | 406 LOG(INFO) << "Initialized system network delegate."; |
| 407 } | 407 } |
| 408 | 408 |
| 409 } // namespace shell | 409 } // namespace shell |
| 410 } // namespace chromecast | 410 } // namespace chromecast |
| OLD | NEW |