| 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_network_delegate.h" | 22 #include "chrome/browser/net/chrome_network_delegate.h" |
| 23 #include "chrome/browser/net/chrome_net_log.h" | 23 #include "chrome/browser/net/chrome_net_log.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/browser_thread.h" | 33 #include "content/browser/browser_thread.h" |
| 34 #include "content/browser/gpu/gpu_process_host.h" | 34 #include "content/browser/gpu/gpu_process_host.h" |
| 35 #include "content/browser/in_process_webkit/indexed_db_key_utility_client.h" | 35 #include "content/browser/in_process_webkit/indexed_db_key_utility_client.h" |
| 36 #include "content/common/content_client.h" | 36 #include "content/common/content_client.h" |
| 37 #include "content/common/net/url_fetcher.h" | 37 #include "content/common/net/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 namespace { | 69 namespace { |
| 66 | 70 |
| 67 // Custom URLRequestContext used by requests which aren't associated with a | 71 // Custom URLRequestContext used by requests which aren't associated with a |
| 68 // particular profile. We need to use a subclass of URLRequestContext in order | 72 // particular profile. We need to use a subclass of URLRequestContext in order |
| 69 // to provide the correct User-Agent. | 73 // to provide the correct User-Agent. |
| 70 class URLRequestContextWithUserAgent : public net::URLRequestContext { | 74 class URLRequestContextWithUserAgent : public net::URLRequestContext { |
| 71 public: | 75 public: |
| 72 virtual const std::string& GetUserAgent( | 76 virtual const std::string& GetUserAgent( |
| 73 const GURL& url) const OVERRIDE { | 77 const GURL& url) const OVERRIDE { |
| 74 return content::GetUserAgent(url); | 78 return content::GetUserAgent(url); |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 RegisterPrefs(local_state); | 360 RegisterPrefs(local_state); |
| 357 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); | 361 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); |
| 358 negotiate_disable_cname_lookup_ = local_state->GetBoolean( | 362 negotiate_disable_cname_lookup_ = local_state->GetBoolean( |
| 359 prefs::kDisableAuthNegotiateCnameLookup); | 363 prefs::kDisableAuthNegotiateCnameLookup); |
| 360 negotiate_enable_port_ = local_state->GetBoolean( | 364 negotiate_enable_port_ = local_state->GetBoolean( |
| 361 prefs::kEnableAuthNegotiatePort); | 365 prefs::kEnableAuthNegotiatePort); |
| 362 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); | 366 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); |
| 363 auth_delegate_whitelist_ = local_state->GetString( | 367 auth_delegate_whitelist_ = local_state->GetString( |
| 364 prefs::kAuthNegotiateDelegateWhitelist); | 368 prefs::kAuthNegotiateDelegateWhitelist); |
| 365 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); | 369 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); |
| 366 pref_proxy_config_tracker_ = new PrefProxyConfigTracker(local_state); | 370 pref_proxy_config_tracker_.reset( |
| 371 ProxyServiceFactory::CreatePrefProxyConfigTracker(local_state)); |
| 367 ChromeNetworkDelegate::InitializeReferrersEnabled(&system_enable_referrers_, | 372 ChromeNetworkDelegate::InitializeReferrersEnabled(&system_enable_referrers_, |
| 368 local_state); | 373 local_state); |
| 369 ssl_config_service_manager_.reset( | 374 ssl_config_service_manager_.reset( |
| 370 SSLConfigServiceManager::CreateDefaultManager(local_state)); | 375 SSLConfigServiceManager::CreateDefaultManager(local_state)); |
| 371 MessageLoop::current()->PostTask(FROM_HERE, | 376 MessageLoop::current()->PostTask(FROM_HERE, |
| 372 method_factory_.NewRunnableMethod( | 377 method_factory_.NewRunnableMethod( |
| 373 &IOThread::InitSystemRequestContext)); | 378 &IOThread::InitSystemRequestContext)); |
| 374 } | 379 } |
| 375 | 380 |
| 376 IOThread::~IOThread() { | 381 IOThread::~IOThread() { |
| 377 if (pref_proxy_config_tracker_) | 382 if (pref_proxy_config_tracker_.get()) |
| 378 pref_proxy_config_tracker_->DetachFromPrefService(); | 383 pref_proxy_config_tracker_->DetachFromPrefService(); |
| 379 // We cannot rely on our base class to stop the thread since we want our | 384 // We cannot rely on our base class to stop the thread since we want our |
| 380 // CleanUp function to run. | 385 // CleanUp function to run. |
| 381 Stop(); | 386 Stop(); |
| 382 DCHECK(!globals_); | 387 DCHECK(!globals_); |
| 383 } | 388 } |
| 384 | 389 |
| 385 IOThread::Globals* IOThread::globals() { | 390 IOThread::Globals* IOThread::globals() { |
| 386 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 391 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 387 return globals_; | 392 return globals_; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 net::SSLConfigService* IOThread::GetSSLConfigService() { | 580 net::SSLConfigService* IOThread::GetSSLConfigService() { |
| 576 return ssl_config_service_manager_->Get(); | 581 return ssl_config_service_manager_->Get(); |
| 577 } | 582 } |
| 578 | 583 |
| 579 void IOThread::InitSystemRequestContext() { | 584 void IOThread::InitSystemRequestContext() { |
| 580 if (system_url_request_context_getter_) | 585 if (system_url_request_context_getter_) |
| 581 return; | 586 return; |
| 582 // If we're in unit_tests, IOThread may not be run. | 587 // If we're in unit_tests, IOThread may not be run. |
| 583 if (!message_loop()) | 588 if (!message_loop()) |
| 584 return; | 589 return; |
| 585 system_proxy_config_service_.reset( | 590 ChromeProxyConfigService* proxy_config_service = |
| 586 ProxyServiceFactory::CreateProxyConfigService( | 591 ProxyServiceFactory::CreateProxyConfigService(); |
| 587 pref_proxy_config_tracker_)); | 592 system_proxy_config_service_.reset(proxy_config_service); |
| 593 if (pref_proxy_config_tracker_.get()) { |
| 594 pref_proxy_config_tracker_->SetChromeProxyConfigService( |
| 595 proxy_config_service); |
| 596 } |
| 588 system_url_request_context_getter_ = | 597 system_url_request_context_getter_ = |
| 589 new SystemURLRequestContextGetter(this); | 598 new SystemURLRequestContextGetter(this); |
| 590 message_loop()->PostTask( | 599 message_loop()->PostTask( |
| 591 FROM_HERE, | 600 FROM_HERE, |
| 592 NewRunnableMethod( | 601 NewRunnableMethod( |
| 593 this, | 602 this, |
| 594 &IOThread::InitSystemRequestContextOnIOThread)); | 603 &IOThread::InitSystemRequestContextOnIOThread)); |
| 595 } | 604 } |
| 596 | 605 |
| 597 void IOThread::InitSystemRequestContextOnIOThread() { | 606 void IOThread::InitSystemRequestContextOnIOThread() { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 622 system_params.network_delegate = globals_->system_network_delegate.get(); | 631 system_params.network_delegate = globals_->system_network_delegate.get(); |
| 623 system_params.net_log = net_log_; | 632 system_params.net_log = net_log_; |
| 624 globals_->system_http_transaction_factory.reset( | 633 globals_->system_http_transaction_factory.reset( |
| 625 new net::HttpNetworkLayer( | 634 new net::HttpNetworkLayer( |
| 626 new net::HttpNetworkSession(system_params))); | 635 new net::HttpNetworkSession(system_params))); |
| 627 globals_->system_ftp_transaction_factory.reset( | 636 globals_->system_ftp_transaction_factory.reset( |
| 628 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 637 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
| 629 globals_->system_request_context = | 638 globals_->system_request_context = |
| 630 ConstructSystemRequestContext(globals_, net_log_); | 639 ConstructSystemRequestContext(globals_, net_log_); |
| 631 } | 640 } |
| OLD | NEW |