| 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 13 matching lines...) Expand all Loading... |
| 24 #include "chrome/browser/net/async_dns_field_trial.h" | 24 #include "chrome/browser/net/async_dns_field_trial.h" |
| 25 #include "chrome/browser/net/chrome_net_log.h" | 25 #include "chrome/browser/net/chrome_net_log.h" |
| 26 #include "chrome/browser/net/chrome_network_delegate.h" | 26 #include "chrome/browser/net/chrome_network_delegate.h" |
| 27 #include "chrome/browser/net/chrome_url_request_context.h" | 27 #include "chrome/browser/net/chrome_url_request_context.h" |
| 28 #include "chrome/browser/net/connect_interceptor.h" | 28 #include "chrome/browser/net/connect_interceptor.h" |
| 29 #include "chrome/browser/net/http_pipelining_compatibility_client.h" | 29 #include "chrome/browser/net/http_pipelining_compatibility_client.h" |
| 30 #include "chrome/browser/net/load_time_stats.h" | 30 #include "chrome/browser/net/load_time_stats.h" |
| 31 #include "chrome/browser/net/pref_proxy_config_tracker.h" | 31 #include "chrome/browser/net/pref_proxy_config_tracker.h" |
| 32 #include "chrome/browser/net/proxy_service_factory.h" | 32 #include "chrome/browser/net/proxy_service_factory.h" |
| 33 #include "chrome/browser/net/sdch_dictionary_fetcher.h" | 33 #include "chrome/browser/net/sdch_dictionary_fetcher.h" |
| 34 #include "chrome/browser/net/spdyproxy/http_auth_handler_spdyproxy.h" |
| 34 #include "chrome/browser/prefs/pref_service.h" | 35 #include "chrome/browser/prefs/pref_service.h" |
| 35 #include "chrome/common/chrome_switches.h" | 36 #include "chrome/common/chrome_switches.h" |
| 36 #include "chrome/common/pref_names.h" | 37 #include "chrome/common/pref_names.h" |
| 37 #include "content/public/browser/browser_thread.h" | 38 #include "content/public/browser/browser_thread.h" |
| 38 #include "content/public/common/content_client.h" | 39 #include "content/public/common/content_client.h" |
| 39 #include "net/base/cert_verifier.h" | 40 #include "net/base/cert_verifier.h" |
| 40 #include "net/base/default_server_bound_cert_store.h" | 41 #include "net/base/default_server_bound_cert_store.h" |
| 41 #include "net/base/host_cache.h" | 42 #include "net/base/host_cache.h" |
| 42 #include "net/base/host_mapping_rules.h" | 43 #include "net/base/host_mapping_rules.h" |
| 43 #include "net/base/host_resolver.h" | 44 #include "net/base/host_resolver.h" |
| (...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 NULL, | 444 NULL, |
| 444 NULL); | 445 NULL); |
| 445 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) | 446 if (command_line.HasSwitch(switches::kDisableExtensionsHttpThrottling)) |
| 446 network_delegate->NeverThrottleRequests(); | 447 network_delegate->NeverThrottleRequests(); |
| 447 globals_->system_network_delegate.reset(network_delegate); | 448 globals_->system_network_delegate.reset(network_delegate); |
| 448 globals_->host_resolver.reset( | 449 globals_->host_resolver.reset( |
| 449 CreateGlobalHostResolver(net_log_)); | 450 CreateGlobalHostResolver(net_log_)); |
| 450 globals_->cert_verifier.reset(net::CertVerifier::CreateDefault()); | 451 globals_->cert_verifier.reset(net::CertVerifier::CreateDefault()); |
| 451 globals_->transport_security_state.reset(new net::TransportSecurityState()); | 452 globals_->transport_security_state.reset(new net::TransportSecurityState()); |
| 452 globals_->ssl_config_service = GetSSLConfigService(); | 453 globals_->ssl_config_service = GetSSLConfigService(); |
| 454 if (command_line.HasSwitch(switches::kSpdyProxyOrigin)) { |
| 455 spdyproxy_origin_ = |
| 456 command_line.GetSwitchValueASCII(switches::kSpdyProxyOrigin); |
| 457 } |
| 453 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( | 458 globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( |
| 454 globals_->host_resolver.get())); | 459 globals_->host_resolver.get())); |
| 455 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl); | 460 globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl); |
| 456 // For the ProxyScriptFetcher, we use a direct ProxyService. | 461 // For the ProxyScriptFetcher, we use a direct ProxyService. |
| 457 globals_->proxy_script_fetcher_proxy_service.reset( | 462 globals_->proxy_script_fetcher_proxy_service.reset( |
| 458 net::ProxyService::CreateDirectWithNetLog(net_log_)); | 463 net::ProxyService::CreateDirectWithNetLog(net_log_)); |
| 459 // In-memory cookie store. | 464 // In-memory cookie store. |
| 460 globals_->system_cookie_store = new net::CookieMonster(NULL, NULL); | 465 globals_->system_cookie_store = new net::CookieMonster(NULL, NULL); |
| 461 // In-memory server bound cert store. | 466 // In-memory server bound cert store. |
| 462 globals_->system_server_bound_cert_service.reset( | 467 globals_->system_server_bound_cert_service.reset( |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 | 589 |
| 585 delete globals_; | 590 delete globals_; |
| 586 globals_ = NULL; | 591 globals_ = NULL; |
| 587 | 592 |
| 588 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); | 593 base::debug::LeakTracker<SystemURLRequestContextGetter>::CheckForLeaks(); |
| 589 } | 594 } |
| 590 | 595 |
| 591 // static | 596 // static |
| 592 void IOThread::RegisterPrefs(PrefService* local_state) { | 597 void IOThread::RegisterPrefs(PrefService* local_state) { |
| 593 local_state->RegisterStringPref(prefs::kAuthSchemes, | 598 local_state->RegisterStringPref(prefs::kAuthSchemes, |
| 594 "basic,digest,ntlm,negotiate"); | 599 "basic,digest,ntlm,negotiate," |
| 600 "spdyproxy"); |
| 595 local_state->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, | 601 local_state->RegisterBooleanPref(prefs::kDisableAuthNegotiateCnameLookup, |
| 596 false); | 602 false); |
| 597 local_state->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false); | 603 local_state->RegisterBooleanPref(prefs::kEnableAuthNegotiatePort, false); |
| 598 local_state->RegisterStringPref(prefs::kAuthServerWhitelist, ""); | 604 local_state->RegisterStringPref(prefs::kAuthServerWhitelist, ""); |
| 599 local_state->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, ""); | 605 local_state->RegisterStringPref(prefs::kAuthNegotiateDelegateWhitelist, ""); |
| 600 local_state->RegisterStringPref(prefs::kGSSAPILibraryName, ""); | 606 local_state->RegisterStringPref(prefs::kGSSAPILibraryName, ""); |
| 607 local_state->RegisterStringPref(prefs::kSpdyProxyOrigin, ""); |
| 601 local_state->RegisterBooleanPref(prefs::kEnableReferrers, true); | 608 local_state->RegisterBooleanPref(prefs::kEnableReferrers, true); |
| 602 } | 609 } |
| 603 | 610 |
| 604 net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( | 611 net::HttpAuthHandlerFactory* IOThread::CreateDefaultAuthHandlerFactory( |
| 605 net::HostResolver* resolver) { | 612 net::HostResolver* resolver) { |
| 606 net::HttpAuthFilterWhitelist* auth_filter_default_credentials = NULL; | 613 net::HttpAuthFilterWhitelist* auth_filter_default_credentials = NULL; |
| 607 if (!auth_server_whitelist_.empty()) { | 614 if (!auth_server_whitelist_.empty()) { |
| 608 auth_filter_default_credentials = | 615 auth_filter_default_credentials = |
| 609 new net::HttpAuthFilterWhitelist(auth_server_whitelist_); | 616 new net::HttpAuthFilterWhitelist(auth_server_whitelist_); |
| 610 } | 617 } |
| 611 net::HttpAuthFilterWhitelist* auth_filter_delegate = NULL; | 618 net::HttpAuthFilterWhitelist* auth_filter_delegate = NULL; |
| 612 if (!auth_delegate_whitelist_.empty()) { | 619 if (!auth_delegate_whitelist_.empty()) { |
| 613 auth_filter_delegate = | 620 auth_filter_delegate = |
| 614 new net::HttpAuthFilterWhitelist(auth_delegate_whitelist_); | 621 new net::HttpAuthFilterWhitelist(auth_delegate_whitelist_); |
| 615 } | 622 } |
| 616 globals_->url_security_manager.reset( | 623 globals_->url_security_manager.reset( |
| 617 net::URLSecurityManager::Create(auth_filter_default_credentials, | 624 net::URLSecurityManager::Create(auth_filter_default_credentials, |
| 618 auth_filter_delegate)); | 625 auth_filter_delegate)); |
| 619 std::vector<std::string> supported_schemes; | 626 std::vector<std::string> supported_schemes; |
| 620 base::SplitString(auth_schemes_, ',', &supported_schemes); | 627 base::SplitString(auth_schemes_, ',', &supported_schemes); |
| 621 | 628 |
| 622 return net::HttpAuthHandlerRegistryFactory::Create( | 629 scoped_ptr<net::HttpAuthHandlerRegistryFactory> registry_factory( |
| 623 supported_schemes, | 630 net::HttpAuthHandlerRegistryFactory::Create( |
| 624 globals_->url_security_manager.get(), | 631 supported_schemes, globals_->url_security_manager.get(), |
| 625 resolver, | 632 resolver, gssapi_library_name_, negotiate_disable_cname_lookup_, |
| 626 gssapi_library_name_, | 633 negotiate_enable_port_)); |
| 627 negotiate_disable_cname_lookup_, | 634 |
| 628 negotiate_enable_port_); | 635 if (!spdyproxy_origin_.empty()) { |
| 636 GURL origin_url(spdyproxy_origin_); |
| 637 if (origin_url.is_valid()) { |
| 638 registry_factory->RegisterSchemeFactory( |
| 639 "spdyproxy", |
| 640 new spdyproxy::HttpAuthHandlerSpdyProxy::Factory(origin_url)); |
| 641 } else { |
| 642 LOG(WARNING) << "Skipping creation of SpdyProxy auth handler since " |
| 643 << "authorized origin is invalid: " |
| 644 << spdyproxy_origin_; |
| 645 } |
| 646 } |
| 647 |
| 648 return registry_factory.release(); |
| 629 } | 649 } |
| 630 | 650 |
| 631 void IOThread::ClearHostCache() { | 651 void IOThread::ClearHostCache() { |
| 632 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 652 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
| 633 | 653 |
| 634 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); | 654 net::HostCache* host_cache = globals_->host_resolver->GetHostCache(); |
| 635 if (host_cache) | 655 if (host_cache) |
| 636 host_cache->clear(); | 656 host_cache->clear(); |
| 637 } | 657 } |
| 638 | 658 |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 new net::HttpNetworkLayer( | 730 new net::HttpNetworkLayer( |
| 711 new net::HttpNetworkSession(system_params))); | 731 new net::HttpNetworkSession(system_params))); |
| 712 globals_->system_ftp_transaction_factory.reset( | 732 globals_->system_ftp_transaction_factory.reset( |
| 713 new net::FtpNetworkLayer(globals_->host_resolver.get())); | 733 new net::FtpNetworkLayer(globals_->host_resolver.get())); |
| 714 globals_->system_request_context.reset( | 734 globals_->system_request_context.reset( |
| 715 ConstructSystemRequestContext(globals_, net_log_)); | 735 ConstructSystemRequestContext(globals_, net_log_)); |
| 716 | 736 |
| 717 sdch_manager_->set_sdch_fetcher( | 737 sdch_manager_->set_sdch_fetcher( |
| 718 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); | 738 new SdchDictionaryFetcher(system_url_request_context_getter_.get())); |
| 719 } | 739 } |
| OLD | NEW |