| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/io_thread.h" | 5 #include "chrome/browser/io_thread.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/debug/leak_tracker.h" | 10 #include "base/debug/leak_tracker.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/metrics/field_trial.h" | 12 #include "base/metrics/field_trial.h" |
| 13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
| 14 #include "base/string_number_conversions.h" | 14 #include "base/string_number_conversions.h" |
| 15 #include "base/string_split.h" | 15 #include "base/string_split.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
| 18 #include "build/build_config.h" | 18 #include "build/build_config.h" |
| 19 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
| 20 #include "chrome/browser/extensions/extension_event_router_forwarder.h" | 20 #include "chrome/browser/extensions/extension_event_router_forwarder.h" |
| 21 #include "chrome/browser/media/media_internals.h" | 21 #include "chrome/browser/media/media_internals.h" |
| 22 #include "chrome/browser/net/chrome_net_log.h" | 22 #include "chrome/browser/net/chrome_net_log.h" |
| 23 #include "chrome/browser/net/chrome_network_delegate.h" | 23 #include "chrome/browser/net/chrome_network_delegate.h" |
| 24 #include "chrome/browser/net/chrome_url_request_context.h" | 24 #include "chrome/browser/net/chrome_url_request_context.h" |
| 25 #include "chrome/browser/net/connect_interceptor.h" | 25 #include "chrome/browser/net/connect_interceptor.h" |
| 26 #include "chrome/browser/net/passive_log_collector.h" | 26 #include "chrome/browser/net/passive_log_collector.h" |
| 27 #include "chrome/browser/net/pref_proxy_config_service.h" | 27 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
| 28 #include "chrome/browser/net/proxy_service_factory.h" | 28 #include "chrome/browser/net/proxy_service_factory.h" |
| 29 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 29 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
| 30 #include "chrome/browser/prefs/pref_service.h" | 30 #include "chrome/browser/prefs/pref_service.h" |
| 31 #include "chrome/common/chrome_switches.h" | 31 #include "chrome/common/chrome_switches.h" |
| 32 #include "chrome/common/pref_names.h" | 32 #include "chrome/common/pref_names.h" |
| 33 #include "content/browser/gpu/gpu_process_host.h" | 33 #include "content/browser/gpu/gpu_process_host.h" |
| 34 #include "content/browser/in_process_webkit/indexed_db_key_utility_client.h" | 34 #include "content/browser/in_process_webkit/indexed_db_key_utility_client.h" |
| 35 #include "content/public/browser/browser_thread.h" | 35 #include "content/public/browser/browser_thread.h" |
| 36 #include "content/public/common/content_client.h" | 36 #include "content/public/common/content_client.h" |
| 37 #include "content/public/common/url_fetcher.h" | 37 #include "content/public/common/url_fetcher.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 55 #include "net/http/http_server_properties_impl.h" | 55 #include "net/http/http_server_properties_impl.h" |
| 56 #include "net/proxy/proxy_config_service.h" | 56 #include "net/proxy/proxy_config_service.h" |
| 57 #include "net/proxy/proxy_script_fetcher_impl.h" | 57 #include "net/proxy/proxy_script_fetcher_impl.h" |
| 58 #include "net/proxy/proxy_service.h" | 58 #include "net/proxy/proxy_service.h" |
| 59 #include "net/socket/dns_cert_provenance_checker.h" | 59 #include "net/socket/dns_cert_provenance_checker.h" |
| 60 | 60 |
| 61 #if defined(USE_NSS) | 61 #if defined(USE_NSS) |
| 62 #include "net/ocsp/nss_ocsp.h" | 62 #include "net/ocsp/nss_ocsp.h" |
| 63 #endif // defined(USE_NSS) | 63 #endif // defined(USE_NSS) |
| 64 | 64 |
| 65 #if defined(OS_CHROMEOS) |
| 66 #include "chrome/browser/chromeos/proxy_config_service_impl.h" |
| 67 #endif // defined(OS_CHROMEOS) |
| 68 |
| 65 using content::BrowserThread; | 69 using content::BrowserThread; |
| 66 | 70 |
| 67 namespace { | 71 namespace { |
| 68 | 72 |
| 69 // Custom URLRequestContext used by requests which aren't associated with a | 73 // Custom URLRequestContext used by requests which aren't associated with a |
| 70 // particular profile. We need to use a subclass of URLRequestContext in order | 74 // particular profile. We need to use a subclass of URLRequestContext in order |
| 71 // to provide the correct User-Agent. | 75 // to provide the correct User-Agent. |
| 72 class URLRequestContextWithUserAgent : public net::URLRequestContext { | 76 class URLRequestContextWithUserAgent : public net::URLRequestContext { |
| 73 public: | 77 public: |
| 74 virtual const std::string& GetUserAgent( | 78 virtual const std::string& GetUserAgent( |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 RegisterPrefs(local_state); | 357 RegisterPrefs(local_state); |
| 354 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); | 358 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); |
| 355 negotiate_disable_cname_lookup_ = local_state->GetBoolean( | 359 negotiate_disable_cname_lookup_ = local_state->GetBoolean( |
| 356 prefs::kDisableAuthNegotiateCnameLookup); | 360 prefs::kDisableAuthNegotiateCnameLookup); |
| 357 negotiate_enable_port_ = local_state->GetBoolean( | 361 negotiate_enable_port_ = local_state->GetBoolean( |
| 358 prefs::kEnableAuthNegotiatePort); | 362 prefs::kEnableAuthNegotiatePort); |
| 359 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); | 363 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); |
| 360 auth_delegate_whitelist_ = local_state->GetString( | 364 auth_delegate_whitelist_ = local_state->GetString( |
| 361 prefs::kAuthNegotiateDelegateWhitelist); | 365 prefs::kAuthNegotiateDelegateWhitelist); |
| 362 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); | 366 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); |
| 363 pref_proxy_config_tracker_ = new PrefProxyConfigTracker(local_state); | 367 pref_proxy_config_tracker_.reset( |
| 368 ProxyServiceFactory::CreatePrefProxyConfigTracker(local_state)); |
| 364 ChromeNetworkDelegate::InitializeReferrersEnabled(&system_enable_referrers_, | 369 ChromeNetworkDelegate::InitializeReferrersEnabled(&system_enable_referrers_, |
| 365 local_state); | 370 local_state); |
| 366 ssl_config_service_manager_.reset( | 371 ssl_config_service_manager_.reset( |
| 367 SSLConfigServiceManager::CreateDefaultManager(local_state)); | 372 SSLConfigServiceManager::CreateDefaultManager(local_state)); |
| 368 MessageLoop::current()->PostTask(FROM_HERE, | 373 MessageLoop::current()->PostTask(FROM_HERE, |
| 369 method_factory_.NewRunnableMethod( | 374 method_factory_.NewRunnableMethod( |
| 370 &IOThread::InitSystemRequestContext)); | 375 &IOThread::InitSystemRequestContext)); |
| 371 } | 376 } |
| 372 | 377 |
| 373 IOThread::~IOThread() { | 378 IOThread::~IOThread() { |
| 374 if (pref_proxy_config_tracker_) | 379 if (pref_proxy_config_tracker_.get()) |
| 375 pref_proxy_config_tracker_->DetachFromPrefService(); | 380 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 376 // We cannot rely on our base class to stop the thread since we want our | 381 // We cannot rely on our base class to stop the thread since we want our |
| 377 // CleanUp function to run. | 382 // CleanUp function to run. |
| 378 Stop(); | 383 Stop(); |
| 379 DCHECK(!globals_); | 384 DCHECK(!globals_); |
| 380 } | 385 } |
| 381 | 386 |
| 382 IOThread::Globals* IOThread::globals() { | 387 IOThread::Globals* IOThread::globals() { |
| 383 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 388 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 384 return globals_; | 389 return globals_; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 net::SSLConfigService* IOThread::GetSSLConfigService() { | 577 net::SSLConfigService* IOThread::GetSSLConfigService() { |
| 573 return ssl_config_service_manager_->Get(); | 578 return ssl_config_service_manager_->Get(); |
| 574 } | 579 } |
| 575 | 580 |
| 576 void IOThread::InitSystemRequestContext() { | 581 void IOThread::InitSystemRequestContext() { |
| 577 if (system_url_request_context_getter_) | 582 if (system_url_request_context_getter_) |
| 578 return; | 583 return; |
| 579 // If we're in unit_tests, IOThread may not be run. | 584 // If we're in unit_tests, IOThread may not be run. |
| 580 if (!message_loop()) | 585 if (!message_loop()) |
| 581 return; | 586 return; |
| 582 system_proxy_config_service_.reset( | 587 ChromeProxyConfigService* proxy_config_service = |
| 583 ProxyServiceFactory::CreateProxyConfigService( | 588 ProxyServiceFactory::CreateProxyConfigService(); |
| 584 pref_proxy_config_tracker_)); | 589 system_proxy_config_service_.reset(proxy_config_service); |
| 590 if (pref_proxy_config_tracker_.get()) { |
| 591 pref_proxy_config_tracker_->SetChromeProxyConfigService( |
| 592 proxy_config_service); |
| 593 } |
| 585 system_url_request_context_getter_ = | 594 system_url_request_context_getter_ = |
| 586 new SystemURLRequestContextGetter(this); | 595 new SystemURLRequestContextGetter(this); |
| 587 message_loop()->PostTask( | 596 message_loop()->PostTask( |
| 588 FROM_HERE, | 597 FROM_HERE, |
| 589 NewRunnableMethod( | 598 NewRunnableMethod( |
| 590 this, | 599 this, |
| 591 &IOThread::InitSystemRequestContextOnIOThread)); | 600 &IOThread::InitSystemRequestContextOnIOThread)); |
| 592 } | 601 } |
| 593 | 602 |
| 594 void IOThread::InitSystemRequestContextOnIOThread() { | 603 void IOThread::InitSystemRequestContextOnIOThread() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 619 system_params.network_delegate = globals_->system_network_delegate.get(); | 628 system_params.network_delegate = globals_->system_network_delegate.get(); |
| 620 system_params.net_log = net_log_; | 629 system_params.net_log = net_log_; |
| 621 globals_->system_http_transaction_factory.reset( | 630 globals_->system_http_transaction_factory.reset( |
| 622 new net::HttpNetworkLayer( | 631 new net::HttpNetworkLayer( |
| 623 new net::HttpNetworkSession(system_params))); | 632 new net::HttpNetworkSession(system_params))); |
| 624 globals_->system_ftp_transaction_factory.reset( | 633 globals_->system_ftp_transaction_factory.reset( |
| 625 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 634 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
| 626 globals_->system_request_context = | 635 globals_->system_request_context = |
| 627 ConstructSystemRequestContext(globals_, net_log_); | 636 ConstructSystemRequestContext(globals_, net_log_); |
| 628 } | 637 } |
| OLD | NEW |