Chromium Code Reviews| 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 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 69 #include "net/cert/ct_verifier.h" | 69 #include "net/cert/ct_verifier.h" |
| 70 #include "net/cert/multi_log_ct_verifier.h" | 70 #include "net/cert/multi_log_ct_verifier.h" |
| 71 #include "net/cert/multi_threaded_cert_verifier.h" | 71 #include "net/cert/multi_threaded_cert_verifier.h" |
| 72 #include "net/cookies/cookie_store.h" | 72 #include "net/cookies/cookie_store.h" |
| 73 #include "net/dns/host_cache.h" | 73 #include "net/dns/host_cache.h" |
| 74 #include "net/dns/host_resolver.h" | 74 #include "net/dns/host_resolver.h" |
| 75 #include "net/dns/mapped_host_resolver.h" | 75 #include "net/dns/mapped_host_resolver.h" |
| 76 #include "net/ftp/ftp_network_layer.h" | 76 #include "net/ftp/ftp_network_layer.h" |
| 77 #include "net/http/http_auth_filter.h" | 77 #include "net/http/http_auth_filter.h" |
| 78 #include "net/http/http_auth_handler_factory.h" | 78 #include "net/http/http_auth_handler_factory.h" |
| 79 #include "net/http/http_auth_preferences.h" | |
| 79 #include "net/http/http_network_layer.h" | 80 #include "net/http/http_network_layer.h" |
| 80 #include "net/http/http_network_session.h" | 81 #include "net/http/http_network_session.h" |
| 81 #include "net/http/http_server_properties_impl.h" | 82 #include "net/http/http_server_properties_impl.h" |
| 82 #include "net/proxy/proxy_config_service.h" | 83 #include "net/proxy/proxy_config_service.h" |
| 83 #include "net/proxy/proxy_script_fetcher_impl.h" | 84 #include "net/proxy/proxy_script_fetcher_impl.h" |
| 84 #include "net/proxy/proxy_service.h" | 85 #include "net/proxy/proxy_service.h" |
| 85 #include "net/quic/crypto/crypto_protocol.h" | 86 #include "net/quic/crypto/crypto_protocol.h" |
| 86 #include "net/quic/quic_protocol.h" | 87 #include "net/quic/quic_protocol.h" |
| 87 #include "net/quic/quic_utils.h" | 88 #include "net/quic/quic_utils.h" |
| 88 #include "net/socket/ssl_client_socket.h" | 89 #include "net/socket/ssl_client_socket.h" |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 460 extensions::EventRouterForwarder* extension_event_router_forwarder) | 461 extensions::EventRouterForwarder* extension_event_router_forwarder) |
| 461 : net_log_(net_log), | 462 : net_log_(net_log), |
| 462 #if defined(ENABLE_EXTENSIONS) | 463 #if defined(ENABLE_EXTENSIONS) |
| 463 extension_event_router_forwarder_(extension_event_router_forwarder), | 464 extension_event_router_forwarder_(extension_event_router_forwarder), |
| 464 #endif | 465 #endif |
| 465 globals_(NULL), | 466 globals_(NULL), |
| 466 is_spdy_disabled_by_policy_(false), | 467 is_spdy_disabled_by_policy_(false), |
| 467 is_quic_allowed_by_policy_(true), | 468 is_quic_allowed_by_policy_(true), |
| 468 creation_time_(base::TimeTicks::Now()), | 469 creation_time_(base::TimeTicks::Now()), |
| 469 weak_factory_(this) { | 470 weak_factory_(this) { |
| 471 scoped_refptr<base::SingleThreadTaskRunner> io_thread_proxy = | |
| 472 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); | |
| 470 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); | 473 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); |
| 471 negotiate_disable_cname_lookup_ = local_state->GetBoolean( | 474 negotiate_disable_cname_lookup_.Init( |
| 472 prefs::kDisableAuthNegotiateCnameLookup); | 475 prefs::kDisableAuthNegotiateCnameLookup, local_state, |
| 473 negotiate_enable_port_ = local_state->GetBoolean( | 476 base::Bind(&IOThread::UpdateNegotiateDisableCnameLookup, |
| 474 prefs::kEnableAuthNegotiatePort); | 477 base::Unretained(this))); |
| 475 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); | 478 negotiate_disable_cname_lookup_.MoveToThread(io_thread_proxy); |
| 476 auth_delegate_whitelist_ = local_state->GetString( | 479 negotiate_enable_port_.Init( |
| 477 prefs::kAuthNegotiateDelegateWhitelist); | 480 prefs::kEnableAuthNegotiatePort, local_state, |
| 481 base::Bind(&IOThread::UpdateNegotiateEnablePort, base::Unretained(this))); | |
| 482 negotiate_enable_port_.MoveToThread(io_thread_proxy); | |
| 483 auth_server_whitelist_.Init( | |
| 484 prefs::kAuthServerWhitelist, local_state, | |
| 485 base::Bind(&IOThread::UpdateServerWhitelist, base::Unretained(this))); | |
| 486 auth_server_whitelist_.MoveToThread(io_thread_proxy); | |
| 487 auth_delegate_whitelist_.Init( | |
| 488 prefs::kAuthNegotiateDelegateWhitelist, local_state, | |
| 489 base::Bind(&IOThread::UpdateDelegateWhitelist, base::Unretained(this))); | |
| 490 auth_delegate_whitelist_.MoveToThread(io_thread_proxy); | |
| 491 #if defined(OS_ANDROID) | |
| 492 auth_android_negotiate_account_type_.Init( | |
| 493 prefs::kAuthAndroidNegotiateAccountType, local_state, | |
| 494 base::Bind(&IOThread::UpdateAndroidAuthNegotiateAccountType, | |
| 495 base::Unretained(this))); | |
| 496 auth_android_negotiate_account_type_.MoveToThread(io_thread_proxy); | |
| 497 #endif | |
| 498 #if defined(OS_POSIX) && !defined(OS_ANDROID) | |
| 478 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); | 499 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); |
| 479 auth_android_negotiate_account_type_ = | 500 #endif |
| 480 local_state->GetString(prefs::kAuthAndroidNegotiateAccountType); | |
| 481 pref_proxy_config_tracker_.reset( | 501 pref_proxy_config_tracker_.reset( |
| 482 ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 502 ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
| 483 local_state)); | 503 local_state)); |
| 484 ChromeNetworkDelegate::InitializePrefsOnUIThread( | 504 ChromeNetworkDelegate::InitializePrefsOnUIThread( |
| 485 &system_enable_referrers_, | 505 &system_enable_referrers_, |
| 486 NULL, | 506 NULL, |
| 487 NULL, | 507 NULL, |
| 488 NULL, | 508 NULL, |
| 489 local_state); | 509 local_state); |
| 490 ssl_config_service_manager_.reset( | 510 ssl_config_service_manager_.reset( |
| 491 ssl_config::SSLConfigServiceManager::CreateDefaultManager( | 511 ssl_config::SSLConfigServiceManager::CreateDefaultManager( |
| 492 local_state, | 512 local_state, |
| 493 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); | 513 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO))); |
| 494 | 514 |
| 495 base::Value* dns_client_enabled_default = new base::FundamentalValue( | 515 base::Value* dns_client_enabled_default = new base::FundamentalValue( |
| 496 chrome_browser_net::ConfigureAsyncDnsFieldTrial()); | 516 chrome_browser_net::ConfigureAsyncDnsFieldTrial()); |
| 497 local_state->SetDefaultPrefValue(prefs::kBuiltInDnsClientEnabled, | 517 local_state->SetDefaultPrefValue(prefs::kBuiltInDnsClientEnabled, |
| 498 dns_client_enabled_default); | 518 dns_client_enabled_default); |
| 499 chrome_browser_net::LogAsyncDnsPrefSource( | 519 chrome_browser_net::LogAsyncDnsPrefSource( |
| 500 local_state->FindPreference(prefs::kBuiltInDnsClientEnabled)); | 520 local_state->FindPreference(prefs::kBuiltInDnsClientEnabled)); |
| 501 | 521 |
| 502 dns_client_enabled_.Init(prefs::kBuiltInDnsClientEnabled, | 522 dns_client_enabled_.Init(prefs::kBuiltInDnsClientEnabled, |
| 503 local_state, | 523 local_state, |
| 504 base::Bind(&IOThread::UpdateDnsClientEnabled, | 524 base::Bind(&IOThread::UpdateDnsClientEnabled, |
| 505 base::Unretained(this))); | 525 base::Unretained(this))); |
| 506 dns_client_enabled_.MoveToThread( | 526 dns_client_enabled_.MoveToThread(io_thread_proxy); |
| 507 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
| 508 | 527 |
| 509 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, | 528 quick_check_enabled_.Init(prefs::kQuickCheckEnabled, |
| 510 local_state); | 529 local_state); |
| 511 quick_check_enabled_.MoveToThread( | 530 quick_check_enabled_.MoveToThread(io_thread_proxy); |
| 512 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO)); | |
| 513 | 531 |
| 514 #if defined(ENABLE_CONFIGURATION_POLICY) | 532 #if defined(ENABLE_CONFIGURATION_POLICY) |
| 515 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( | 533 is_spdy_disabled_by_policy_ = policy_service->GetPolicies( |
| 516 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( | 534 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, std::string())).Get( |
| 517 policy::key::kDisableSpdy) != NULL; | 535 policy::key::kDisableSpdy) != NULL; |
| 518 | 536 |
| 519 const base::Value* value = policy_service->GetPolicies( | 537 const base::Value* value = policy_service->GetPolicies( |
| 520 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, | 538 policy::PolicyNamespace(policy::POLICY_DOMAIN_CHROME, |
| 521 std::string())).GetValue(policy::key::kQuicAllowed); | 539 std::string())).GetValue(policy::key::kQuicAllowed); |
| 522 if (value) | 540 if (value) |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 735 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 753 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
| 736 // is fixed. | 754 // is fixed. |
| 737 tracked_objects::ScopedTracker tracking_profile10( | 755 tracked_objects::ScopedTracker tracking_profile10( |
| 738 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 756 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 739 "466432 IOThread::InitAsync::CertPolicyEnforcer")); | 757 "466432 IOThread::InitAsync::CertPolicyEnforcer")); |
| 740 net::CertPolicyEnforcer* policy_enforcer = new net::CertPolicyEnforcer; | 758 net::CertPolicyEnforcer* policy_enforcer = new net::CertPolicyEnforcer; |
| 741 globals_->cert_policy_enforcer.reset(policy_enforcer); | 759 globals_->cert_policy_enforcer.reset(policy_enforcer); |
| 742 | 760 |
| 743 globals_->ssl_config_service = GetSSLConfigService(); | 761 globals_->ssl_config_service = GetSSLConfigService(); |
| 744 | 762 |
| 745 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( | 763 CreateDefaultAuthHandlerFactory(); |
| 746 globals_->host_resolver.get())); | |
| 747 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); | 764 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl()); |
| 748 // For the ProxyScriptFetcher, we use a direct ProxyService. | 765 // For the ProxyScriptFetcher, we use a direct ProxyService. |
| 749 globals_->proxy_script_fetcher_proxy_service = | 766 globals_->proxy_script_fetcher_proxy_service = |
| 750 net::ProxyService::CreateDirectWithNetLog(net_log_); | 767 net::ProxyService::CreateDirectWithNetLog(net_log_); |
| 751 // In-memory cookie store. | 768 // In-memory cookie store. |
| 752 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 | 769 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/466432 |
| 753 // is fixed. | 770 // is fixed. |
| 754 tracked_objects::ScopedTracker tracking_profile11( | 771 tracked_objects::ScopedTracker tracking_profile11( |
| 755 FROM_HERE_WITH_EXPLICIT_FUNCTION( | 772 FROM_HERE_WITH_EXPLICIT_FUNCTION( |
| 756 "466432 IOThread::InitAsync::CreateCookieStore::Start")); | 773 "466432 IOThread::InitAsync::CreateCookieStore::Start")); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 874 // Release objects that the net::URLRequestContext could have been pointing | 891 // Release objects that the net::URLRequestContext could have been pointing |
| 875 // to. | 892 // to. |
| 876 | 893 |
| 877 // Shutdown the HistogramWatcher on the IO thread. | 894 // Shutdown the HistogramWatcher on the IO thread. |
| 878 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); | 895 net::NetworkChangeNotifier::ShutdownHistogramWatcher(); |
| 879 | 896 |
| 880 // This must be reset before the ChromeNetLog is destroyed. | 897 // This must be reset before the ChromeNetLog is destroyed. |
| 881 network_change_observer_.reset(); | 898 network_change_observer_.reset(); |
| 882 | 899 |
| 883 system_proxy_config_service_.reset(); | 900 system_proxy_config_service_.reset(); |
| 884 | |
| 885 delete globals_; | 901 delete globals_; |
| 886 globals_ = NULL; | 902 globals_ = NULL; |
| 887 | 903 |
| 888 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); | 904 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); |
| 889 } | 905 } |
| 890 | 906 |
| 891 void IOThread::InitializeNetworkOptions(const base::CommandLine& command_line) { | 907 void IOThread::InitializeNetworkOptions(const base::CommandLine& command_line) { |
| 892 // Only handle use-spdy command line flags if "spdy.disabled" preference is | 908 // Only handle use-spdy command line flags if "spdy.disabled" preference is |
| 893 // not disabled via policy. | 909 // not disabled via policy. |
| 894 if (is_spdy_disabled_by_policy_) { | 910 if (is_spdy_disabled_by_policy_) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1012 registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, | 1028 registry->RegisterStringPref(prefs::kAuthAndroidNegotiateAccountType, |
| 1013 std::string()); | 1029 std::string()); |
| 1014 registry->RegisterStringPref( | 1030 registry->RegisterStringPref( |
| 1015 data_reduction_proxy::prefs::kDataReductionProxy, std::string()); | 1031 data_reduction_proxy::prefs::kDataReductionProxy, std::string()); |
| 1016 registry->RegisterBooleanPref(prefs::kEnableReferrers, true); | 1032 registry->RegisterBooleanPref(prefs::kEnableReferrers, true); |
| 1017 data_reduction_proxy::RegisterPrefs(registry); | 1033 data_reduction_proxy::RegisterPrefs(registry); |
| 1018 registry->RegisterBooleanPref(prefs::kBuiltInDnsClientEnabled, true); | 1034 registry->RegisterBooleanPref(prefs::kBuiltInDnsClientEnabled, true); |
| 1019 registry->RegisterBooleanPref(prefs::kQuickCheckEnabled, true); | 1035 registry->RegisterBooleanPref(prefs::kQuickCheckEnabled, true); |
| 1020 } | 1036 } |
| 1021 | 1037 |
| 1022 net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( | 1038 void IOThread::UpdateServerWhitelist() { |
| 1023 net::HostResolver* resolver) { | 1039 globals_->http_auth_preferences->set_server_whitelist( |
| 1024 net::HttpAuthFilterWhitelist* auth_filter_default_credentials = NULL; | 1040 auth_server_whitelist_.GetValue()); |
| 1025 if (!auth_server_whitelist_.empty()) { | 1041 } |
| 1026 auth_filter_default_credentials = | 1042 |
| 1027 new net::HttpAuthFilterWhitelist(auth_server_whitelist_); | 1043 void IOThread::UpdateDelegateWhitelist() { |
| 1028 } | 1044 globals_->http_auth_preferences->set_delegate_whitelist( |
| 1029 net::HttpAuthFilterWhitelist* auth_filter_delegate = NULL; | 1045 auth_delegate_whitelist_.GetValue()); |
| 1030 if (!auth_delegate_whitelist_.empty()) { | 1046 } |
| 1031 auth_filter_delegate = | 1047 |
| 1032 new net::HttpAuthFilterWhitelist(auth_delegate_whitelist_); | 1048 #if defined(OS_ANDROID) |
| 1033 } | 1049 void IOThread::UpdateAndroidAuthNegotiateAccountType() { |
| 1034 globals_->url_security_manager.reset( | 1050 globals_->http_auth_preferences->set_auth_android_negotiate_account_type( |
| 1035 net::URLSecurityManager::Create(auth_filter_default_credentials, | 1051 auth_android_negotiate_account_type_.GetValue()); |
| 1036 auth_filter_delegate)); | 1052 } |
| 1053 #endif | |
| 1054 | |
| 1055 void IOThread::UpdateNegotiateDisableCnameLookup() { | |
| 1056 globals_->http_auth_preferences->set_negotiate_disable_cname_lookup( | |
| 1057 negotiate_disable_cname_lookup_.GetValue()); | |
| 1058 } | |
| 1059 | |
| 1060 void IOThread::UpdateNegotiateEnablePort() { | |
| 1061 globals_->http_auth_preferences->set_negotiate_enable_port( | |
| 1062 negotiate_enable_port_.GetValue()); | |
| 1063 } | |
| 1064 void IOThread::CreateDefaultAuthHandlerFactory() { | |
|
asanka
2015/11/25 19:00:09
Nit: add new line.
aberent
2015/11/26 15:58:00
Done.
| |
| 1037 std::vector<std::string> supported_schemes = base::SplitString( | 1065 std::vector<std::string> supported_schemes = base::SplitString( |
| 1038 auth_schemes_, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 1066 auth_schemes_, ",", base::TRIM_WHITESPACE, base::SPLIT_WANT_NONEMPTY); |
| 1039 | 1067 globals_->http_auth_preferences.reset(new net::HttpAuthPreferences( |
| 1040 scoped_ptr<net::HttpAuthHandlerRegistryFactory> registry_factory( | 1068 supported_schemes |
| 1069 #if defined(OS_POSIX) && !defined(OS_ANDROID) | |
| 1070 , | |
| 1071 gssapi_library_name_ | |
| 1072 #endif | |
| 1073 )); | |
| 1074 UpdateServerWhitelist(); | |
| 1075 UpdateDelegateWhitelist(); | |
| 1076 UpdateNegotiateDisableCnameLookup(); | |
| 1077 UpdateNegotiateEnablePort(); | |
| 1078 #if defined(OS_ANDROID) | |
| 1079 UpdateAndroidAuthNegotiateAccountType(); | |
| 1080 #endif | |
| 1081 globals_->http_auth_handler_factory = | |
| 1041 net::HttpAuthHandlerRegistryFactory::Create( | 1082 net::HttpAuthHandlerRegistryFactory::Create( |
| 1042 supported_schemes, globals_->url_security_manager.get(), resolver, | 1083 globals_->http_auth_preferences.get(), globals_->host_resolver.get()) |
| 1043 gssapi_library_name_, auth_android_negotiate_account_type_, | 1084 .Pass(); |
| 1044 negotiate_disable_cname_lookup_, negotiate_enable_port_)); | |
| 1045 return registry_factory.release(); | |
| 1046 } | 1085 } |
| 1047 | 1086 |
| 1048 void IOThread::ClearHostCache() { | 1087 void IOThread::ClearHostCache() { |
| 1049 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 1088 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 1050 | 1089 |
| 1051 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); | 1090 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); |
| 1052 if (host_cache) | 1091 if (host_cache) |
| 1053 host_cache->clear(); | 1092 host_cache->clear(); |
| 1054 } | 1093 } |
| 1055 | 1094 |
| (...skipping 608 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1664 globals->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); | 1703 globals->proxy_script_fetcher_url_request_job_factory = job_factory.Pass(); |
| 1665 | 1704 |
| 1666 context->set_job_factory( | 1705 context->set_job_factory( |
| 1667 globals->proxy_script_fetcher_url_request_job_factory.get()); | 1706 globals->proxy_script_fetcher_url_request_job_factory.get()); |
| 1668 | 1707 |
| 1669 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the | 1708 // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the |
| 1670 // system URLRequestContext too. There's no reason this should be tied to a | 1709 // system URLRequestContext too. There's no reason this should be tied to a |
| 1671 // profile. | 1710 // profile. |
| 1672 return context; | 1711 return context; |
| 1673 } | 1712 } |
| OLD | NEW |