| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/base64.h" | 9 #include "base/base64.h" |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 extensions::EventRouterForwarder* extension_event_router_forwarder) | 456 extensions::EventRouterForwarder* extension_event_router_forwarder) |
| 457 : net_log_(net_log), | 457 : net_log_(net_log), |
| 458 #if defined(ENABLE_EXTENSIONS) | 458 #if defined(ENABLE_EXTENSIONS) |
| 459 extension_event_router_forwarder_(extension_event_router_forwarder), | 459 extension_event_router_forwarder_(extension_event_router_forwarder), |
| 460 #endif | 460 #endif |
| 461 globals_(NULL), | 461 globals_(NULL), |
| 462 is_spdy_disabled_by_policy_(false), | 462 is_spdy_disabled_by_policy_(false), |
| 463 is_quic_allowed_by_policy_(true), | 463 is_quic_allowed_by_policy_(true), |
| 464 creation_time_(base::TimeTicks::Now()), | 464 creation_time_(base::TimeTicks::Now()), |
| 465 weak_factory_(this) { | 465 weak_factory_(this) { |
| 466 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); | 466 scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy = |
| 467 negotiate_disable_cname_lookup_ = local_state->GetBoolean( | 467 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
| 468 prefs::kDisableAuthNegotiateCnameLookup); | 468 http_auth_preferences_.Init(local_state, io_thread_proxy); |
| 469 negotiate_enable_port_ = local_state->GetBoolean( | |
| 470 prefs::kEnableAuthNegotiatePort); | |
| 471 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); | |
| 472 auth_delegate_whitelist_ = local_state->GetString( | |
| 473 prefs::kAuthNegotiateDelegateWhitelist); | |
| 474 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); | |
| 475 auth_android_negotiate_account_type_ = | |
| 476 local_state->GetString(prefs::kAuthAndroidNegotiateAccountType); | |
| 477 pref_proxy_config_tracker_.reset( | 469 pref_proxy_config_tracker_.reset( |
| 478 ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 470 ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
| 479 local_state)); | 471 local_state)); |
| 480 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 472 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
| 481 &system_enable_referrers_, | 473 &system_enable_referrers_, |
| 482 NULL, | 474 NULL, |
| 483 NULL, | 475 NULL, |
| 484 NULL, | 476 NULL, |
| 485 local_state); | 477 local_state); |
| 486 ssl_config_service_manager_.reset( | 478 ssl_config_service_manager_.reset( |
| 487 ssl_config::SSLConfigServiceManager::CreateDefaultManager( | 479 ssl_config::SSLConfigServiceManager::CreateDefaultManager( |
| 488 local_state, | 480 local_state, |
| 489 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 481 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
| 490 | 482 |
| 491 base::Value* dns_client_enabled_default = new base::FundamentalValue( | 483 base::Value* dns_client_enabled_default = new base::FundamentalValue( |
| 492 chrome_browser_net::ConfigureAsyncDnsFieldTrial()); | 484 chrome_browser_net::ConfigureAsyncDnsFieldTrial()); |
| 493 local_state->SetDefaultPrefValue(prefs::kBuiltInDnsClientEnabled, | 485 local_state->SetDefaultPrefValue(prefs::kBuiltInDnsClientEnabled, |
| 494 dns_client_enabled_default); | 486 dns_client_enabled_default); |
| 495 chrome_browser_net::LogAsyncDnsPrefSource( | 487 chrome_browser_net::LogAsyncDnsPrefSource( |
| 496 local_state->FindPreference(prefs::kBuiltInDnsClientEnabled)); | 488 local_state->FindPreference(prefs::kBuiltInDnsClientEnabled)); |
| 497 | 489 |
| 498 dns_client_enabled_.Init(prefs::kBuiltInDnsClientEnabled, | 490 dns_client_enabled_.Init(prefs::kBuiltInDnsClientEnabled, |
| 499 local_state, | 491 local_state, |
| 500 base::Bind(&IOThread::UpdateDnsClientEnabled, | 492 base::Bind(&IOThread::UpdateDnsClientEnabled, |
| 501 base::Unretained(this))); | 493 base::Unretained(this))); |
| 502 dns_client_enabled_.MoveToThread( | 494 dns_client_enabled_.MoveToThread(io_thread_proxy); |
| 503 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
| 504 | 495 |
| 505 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, | 496 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, |
| 506 local_state); | 497 local_state); |
| 507 quick_check_enabled_.MoveToThread( | 498 quick_check_enabled_.MoveToThread(io_thread_proxy); |
| 508 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
| 509 | 499 |
| 510 #if defined(ENABLE_CONFIGURATION_POLICY) | 500 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 511 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( | 501 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( |
| 512 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( | 502 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( |
| 513 policy::key::kDisableSpdy) != NULL; | 503 policy::key::kDisableSpdy) != NULL; |
| 514 | 504 |
| 515 const base::Value* value = policy_service->GetPolicies( | 505 const base::Value* value = policy_service->GetPolicies( |
| 516 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, | 506 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, |
| 517 std::string())).GetValue(policy::key::kQuicAllowed); | 507 std::string())).GetValue(policy::key::kQuicAllowed); |
| 518 if (value) | 508 if (value) |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 714 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
| 725 // is fixed. | 715 // is fixed. |
| 726 tracked_objects::ScopedTracker tracking_profile10( | 716 tracked_objects::ScopedTracker tracking_profile10( |
| 727 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 717 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 728 "466432 IOThread::InitAsync::CertPolicyEnforcer")); | 718 "466432 IOThread::InitAsync::CertPolicyEnforcer")); |
| 729 net::CertPolicyEnforcer* policy_enforcer = new net::CertPolicyEnforcer; | 719 net::CertPolicyEnforcer* policy_enforcer = new net::CertPolicyEnforcer; |
| 730 globals_->cert_policy_enforcer.reset(policy_enforcer); | 720 globals_->cert_policy_enforcer.reset(policy_enforcer); |
| 731 | 721 |
| 732 globals_->ssl_config_service = GetSSLConfigService(); | 722 globals_->ssl_config_service = GetSSLConfigService(); |
| 733 | 723 |
| 734 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( | 724 CreateDefaultAuthHandlerFactory(); |
| 735 globals_->host_resolver.get())); | |
| 736 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); | 725 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); |
| 737 // For the ProxyScriptFetcher, we use a direct ProxyService. | 726 // For the ProxyScriptFetcher, we use a direct ProxyService. |
| 738 globals_->proxy_script_fetcher_proxy_service = | 727 globals_->proxy_script_fetcher_proxy_service = |
| 739 net::ProxyService::CreateDirectWithNetLog(net_log_); | 728 net::ProxyService::CreateDirectWithNetLog(net_log_); |
| 740 // In-memory cookie store. | 729 // In-memory cookie store. |
| 741 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 730 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
| 742 // is fixed. | 731 // is fixed. |
| 743 tracked_objects::ScopedTracker tracking_profile11( | 732 tracked_objects::ScopedTracker tracking_profile11( |
| 744 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 733 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 745 "466432 IOThread::InitAsync::CreateCookieStore::Start")); | 734 "466432 IOThread::InitAsync::CreateCookieStore::Start")); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 // Release objects that the net::URLRequestContext could have been pointing | 852 // Release objects that the net::URLRequestContext could have been pointing |
| 864 // to. | 853 // to. |
| 865 | 854 |
| 866 // Shutdown the HistogramWatcher on the IO thread. | 855 // Shutdown the HistogramWatcher on the IO thread. |
| 867 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); | 856 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); |
| 868 | 857 |
| 869 // This must be reset before the ChromeNetLog is destroyed. | 858 // This must be reset before the ChromeNetLog is destroyed. |
| 870 network_change_observer_.reset(); | 859 network_change_observer_.reset(); |
| 871 | 860 |
| 872 system_proxy_config_service_.reset(); | 861 system_proxy_config_service_.reset(); |
| 862 #if defined(OS_ANDROID) |
| 863 // Only needed for tests, since we never do a clean shutdown of the real |
| 864 // application on Android. |
| 865 external_data_use_observer_.reset(); |
| 866 #endif |
| 873 | 867 |
| 874 delete globals_; | 868 delete globals_; |
| 875 globals_ = NULL; | 869 globals_ = NULL; |
| 876 | 870 |
| 877 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); | 871 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); |
| 878 } | 872 } |
| 879 | 873 |
| 880 void IOThread::InitializeNetworkOptions(const base::CommandLine& command_line) { | 874 void IOThread::InitializeNetworkOptions(const base::CommandLine& command_line) { |
| 881 // Only handle use-spdy command line flags if "spdy.disabled" preference is | 875 // Only handle use-spdy command line flags if "spdy.disabled" preference is |
| 882 // not disabled via policy. | 876 // not disabled via policy. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 983 void IOThread::ConfigureNPNGlobals(base::StringPiece npn_trial_group, | 977 void IOThread::ConfigureNPNGlobals(base::StringPiece npn_trial_group, |
| 984 IOThread::Globals* globals) { | 978 IOThread::Globals* globals) { |
| 985 if (npn_trial_group.starts_with(kNpnTrialEnabledGroupNamePrefix)) { | 979 if (npn_trial_group.starts_with(kNpnTrialEnabledGroupNamePrefix)) { |
| 986 globals->enable_npn.set(true); | 980 globals->enable_npn.set(true); |
| 987 } else if (npn_trial_group.starts_with(kNpnTrialDisabledGroupNamePrefix)) { | 981 } else if (npn_trial_group.starts_with(kNpnTrialDisabledGroupNamePrefix)) { |
| 988 globals->enable_npn.set(false); | 982 globals->enable_npn.set(false); |
| 989 } | 983 } |
| 990 } | 984 } |
| 991 | 985 |
| 992 void IOThread::RegisterPrefs(PrefRegistrySimple* registry) { | 986 void IOThread::RegisterPrefs(PrefRegistrySimple* registry) { |
| 993 registry->RegisterStringPref(prefs::kAuthSchemes, | 987 net::HttpAuthPreferences::RegisterPrefs(registry); |
| 994 "basic,digest,ntlm,negotiate"); | |
| 995 registry->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, false); | |
| 996 registry->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false); | |
| 997 registry->RegisterStringPref(prefs::kAuthServerWhitelist, std::string()); | |
| 998 registry->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, | |
| 999 std::string()); | |
| 1000 registry->RegisterStringPref(prefs::kGSSAPILibraryName, std::string()); | |
| 1001 registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, | |
| 1002 std::string()); | |
| 1003 registry->RegisterStringPref( | 988 registry->RegisterStringPref( |
| 1004 data_reduction_proxy::prefs::kDataReductionProxy, std::string()); | 989 data_reduction_proxy::prefs::kDataReductionProxy, std::string()); |
| 1005 registry->RegisterBooleanPref(prefs::kEnableReferrers, true); | 990 registry->RegisterBooleanPref(prefs::kEnableReferrers, true); |
| 1006 data_reduction_proxy::RegisterPrefs(registry); | 991 data_reduction_proxy::RegisterPrefs(registry); |
| 1007 registry->RegisterBooleanPref(prefs::kBuiltInDnsClientEnabled, true); | 992 registry->RegisterBooleanPref(prefs::kBuiltInDnsClientEnabled, true); |
| 1008 registry->RegisterBooleanPref(prefs::kQuickCheckEnabled, true); | 993 registry->RegisterBooleanPref(prefs::kQuickCheckEnabled, true); |
| 1009 } | 994 } |
| 1010 | 995 |
| 1011 net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( | 996 void IOThread::CreateDefaultAuthHandlerFactory() { |
| 1012 net::HostResolver* resolver) { | 997 globals_->http_auth_handler_factory = |
| 1013 net::HttpAuthFilterWhitelist* auth_filter_default_credentials = NULL; | 998 net::HttpAuthHandlerRegistryFactory::Create(&http_auth_preferences_, |
| 1014 if (!auth_server_whitelist_.empty()) { | 999 globals_->host_resolver.get()) |
| 1015 auth_filter_default_credentials = | 1000 .Pass(); |
| 1016 new net::HttpAuthFilterWhitelist(auth_server_whitelist_); | |
| 1017 } | |
| 1018 net::HttpAuthFilterWhitelist* auth_filter_delegate = NULL; | |
| 1019 if (!auth_delegate_whitelist_.empty()) { | |
| 1020 auth_filter_delegate = | |
| 1021 new net::HttpAuthFilterWhitelist(auth_delegate_whitelist_); | |
| 1022 } | |
| 1023 globals_->url_security_manager.reset( | |
| 1024 net::URLSecurityManager::Create(auth_filter_default_credentials, | |
| 1025 auth_filter_delegate)); | |
| 1026 std::vector<std::string> supported_schemes = base::SplitString( | |
| 1027 auth_schemes_, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | |
| 1028 | |
| 1029 scoped_ptr<net::HttpAuthHandlerRegistryFactory> registry_factory( | |
| 1030 net::HttpAuthHandlerRegistryFactory::Create( | |
| 1031 supported_schemes, globals_->url_security_manager.get(), resolver, | |
| 1032 gssapi_library_name_, auth_android_negotiate_account_type_, | |
| 1033 negotiate_disable_cname_lookup_, negotiate_enable_port_)); | |
| 1034 return registry_factory.release(); | |
| 1035 } | 1001 } |
| 1036 | 1002 |
| 1037 void IOThread::ClearHostCache() { | 1003 void IOThread::ClearHostCache() { |
| 1038 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1004 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1039 | 1005 |
| 1040 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); | 1006 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); |
| 1041 if (host_cache) | 1007 if (host_cache) |
| 1042 host_cache->clear(); | 1008 host_cache->clear(); |
| 1043 } | 1009 } |
| 1044 | 1010 |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1657 globals->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); | 1623 globals->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); |
| 1658 | 1624 |
| 1659 context->set_job_factory( | 1625 context->set_job_factory( |
| 1660 globals->proxy_script_fetcher_url_request_job_factory.get()); | 1626 globals->proxy_script_fetcher_url_request_job_factory.get()); |
| 1661 | 1627 |
| 1662 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 1628 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
| 1663 // system URLRequestContext too. There's no reason this should be tied to a | 1629 // system URLRequestContext too. There's no reason this should be tied to a |
| 1664 // profile. | 1630 // profile. |
| 1665 return context; | 1631 return context; |
| 1666 } | 1632 } |
| OLD | NEW |