diff options
author | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-10 07:32:53 +0000 |
---|---|---|
committer | willchan@chromium.org <willchan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-10 07:32:53 +0000 |
commit | 17291a02bb3589d94ceb63fbb14ca59fff75e163 (patch) | |
tree | dff2d5c6919d567ced7dcbfeea6c8daa580b0673 /chrome/browser | |
parent | cd6e0ba8e0d9435222349ff4d4d7b19d137d9c57 (diff) | |
download | chromium_src-17291a02bb3589d94ceb63fbb14ca59fff75e163.zip chromium_src-17291a02bb3589d94ceb63fbb14ca59fff75e163.tar.gz chromium_src-17291a02bb3589d94ceb63fbb14ca59fff75e163.tar.bz2 |
Migrate HttpAlternateProtocols to HttpServerPropertiesImpl.
Hooks in HttpServerPropertiesManager also. No persistence done yet. This is all plumbing.
Also require HttpServerProperties in HttpNetworkSession::Params.
BUG=98472
TEST=none
Review URL: http://codereview.chromium.org/8211003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@104696 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/io_thread.cc | 5 | ||||
-rw-r--r-- | chrome/browser/io_thread.h | 2 | ||||
-rw-r--r-- | chrome/browser/net/connection_tester.cc | 3 | ||||
-rw-r--r-- | chrome/browser/net/connection_tester_unittest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/net/http_server_properties_manager.cc | 49 | ||||
-rw-r--r-- | chrome/browser/net/http_server_properties_manager.h | 40 | ||||
-rw-r--r-- | chrome/browser/net/http_server_properties_manager_unittest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/profiles/off_the_record_profile_io_data.cc | 5 | ||||
-rw-r--r-- | chrome/browser/profiles/off_the_record_profile_io_data.h | 5 | ||||
-rw-r--r-- | chrome/browser/ui/webui/net_internals_ui.cc | 31 |
10 files changed, 115 insertions, 32 deletions
diff --git a/chrome/browser/io_thread.cc b/chrome/browser/io_thread.cc index c0e0159..3fce1ca 100644 --- a/chrome/browser/io_thread.cc +++ b/chrome/browser/io_thread.cc @@ -51,6 +51,7 @@ #include "net/http/http_auth_handler_factory.h" #include "net/http/http_network_layer.h" #include "net/http/http_network_session.h" +#include "net/http/http_server_properties_impl.h" #include "net/proxy/proxy_config_service.h" #include "net/proxy/proxy_script_fetcher_impl.h" #include "net/proxy/proxy_service.h" @@ -437,6 +438,7 @@ void IOThread::Init() { globals_->ssl_config_service = GetSSLConfigService(); globals_->http_auth_handler_factory.reset(CreateDefaultAuthHandlerFactory( globals_->host_resolver.get())); + globals_->http_server_properties.reset(new net::HttpServerPropertiesImpl); // For the ProxyScriptFetcher, we use a direct ProxyService. globals_->proxy_script_fetcher_proxy_service.reset( net::ProxyService::CreateDirectWithNetLog(net_log_)); @@ -459,6 +461,8 @@ void IOThread::Init() { // TODO(rtenneti): We should probably use HttpServerPropertiesManager for the // system URLRequestContext too. There's no reason this should be tied to a // profile. + session_params.http_server_properties = + globals_->http_server_properties.get(); session_params.net_log = net_log_; session_params.ssl_config_service = globals_->ssl_config_service; scoped_refptr<net::HttpNetworkSession> network_session( @@ -617,6 +621,7 @@ void IOThread::InitSystemRequestContextOnIOThread() { system_params.ssl_config_service = globals_->ssl_config_service.get(); system_params.http_auth_handler_factory = globals_->http_auth_handler_factory.get(); + system_params.http_server_properties = globals_->http_server_properties.get(); system_params.network_delegate = globals_->system_network_delegate.get(); system_params.net_log = net_log_; globals_->system_http_transaction_factory.reset( diff --git a/chrome/browser/io_thread.h b/chrome/browser/io_thread.h index a8eb014..b4fd0a8 100644 --- a/chrome/browser/io_thread.h +++ b/chrome/browser/io_thread.h @@ -35,6 +35,7 @@ class DnsRRResolver; class FtpTransactionFactory; class HostResolver; class HttpAuthHandlerFactory; +class HttpServerProperties; class HttpTransactionFactory; class NetworkDelegate; class OriginBoundCertService; @@ -67,6 +68,7 @@ class IOThread : public BrowserProcessSubThread { scoped_ptr<net::DnsRRResolver> dnsrr_resolver; scoped_refptr<net::SSLConfigService> ssl_config_service; scoped_ptr<net::HttpAuthHandlerFactory> http_auth_handler_factory; + scoped_ptr<net::HttpServerProperties> http_server_properties; scoped_ptr<net::ProxyService> proxy_script_fetcher_proxy_service; scoped_ptr<net::HttpTransactionFactory> proxy_script_fetcher_http_transaction_factory; diff --git a/chrome/browser/net/connection_tester.cc b/chrome/browser/net/connection_tester.cc index e09bed3..4578ded 100644 --- a/chrome/browser/net/connection_tester.cc +++ b/chrome/browser/net/connection_tester.cc @@ -26,6 +26,7 @@ #include "net/http/http_auth_handler_factory.h" #include "net/http/http_cache.h" #include "net/http/http_network_session.h" +#include "net/http/http_server_properties_impl.h" #include "net/proxy/dhcp_proxy_script_fetcher_factory.h" #include "net/proxy/proxy_config_service_fixed.h" #include "net/proxy/proxy_script_fetcher_impl.h" @@ -76,6 +77,7 @@ class ExperimentURLRequestContext : public net::URLRequestContext { storage_.set_ssl_config_service(new net::SSLConfigServiceDefaults); storage_.set_http_auth_handler_factory( net::HttpAuthHandlerFactory::CreateDefault(host_resolver())); + storage_.set_http_server_properties(new net::HttpServerPropertiesImpl); net::HttpNetworkSession::Params session_params; session_params.host_resolver = host_resolver(); @@ -83,6 +85,7 @@ class ExperimentURLRequestContext : public net::URLRequestContext { session_params.cert_verifier = cert_verifier(); session_params.proxy_service = proxy_service(); session_params.http_auth_handler_factory = http_auth_handler_factory(); + session_params.http_server_properties = http_server_properties(); session_params.ssl_config_service = ssl_config_service(); scoped_refptr<net::HttpNetworkSession> network_session( new net::HttpNetworkSession(session_params)); diff --git a/chrome/browser/net/connection_tester_unittest.cc b/chrome/browser/net/connection_tester_unittest.cc index 61eda59..258c62e 100644 --- a/chrome/browser/net/connection_tester_unittest.cc +++ b/chrome/browser/net/connection_tester_unittest.cc @@ -15,6 +15,7 @@ #include "net/http/http_auth_handler_factory.h" #include "net/http/http_network_layer.h" #include "net/http/http_network_session.h" +#include "net/http/http_server_properties_impl.h" #include "net/proxy/proxy_config_service_fixed.h" #include "net/proxy/proxy_service.h" #include "net/test/test_server.h" @@ -111,6 +112,7 @@ class ConnectionTesterTest : public PlatformTest { scoped_ptr<net::HttpTransactionFactory> http_transaction_factory_; net::HttpAuthHandlerRegistryFactory http_auth_handler_factory_; scoped_refptr<net::URLRequestContext> proxy_script_fetcher_context_; + net::HttpServerPropertiesImpl http_server_properties_impl_; private: void InitializeRequestContext() { @@ -129,6 +131,7 @@ class ConnectionTesterTest : public PlatformTest { session_params.http_auth_handler_factory = &http_auth_handler_factory_; session_params.ssl_config_service = ssl_config_service_; session_params.proxy_service = proxy_service_.get(); + session_params.http_server_properties = &http_server_properties_impl_; scoped_refptr<net::HttpNetworkSession> network_session( new net::HttpNetworkSession(session_params)); http_transaction_factory_.reset( diff --git a/chrome/browser/net/http_server_properties_manager.cc b/chrome/browser/net/http_server_properties_manager.cc index 0d3b669..9bcab3c 100644 --- a/chrome/browser/net/http_server_properties_manager.cc +++ b/chrome/browser/net/http_server_properties_manager.cc @@ -90,6 +90,18 @@ void HttpServerPropertiesManager::ShutdownOnUIThread() { pref_change_registrar_.RemoveAll(); } +// static +void HttpServerPropertiesManager::RegisterPrefs(PrefService* prefs) { + prefs->RegisterListPref(prefs::kSpdyServers, PrefService::UNSYNCABLE_PREF); +} + +void HttpServerPropertiesManager::DeleteAll() { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + + http_server_properties_impl_->DeleteAll(); + ScheduleUpdatePrefsOnIO(); +} + bool HttpServerPropertiesManager::SupportsSpdy( const net::HostPortPair& server) const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); @@ -105,16 +117,38 @@ void HttpServerPropertiesManager::SetSupportsSpdy( ScheduleUpdatePrefsOnIO(); } -void HttpServerPropertiesManager::DeleteAll() { +bool HttpServerPropertiesManager::HasAlternateProtocol( + const net::HostPortPair& server) const { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + return http_server_properties_impl_->HasAlternateProtocol(server); +} + +net::PortAlternateProtocolPair +HttpServerPropertiesManager::GetAlternateProtocol( + const net::HostPortPair& server) const { DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + return http_server_properties_impl_->GetAlternateProtocol(server); +} - http_server_properties_impl_->DeleteAll(); - ScheduleUpdatePrefsOnIO(); +void HttpServerPropertiesManager::SetAlternateProtocol( + const net::HostPortPair& server, + uint16 alternate_port, + net::AlternateProtocol alternate_protocol) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + http_server_properties_impl_->SetAlternateProtocol( + server, alternate_port, alternate_protocol); } -// static -void HttpServerPropertiesManager::RegisterPrefs(PrefService* prefs) { - prefs->RegisterListPref(prefs::kSpdyServers, PrefService::UNSYNCABLE_PREF); +void HttpServerPropertiesManager::SetBrokenAlternateProtocol( + const net::HostPortPair& server) { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + http_server_properties_impl_->SetBrokenAlternateProtocol(server); +} + +const net::AlternateProtocolMap& +HttpServerPropertiesManager::alternate_protocol_map() const { + DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); + return http_server_properties_impl_->alternate_protocol_map(); } // @@ -163,7 +197,8 @@ void HttpServerPropertiesManager::UpdateCacheFromPrefsOnIO( // preferences. Clear the cached data and use the new spdy server list from // preferences. scoped_ptr<StringVector> scoped_spdy_servers(spdy_servers); - http_server_properties_impl_->Initialize(spdy_servers, support_spdy); + http_server_properties_impl_->InitializeSpdyServers(spdy_servers, + support_spdy); } // diff --git a/chrome/browser/net/http_server_properties_manager.h b/chrome/browser/net/http_server_properties_manager.h index f19f68d..572922e 100644 --- a/chrome/browser/net/http_server_properties_manager.h +++ b/chrome/browser/net/http_server_properties_manager.h @@ -6,6 +6,8 @@ #define CHROME_BROWSER_NET_HTTP_SERVER_PROPERTIES_MANAGER_H_ #pragma once +#include <string> +#include <vector> #include "base/basictypes.h" #include "base/compiler_specific.h" #include "base/memory/ref_counted.h" @@ -65,6 +67,16 @@ class HttpServerPropertiesManager // Prepare for shutdown. Must be called on the UI thread, before destruction. void ShutdownOnUIThread(); + // Register |prefs| for properties managed here. + static void RegisterPrefs(PrefService* prefs); + + // ---------------------------------- + // net::HttpServerProperties methods: + // ---------------------------------- + + // Deletes all data. + virtual void DeleteAll() OVERRIDE; + // Returns true if |server| supports SPDY. Should only be called from IO // thread. virtual bool SupportsSpdy(const net::HostPortPair& server) const OVERRIDE; @@ -74,11 +86,28 @@ class HttpServerPropertiesManager virtual void SetSupportsSpdy(const net::HostPortPair& server, bool support_spdy) OVERRIDE; - // Deletes all data. - virtual void DeleteAll() OVERRIDE; + // Returns true if |server| has an Alternate-Protocol header. + virtual bool HasAlternateProtocol( + const net::HostPortPair& server) const OVERRIDE; - // Register |prefs| SPDY preferences. - static void RegisterPrefs(PrefService* prefs); + // Returns the Alternate-Protocol and port for |server|. + // HasAlternateProtocol(server) must be true. + virtual net::PortAlternateProtocolPair GetAlternateProtocol( + const net::HostPortPair& server) const OVERRIDE; + + // Sets the Alternate-Protocol for |server|. + virtual void SetAlternateProtocol( + const net::HostPortPair& server, + uint16 alternate_port, + net::AlternateProtocol alternate_protocol) OVERRIDE; + + // Sets the Alternate-Protocol for |server| to be BROKEN. + virtual void SetBrokenAlternateProtocol( + const net::HostPortPair& server) OVERRIDE; + + // Returns all Alternate-Protocol mappings. + virtual const net::AlternateProtocolMap& + alternate_protocol_map() const OVERRIDE; protected: typedef base::RefCountedData<base::ListValue> RefCountedListValue; @@ -93,7 +122,8 @@ class HttpServerPropertiesManager virtual void UpdateCacheFromPrefs(); // Starts the |spdy_servers| update on the IO thread. Protected for testing. - void UpdateCacheFromPrefsOnIO(StringVector* spdy_servers, bool support_spdy); + void UpdateCacheFromPrefsOnIO(std::vector<std::string>* spdy_servers, + bool support_spdy); // These are used to delay updating the preferences when spdy servers_ are // changing, and execute only one update per simultaneous spdy server changes. diff --git a/chrome/browser/net/http_server_properties_manager_unittest.cc b/chrome/browser/net/http_server_properties_manager_unittest.cc index cda95e0..1c95eab 100644 --- a/chrome/browser/net/http_server_properties_manager_unittest.cc +++ b/chrome/browser/net/http_server_properties_manager_unittest.cc @@ -44,7 +44,7 @@ class TestingHttpServerPropertiesManager : public HttpServerPropertiesManager { // Makes a direct call to UpdateCacheFromPrefsOnIO during tests. void UpdateCacheFromPrefsOnIO() { - StringVector* spdy_servers = new StringVector; + std::vector<std::string>* spdy_servers = new std::vector<std::string>; spdy_servers->push_back("www.google.com:443"); HttpServerPropertiesManager::UpdateCacheFromPrefsOnIO(spdy_servers, true); } @@ -78,7 +78,7 @@ class TestingHttpServerPropertiesManager : public HttpServerPropertiesManager { MOCK_METHOD0(UpdateCacheFromPrefs, void()); MOCK_METHOD0(UpdatePrefsFromCache, void()); MOCK_METHOD2(UpdateCacheFromPrefsOnIO, - void(StringVector* spdy_servers, bool support_spdy)); + void(std::vector<std::string>* spdy_servers, bool support_spdy)); MOCK_METHOD1(SetSpdyServersInPrefsOnUI, void(scoped_refptr<RefCountedListValue> spdy_server_list)); diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.cc b/chrome/browser/profiles/off_the_record_profile_io_data.cc index 1c6b0ec..cf3d126 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.cc +++ b/chrome/browser/profiles/off_the_record_profile_io_data.cc @@ -23,6 +23,7 @@ #include "net/base/origin_bound_cert_service.h" #include "net/ftp/ftp_network_layer.h" #include "net/http/http_cache.h" +#include "net/http/http_server_properties_impl.h" #include "webkit/database/database_tracker.h" OffTheRecordProfileIOData::Handle::Handle(Profile* profile) @@ -165,6 +166,10 @@ void OffTheRecordProfileIOData::LazyInitializeInternal( main_context->set_dns_cert_checker(dns_cert_checker()); main_context->set_proxy_service(proxy_service()); + // For incognito, we use the default non-persistent HttpServerPropertiesImpl. + http_server_properties_.reset(new net::HttpServerPropertiesImpl); + main_context->set_http_server_properties(http_server_properties_.get()); + // For incognito, we use a non-persistent origin bound cert store. net::OriginBoundCertService* origin_bound_cert_service = new net::OriginBoundCertService( diff --git a/chrome/browser/profiles/off_the_record_profile_io_data.h b/chrome/browser/profiles/off_the_record_profile_io_data.h index cbeb632..52bffc6 100644 --- a/chrome/browser/profiles/off_the_record_profile_io_data.h +++ b/chrome/browser/profiles/off_the_record_profile_io_data.h @@ -17,6 +17,9 @@ class ChromeURLRequestContext; class ChromeURLRequestContextGetter; class Profile; +namespace net { +class HttpServerPropertiesImpl; +} // namespace net // OffTheRecordProfile owns a OffTheRecordProfileIOData::Handle, which holds a // reference to the OffTheRecordProfileIOData. OffTheRecordProfileIOData is @@ -103,6 +106,8 @@ class OffTheRecordProfileIOData : public ProfileIOData { mutable scoped_ptr<net::HttpTransactionFactory> main_http_factory_; + mutable scoped_ptr<net::HttpServerPropertiesImpl> http_server_properties_; + DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileIOData); }; diff --git a/chrome/browser/ui/webui/net_internals_ui.cc b/chrome/browser/ui/webui/net_internals_ui.cc index 3ea8237..723990c 100644 --- a/chrome/browser/ui/webui/net_internals_ui.cc +++ b/chrome/browser/ui/webui/net_internals_ui.cc @@ -51,10 +51,10 @@ #include "net/base/sys_addrinfo.h" #include "net/base/x509_cert_types.h" #include "net/disk_cache/disk_cache.h" -#include "net/http/http_alternate_protocols.h" #include "net/http/http_cache.h" #include "net/http/http_network_layer.h" #include "net/http/http_network_session.h" +#include "net/http/http_server_properties.h" #include "net/http/http_stream_factory.h" #include "net/proxy/proxy_service.h" #include "net/url_request/url_request_context.h" @@ -1198,25 +1198,20 @@ void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyStatus( void NetInternalsMessageHandler::IOThreadImpl::OnGetSpdyAlternateProtocolMappings( const ListValue* list) { - net::HttpNetworkSession* http_network_session = - GetHttpNetworkSession(context_getter_->GetURLRequestContext()); - ListValue* dict_list = new ListValue(); - if (http_network_session) { - const net::HttpAlternateProtocols& http_alternate_protocols = - http_network_session->alternate_protocols(); - const net::HttpAlternateProtocols::ProtocolMap& map = - http_alternate_protocols.protocol_map(); - - for (net::HttpAlternateProtocols::ProtocolMap::const_iterator it = - map.begin(); - it != map.end(); ++it) { - DictionaryValue* dict = new DictionaryValue(); - dict->SetString("host_port_pair", it->first.ToString()); - dict->SetString("alternate_protocol", it->second.ToString()); - dict_list->Append(dict); - } + const net::HttpServerProperties& http_server_properties = + *context_getter_->GetURLRequestContext()->http_server_properties(); + + const net::AlternateProtocolMap& map = + http_server_properties.alternate_protocol_map(); + + for (net::AlternateProtocolMap::const_iterator it = map.begin(); + it != map.end(); ++it) { + DictionaryValue* dict = new DictionaryValue(); + dict->SetString("host_port_pair", it->first.ToString()); + dict->SetString("alternate_protocol", it->second.ToString()); + dict_list->Append(dict); } SendJavascriptCommand(L"receivedSpdyAlternateProtocolMappings", dict_list); |