| 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/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 #include "chrome/browser/net/chrome_url_request_context.h" | 28 #include "chrome/browser/net/chrome_url_request_context.h" |
| 29 #include "chrome/browser/net/connect_interceptor.h" | 29 #include "chrome/browser/net/connect_interceptor.h" |
| 30 #include "chrome/browser/net/dns_probe_service.h" | 30 #include "chrome/browser/net/dns_probe_service.h" |
| 31 #include "chrome/browser/net/http_pipelining_compatibility_client.h" | 31 #include "chrome/browser/net/http_pipelining_compatibility_client.h" |
| 32 #include "chrome/browser/net/load_time_stats.h" | 32 #include "chrome/browser/net/load_time_stats.h" |
| 33 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 33 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
| 34 #include "chrome/browser/net/proxy_service_factory.h" | 34 #include "chrome/browser/net/proxy_service_factory.h" |
| 35 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 35 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
| 36 #include "chrome/browser/net/spdyproxy/http_auth_handler_spdyproxy.h" | 36 #include "chrome/browser/net/spdyproxy/http_auth_handler_spdyproxy.h" |
| 37 #include "chrome/browser/policy/policy_service.h" | 37 #include "chrome/browser/policy/policy_service.h" |
| 38 #include "chrome/browser/prefs/pref_registry_simple.h" |
| 38 #include "chrome/browser/prefs/pref_service.h" | 39 #include "chrome/browser/prefs/pref_service.h" |
| 39 #include "chrome/common/chrome_switches.h" | 40 #include "chrome/common/chrome_switches.h" |
| 40 #include "chrome/common/pref_names.h" | 41 #include "chrome/common/pref_names.h" |
| 41 #include "content/public/browser/browser_thread.h" | 42 #include "content/public/browser/browser_thread.h" |
| 42 #include "net/base/cert_verifier.h" | 43 #include "net/base/cert_verifier.h" |
| 43 #include "net/base/default_server_bound_cert_store.h" | 44 #include "net/base/default_server_bound_cert_store.h" |
| 44 #include "net/base/host_cache.h" | 45 #include "net/base/host_cache.h" |
| 45 #include "net/base/host_mapping_rules.h" | 46 #include "net/base/host_mapping_rules.h" |
| 46 #include "net/base/host_resolver.h" | 47 #include "net/base/host_resolver.h" |
| 47 #include "net/base/mapped_host_resolver.h" | 48 #include "net/base/mapped_host_resolver.h" |
| (...skipping 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 testing_fixed_http_port(0), | 357 testing_fixed_http_port(0), |
| 357 testing_fixed_https_port(0), | 358 testing_fixed_https_port(0), |
| 358 enable_user_alternate_protocol_ports(false) { | 359 enable_user_alternate_protocol_ports(false) { |
| 359 } | 360 } |
| 360 | 361 |
| 361 IOThread::Globals::~Globals() {} | 362 IOThread::Globals::~Globals() {} |
| 362 | 363 |
| 363 // |local_state| is passed in explicitly in order to (1) reduce implicit | 364 // |local_state| is passed in explicitly in order to (1) reduce implicit |
| 364 // dependencies and (2) make IOThread more flexible for testing. | 365 // dependencies and (2) make IOThread more flexible for testing. |
| 365 IOThread::IOThread( | 366 IOThread::IOThread( |
| 366 PrefServiceSimple* local_state, | 367 PrefService* local_state, |
| 367 policy::PolicyService* policy_service, | 368 policy::PolicyService* policy_service, |
| 368 ChromeNetLog* net_log, | 369 ChromeNetLog* net_log, |
| 369 extensions::EventRouterForwarder* extension_event_router_forwarder) | 370 extensions::EventRouterForwarder* extension_event_router_forwarder) |
| 370 : net_log_(net_log), | 371 : net_log_(net_log), |
| 371 extension_event_router_forwarder_(extension_event_router_forwarder), | 372 extension_event_router_forwarder_(extension_event_router_forwarder), |
| 372 globals_(NULL), | 373 globals_(NULL), |
| 373 sdch_manager_(NULL), | 374 sdch_manager_(NULL), |
| 374 is_spdy_disabled_by_policy_(false), | 375 is_spdy_disabled_by_policy_(false), |
| 375 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { | 376 ALLOW_THIS_IN_INITIALIZER_LIST(weak_factory_(this)) { |
| 376 #if !defined(OS_IOS) && !defined(OS_ANDROID) | 377 #if !defined(OS_IOS) && !defined(OS_ANDROID) |
| 377 net::ProxyResolverV8::RememberDefaultIsolate(); | 378 net::ProxyResolverV8::RememberDefaultIsolate(); |
| 378 #endif | 379 #endif |
| 379 // We call RegisterPrefs() here (instead of inside browser_prefs.cc) to make | 380 // We call RegisterPrefs() here (instead of inside browser_prefs.cc) to make |
| 380 // sure that everything is initialized in the right order. | 381 // sure that everything is initialized in the right order. |
| 381 // | 382 // |
| 382 // TODO(joi): See if we can fix so it does get registered from | 383 // TODO(joi): See if we can fix so it does get registered from |
| 383 // browser_prefs::RegisterLocalState. | 384 // browser_prefs::RegisterLocalState. |
| 384 RegisterPrefs(local_state); | 385 PrefRegistrySimple* registry = static_cast<PrefRegistrySimple*>( |
| 386 local_state->DeprecatedGetPrefRegistry()); |
| 387 RegisterPrefs(registry); |
| 385 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); | 388 auth_schemes_ = local_state->GetString(prefs::kAuthSchemes); |
| 386 negotiate_disable_cname_lookup_ = local_state->GetBoolean( | 389 negotiate_disable_cname_lookup_ = local_state->GetBoolean( |
| 387 prefs::kDisableAuthNegotiateCnameLookup); | 390 prefs::kDisableAuthNegotiateCnameLookup); |
| 388 negotiate_enable_port_ = local_state->GetBoolean( | 391 negotiate_enable_port_ = local_state->GetBoolean( |
| 389 prefs::kEnableAuthNegotiatePort); | 392 prefs::kEnableAuthNegotiatePort); |
| 390 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); | 393 auth_server_whitelist_ = local_state->GetString(prefs::kAuthServerWhitelist); |
| 391 auth_delegate_whitelist_ = local_state->GetString( | 394 auth_delegate_whitelist_ = local_state->GetString( |
| 392 prefs::kAuthNegotiateDelegateWhitelist); | 395 prefs::kAuthNegotiateDelegateWhitelist); |
| 393 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); | 396 gssapi_library_name_ = local_state->GetString(prefs::kGSSAPILibraryName); |
| 394 pref_proxy_config_tracker_.reset( | 397 pref_proxy_config_tracker_.reset( |
| (...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 733 globals_->initial_max_spdy_concurrent_streams.set(streams); | 736 globals_->initial_max_spdy_concurrent_streams.set(streams); |
| 734 } else if (option.empty() && it == spdy_options.begin()) { | 737 } else if (option.empty() && it == spdy_options.begin()) { |
| 735 continue; | 738 continue; |
| 736 } else { | 739 } else { |
| 737 LOG(DFATAL) << "Unrecognized spdy option: " << option; | 740 LOG(DFATAL) << "Unrecognized spdy option: " << option; |
| 738 } | 741 } |
| 739 } | 742 } |
| 740 } | 743 } |
| 741 | 744 |
| 742 // static | 745 // static |
| 743 void IOThread::RegisterPrefs(PrefServiceSimple* local_state) { | 746 void IOThread::RegisterPrefs(PrefRegistrySimple* registry) { |
| 744 local_state->RegisterStringPref(prefs::kAuthSchemes, | 747 registry->RegisterStringPref(prefs::kAuthSchemes, |
| 745 "basic,digest,ntlm,negotiate," | 748 "basic,digest,ntlm,negotiate," |
| 746 "spdyproxy"); | 749 "spdyproxy"); |
| 747 local_state->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, | 750 registry->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, |
| 748 false); | 751 false); |
| 749 local_state->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false); | 752 registry->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false); |
| 750 local_state->RegisterStringPref(prefs::kAuthServerWhitelist, ""); | 753 registry->RegisterStringPref(prefs::kAuthServerWhitelist, ""); |
| 751 local_state->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, ""); | 754 registry->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, ""); |
| 752 local_state->RegisterStringPref(prefs::kGSSAPILibraryName, ""); | 755 registry->RegisterStringPref(prefs::kGSSAPILibraryName, ""); |
| 753 local_state->RegisterStringPref(prefs::kSpdyProxyOrigin, ""); | 756 registry->RegisterStringPref(prefs::kSpdyProxyOrigin, ""); |
| 754 local_state->RegisterBooleanPref(prefs::kEnableReferrers, true); | 757 registry->RegisterBooleanPref(prefs::kEnableReferrers, true); |
| 755 local_state->RegisterInt64Pref(prefs::kHttpReceivedContentLength, 0); | 758 registry->RegisterInt64Pref(prefs::kHttpReceivedContentLength, 0); |
| 756 local_state->RegisterInt64Pref(prefs::kHttpOriginalContentLength, 0); | 759 registry->RegisterInt64Pref(prefs::kHttpOriginalContentLength, 0); |
| 757 local_state->RegisterBooleanPref( | 760 registry->RegisterBooleanPref( |
| 758 prefs::kBuiltInDnsClientEnabled, | 761 prefs::kBuiltInDnsClientEnabled, |
| 759 chrome_browser_net::ConfigureAsyncDnsFieldTrial()); | 762 chrome_browser_net::ConfigureAsyncDnsFieldTrial()); |
| 760 } | 763 } |
| 761 | 764 |
| 762 net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( | 765 net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( |
| 763 net::HostResolver* resolver) { | 766 net::HostResolver* resolver) { |
| 764 net::HttpAuthFilterWhitelist* auth_filter_default_credentials = NULL; | 767 net::HttpAuthFilterWhitelist* auth_filter_default_credentials = NULL; |
| 765 if (!auth_server_whitelist_.empty()) { | 768 if (!auth_server_whitelist_.empty()) { |
| 766 auth_filter_default_credentials = | 769 auth_filter_default_credentials = |
| 767 new net::HttpAuthFilterWhitelist(auth_server_whitelist_); | 770 new net::HttpAuthFilterWhitelist(auth_server_whitelist_); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 globals_->system_request_context.reset( | 912 globals_->system_request_context.reset( |
| 910 ConstructSystemRequestContext(globals_, net_log_)); | 913 ConstructSystemRequestContext(globals_, net_log_)); |
| 911 | 914 |
| 912 sdch_manager_->set_sdch_fetcher( | 915 sdch_manager_->set_sdch_fetcher( |
| 913 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); | 916 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); |
| 914 } | 917 } |
| 915 | 918 |
| 916 void IOThread::UpdateDnsClientEnabled() { | 919 void IOThread::UpdateDnsClientEnabled() { |
| 917 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); | 920 globals()->host_resolver->SetDnsClientEnabled(*dns_client_enabled_); |
| 918 } | 921 } |
| OLD | NEW |