| 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" |
| 11 #include "chromecast/base/chromecast_switches.h" | 11 #include "chromecast/base/chromecast_switches.h" |
| 12 #include "chromecast/browser/cast_http_user_agent_settings.h" | 12 #include "chromecast/browser/cast_http_user_agent_settings.h" |
| 13 #include "chromecast/browser/cast_net_log.h" |
| 13 #include "chromecast/browser/cast_network_delegate.h" | 14 #include "chromecast/browser/cast_network_delegate.h" |
| 14 #include "content/public/browser/browser_context.h" | 15 #include "content/public/browser/browser_context.h" |
| 15 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 16 #include "content/public/browser/cookie_store_factory.h" | 17 #include "content/public/browser/cookie_store_factory.h" |
| 17 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
| 18 #include "content/public/common/url_constants.h" | 19 #include "content/public/common/url_constants.h" |
| 19 #include "net/cert/cert_verifier.h" | 20 #include "net/cert/cert_verifier.h" |
| 20 #include "net/cert_net/nss_ocsp.h" | 21 #include "net/cert_net/nss_ocsp.h" |
| 21 #include "net/cookies/cookie_store.h" | 22 #include "net/cookies/cookie_store.h" |
| 22 #include "net/dns/host_resolver.h" | 23 #include "net/dns/host_resolver.h" |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 scoped_ptr<net::URLRequestContext> request_context_; | 131 scoped_ptr<net::URLRequestContext> request_context_; |
| 131 | 132 |
| 132 DISALLOW_COPY_AND_ASSIGN(MainURLRequestContextGetter); | 133 DISALLOW_COPY_AND_ASSIGN(MainURLRequestContextGetter); |
| 133 }; | 134 }; |
| 134 | 135 |
| 135 URLRequestContextFactory::URLRequestContextFactory() | 136 URLRequestContextFactory::URLRequestContextFactory() |
| 136 : app_network_delegate_(CastNetworkDelegate::Create()), | 137 : app_network_delegate_(CastNetworkDelegate::Create()), |
| 137 system_network_delegate_(CastNetworkDelegate::Create()), | 138 system_network_delegate_(CastNetworkDelegate::Create()), |
| 138 system_dependencies_initialized_(false), | 139 system_dependencies_initialized_(false), |
| 139 main_dependencies_initialized_(false), | 140 main_dependencies_initialized_(false), |
| 140 media_dependencies_initialized_(false) { | 141 media_dependencies_initialized_(false), |
| 142 net_log_(new CastNetLog()) { |
| 141 } | 143 } |
| 142 | 144 |
| 143 URLRequestContextFactory::~URLRequestContextFactory() { | 145 URLRequestContextFactory::~URLRequestContextFactory() { |
| 144 } | 146 } |
| 145 | 147 |
| 146 void URLRequestContextFactory::InitializeOnUIThread() { | 148 void URLRequestContextFactory::InitializeOnUIThread() { |
| 147 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 149 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 148 // Cast http user agent settings must be initialized in UI thread | 150 // Cast http user agent settings must be initialized in UI thread |
| 149 // because it registers itself to pref notification observer which is not | 151 // because it registers itself to pref notification observer which is not |
| 150 // thread safe. | 152 // thread safe. |
| (...skipping 170 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_.get()); |
| 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_.get()); |
| 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_.get()); |
| 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 |