diff options
author | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-15 19:20:31 +0000 |
---|---|---|
committer | rtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-15 19:20:31 +0000 |
commit | 53bfa31ccee6580c7e79d9024721817a07227801 (patch) | |
tree | 376c45efc814c8f31236a581eab56cb44fb4abb4 /net/spdy | |
parent | 2753d493f7fa77bf376eaca4a922596424d8a896 (diff) | |
download | chromium_src-53bfa31ccee6580c7e79d9024721817a07227801.zip chromium_src-53bfa31ccee6580c7e79d9024721817a07227801.tar.gz chromium_src-53bfa31ccee6580c7e79d9024721817a07227801.tar.bz2 |
Persist dynamically learned SPDY settings (like CWND).
BUG=70652
R=willchan
TEST=network unittests, browser unit tests
Review URL: http://codereview.chromium.org/8423028
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110143 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy')
-rw-r--r-- | net/spdy/spdy_network_transaction_unittest.cc | 21 | ||||
-rw-r--r-- | net/spdy/spdy_session.cc | 15 | ||||
-rw-r--r-- | net/spdy/spdy_session.h | 4 | ||||
-rw-r--r-- | net/spdy/spdy_session_pool.cc | 15 | ||||
-rw-r--r-- | net/spdy/spdy_session_pool.h | 9 | ||||
-rw-r--r-- | net/spdy/spdy_session_unittest.cc | 19 | ||||
-rw-r--r-- | net/spdy/spdy_websocket_stream_unittest.cc | 2 |
7 files changed, 55 insertions, 30 deletions
diff --git a/net/spdy/spdy_network_transaction_unittest.cc b/net/spdy/spdy_network_transaction_unittest.cc index bcc8201..632649b 100644 --- a/net/spdy/spdy_network_transaction_unittest.cc +++ b/net/spdy/spdy_network_transaction_unittest.cc @@ -4206,7 +4206,8 @@ TEST_P(SpdyNetworkTransactionTest, SettingsSaved) { // Verify that no settings exist initially. HostPortPair host_port_pair("www.google.com", helper.port()); SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); - EXPECT_TRUE(spdy_session_pool->spdy_settings().Get(host_port_pair).empty()); + EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( + host_port_pair).empty()); // Construct the request. scoped_ptr<spdy::SpdyFrame> req(ConstructSpdyGet(NULL, 0, false, 1, LOWEST)); @@ -4268,7 +4269,8 @@ TEST_P(SpdyNetworkTransactionTest, SettingsSaved) { { // Verify we had two persisted settings. spdy::SpdySettings saved_settings = - spdy_session_pool->spdy_settings().Get(host_port_pair); + spdy_session_pool->http_server_properties()->GetSpdySettings( + host_port_pair); ASSERT_EQ(2u, saved_settings.size()); // Verify the first persisted setting. @@ -4315,7 +4317,8 @@ TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { // Verify that no settings exist initially. HostPortPair host_port_pair("www.google.com", helper.port()); SpdySessionPool* spdy_session_pool = helper.session()->spdy_session_pool(); - EXPECT_TRUE(spdy_session_pool->spdy_settings().Get(host_port_pair).empty()); + EXPECT_TRUE(spdy_session_pool->http_server_properties()->GetSpdySettings( + host_port_pair).empty()); unsigned int kSampleId1 = 0x1; unsigned int kSampleValue1 = 0x0a0a0a0a; @@ -4334,14 +4337,17 @@ TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { setting.set_id(kSampleId2); settings.push_back(std::make_pair(setting, kSampleValue2)); - spdy_session_pool->mutable_spdy_settings()->Set(host_port_pair, settings); + spdy_session_pool->http_server_properties()->SetSpdySettings( + host_port_pair, settings); } - EXPECT_EQ(2u, spdy_session_pool->spdy_settings().Get(host_port_pair).size()); + EXPECT_EQ(2u, spdy_session_pool->http_server_properties()->GetSpdySettings( + host_port_pair).size()); // Construct the SETTINGS frame. const spdy::SpdySettings& settings = - spdy_session_pool->spdy_settings().Get(host_port_pair); + spdy_session_pool->http_server_properties()->GetSpdySettings( + host_port_pair); scoped_ptr<spdy::SpdyFrame> settings_frame(ConstructSpdySettings(settings)); // Construct the request. @@ -4381,7 +4387,8 @@ TEST_P(SpdyNetworkTransactionTest, SettingsPlayback) { { // Verify we had two persisted settings. spdy::SpdySettings saved_settings = - spdy_session_pool->spdy_settings().Get(host_port_pair); + spdy_session_pool->http_server_properties()->GetSpdySettings( + host_port_pair); ASSERT_EQ(2u, saved_settings.size()); // Verify the first persisted setting. diff --git a/net/spdy/spdy_session.cc b/net/spdy/spdy_session.cc index cffbe0f..cdd71dc 100644 --- a/net/spdy/spdy_session.cc +++ b/net/spdy/spdy_session.cc @@ -21,6 +21,7 @@ #include "net/base/net_log.h" #include "net/base/net_util.h" #include "net/http/http_network_session.h" +#include "net/http/http_server_properties.h" #include "net/socket/ssl_client_socket.h" #include "net/spdy/spdy_frame_builder.h" #include "net/spdy/spdy_http_utils.h" @@ -244,7 +245,7 @@ int SpdySession::hung_interval_ms_ = 10000; SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair, SpdySessionPool* spdy_session_pool, - SpdySettingsStorage* spdy_settings, + HttpServerProperties* http_server_properties, bool verify_domain_authentication, NetLog* net_log) : ALLOW_THIS_IN_INITIALIZER_LIST( @@ -254,7 +255,7 @@ SpdySession::SpdySession(const HostPortProxyPair& host_port_proxy_pair, ALLOW_THIS_IN_INITIALIZER_LIST(method_factory_(this)), host_port_proxy_pair_(host_port_proxy_pair), spdy_session_pool_(spdy_session_pool), - spdy_settings_(spdy_settings), + http_server_properties_(http_server_properties), connection_(new ClientSocketHandle), read_buffer_(new IOBuffer(kReadBufferSize)), read_pending_(false), @@ -1412,7 +1413,7 @@ void SpdySession::OnSettings(const spdy::SpdySettingsControlFrame& frame) { spdy::SpdySettings settings; if (spdy_framer_.ParseSettings(&frame, &settings)) { HandleSettings(settings); - spdy_settings_->Set(host_port_pair(), settings); + http_server_properties_->SetSpdySettings(host_port_pair(), settings); } received_settings_ = true; @@ -1493,7 +1494,8 @@ void SpdySession::SendSettings() { // Note: we're copying the settings here, so that we can potentially modify // the settings for the field trial. When removing the field trial, make // this a reference to the const SpdySettings again. - spdy::SpdySettings settings = spdy_settings_->Get(host_port_pair()); + spdy::SpdySettings settings = + http_server_properties_->GetSpdySettings(host_port_pair()); if (settings.empty()) return; @@ -1512,7 +1514,7 @@ void SpdySession::SendSettings() { if (cwnd != val) { i->second = cwnd; i->first.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); - spdy_settings_->Set(host_port_pair(), settings); + http_server_properties_->SetSpdySettings(host_port_pair(), settings); } break; } @@ -1674,7 +1676,8 @@ void SpdySession::RecordHistograms() { if (received_settings_) { // Enumerate the saved settings, and set histograms for it. - const spdy::SpdySettings& settings = spdy_settings_->Get(host_port_pair()); + const spdy::SpdySettings& settings = + http_server_properties_->GetSpdySettings(host_port_pair()); spdy::SpdySettings::const_iterator it; for (it = settings.begin(); it != settings.end(); ++it) { diff --git a/net/spdy/spdy_session.h b/net/spdy/spdy_session.h index b45b361..8d9b8ae 100644 --- a/net/spdy/spdy_session.h +++ b/net/spdy/spdy_session.h @@ -56,7 +56,7 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>, // network events to. SpdySession(const HostPortProxyPair& host_port_proxy_pair, SpdySessionPool* spdy_session_pool, - SpdySettingsStorage* spdy_settings, + HttpServerProperties* http_server_properties, bool verify_domain_authentication, NetLog* net_log); @@ -447,7 +447,7 @@ class NET_EXPORT SpdySession : public base::RefCounted<SpdySession>, // |spdy_session_pool_| owns us, therefore its lifetime must exceed ours. We // set this to NULL after we are removed from the pool. SpdySessionPool* spdy_session_pool_; - SpdySettingsStorage* const spdy_settings_; + HttpServerProperties* const http_server_properties_; // The socket handle for this session. scoped_ptr<ClientSocketHandle> connection_; diff --git a/net/spdy/spdy_session_pool.cc b/net/spdy/spdy_session_pool.cc index 7bac3bc..ed490e4 100644 --- a/net/spdy/spdy_session_pool.cc +++ b/net/spdy/spdy_session_pool.cc @@ -10,6 +10,7 @@ #include "net/base/address_list.h" #include "net/base/sys_addrinfo.h" #include "net/http/http_network_session.h" +#include "net/http/http_server_properties.h" #include "net/spdy/spdy_session.h" @@ -40,8 +41,10 @@ bool SpdySessionPool::g_force_single_domain = false; bool SpdySessionPool::g_enable_ip_pooling = true; SpdySessionPool::SpdySessionPool(HostResolver* resolver, - SSLConfigService* ssl_config_service) - : ssl_config_service_(ssl_config_service), + SSLConfigService* ssl_config_service, + HttpServerProperties* http_server_properties) + : http_server_properties_(http_server_properties), + ssl_config_service_(ssl_config_service), resolver_(resolver), verify_domain_authentication_(true) { NetworkChangeNotifier::AddIPAddressObserver(this); @@ -110,7 +113,8 @@ scoped_refptr<SpdySession> SpdySessionPool::GetInternal( DCHECK(!only_use_existing_sessions); - spdy_session = new SpdySession(host_port_proxy_pair, this, &spdy_settings_, + spdy_session = new SpdySession(host_port_proxy_pair, this, + http_server_properties_, verify_domain_authentication_, net_log.net_log()); UMA_HISTOGRAM_ENUMERATION("Net.SpdySessionGet", @@ -136,7 +140,8 @@ net::Error SpdySessionPool::GetSpdySessionFromSocket( IMPORTED_FROM_SOCKET, SPDY_SESSION_GET_MAX); // Create the SPDY session and add it to the pool. - *spdy_session = new SpdySession(host_port_proxy_pair, this, &spdy_settings_, + *spdy_session = new SpdySession(host_port_proxy_pair, this, + http_server_properties_, verify_domain_authentication_, net_log.net_log()); SpdySessionList* list = GetSessionList(host_port_proxy_pair); @@ -207,7 +212,7 @@ Value* SpdySessionPool::SpdySessionPoolInfoToValue() const { void SpdySessionPool::OnIPAddressChanged() { CloseCurrentSessions(); - spdy_settings_.Clear(); + http_server_properties_->ClearSpdySettings(); } void SpdySessionPool::OnSSLConfigChanged() { diff --git a/net/spdy/spdy_session_pool.h b/net/spdy/spdy_session_pool.h index 9da713e..3861481 100644 --- a/net/spdy/spdy_session_pool.h +++ b/net/spdy/spdy_session_pool.h @@ -31,6 +31,7 @@ class AddressList; class BoundNetLog; class ClientSocketHandle; class HostResolver; +class HttpServerProperties; class SpdySession; // This is a very simple pool for open SpdySessions. @@ -40,7 +41,8 @@ class NET_EXPORT SpdySessionPool public CertDatabase::Observer { public: SpdySessionPool(HostResolver* host_resolver, - SSLConfigService* ssl_config_service); + SSLConfigService* ssl_config_service, + HttpServerProperties* http_server_properties); virtual ~SpdySessionPool(); // Either returns an existing SpdySession or creates a new SpdySession for @@ -105,6 +107,10 @@ class NET_EXPORT SpdySessionPool SpdySettingsStorage* mutable_spdy_settings() { return &spdy_settings_; } const SpdySettingsStorage& spdy_settings() const { return spdy_settings_; } + HttpServerProperties* http_server_properties() { + return http_server_properties_; + } + // NetworkChangeNotifier::IPAddressObserver methods: // We flush all idle sessions and release references to the active ones so @@ -171,6 +177,7 @@ class NET_EXPORT SpdySessionPool void RemoveAliases(const HostPortProxyPair& pair); SpdySettingsStorage spdy_settings_; + HttpServerProperties* const http_server_properties_; // This is our weak session pool - one session per domain. SpdySessionsMap sessions_; diff --git a/net/spdy/spdy_session_unittest.cc b/net/spdy/spdy_session_unittest.cc index e9ec4a9..2b012a3 100644 --- a/net/spdy/spdy_session_unittest.cc +++ b/net/spdy/spdy_session_unittest.cc @@ -538,7 +538,7 @@ TEST_F(SpdySessionTest, OnSettings) { spdy::SpdySettings old_settings; id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); old_settings.push_back(spdy::SpdySetting(id, 1)); - spdy_session_pool->mutable_spdy_settings()->Set( + spdy_session_pool->http_server_properties()->SetSpdySettings( test_host_port_pair, old_settings); // Create a session. @@ -624,7 +624,7 @@ TEST_F(SpdySessionTest, CancelPendingCreateStream) { id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); settings.push_back(spdy::SpdySetting(id, 1)); - spdy_session_pool->mutable_spdy_settings()->Set( + spdy_session_pool->http_server_properties()->SetSpdySettings( test_host_port_pair, settings); // Create a session. @@ -726,7 +726,7 @@ TEST_F(SpdySessionTest, SendSettingsOnNewSession) { settings.clear(); settings.push_back(spdy::SpdySetting(id, kBogusSettingValue)); SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); - spdy_session_pool->mutable_spdy_settings()->Set( + spdy_session_pool->http_server_properties()->SetSpdySettings( test_host_port_pair, settings); EXPECT_FALSE(spdy_session_pool->HasSession(pair)); scoped_refptr<SpdySession> session = @@ -905,8 +905,8 @@ TEST_F(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) { SpdySessionDependencies::SpdyCreateSession(&session_deps)); SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool()); - SpdySettingsStorage* test_settings_storage = - spdy_session_pool->mutable_spdy_settings(); + HttpServerProperties* test_http_server_properties = + spdy_session_pool->http_server_properties(); spdy::SettingsFlagsAndId id(0); id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS); id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST); @@ -914,10 +914,13 @@ TEST_F(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) { spdy::SpdySettings test_settings; test_settings.push_back(spdy::SpdySetting(id, max_concurrent_streams)); - test_settings_storage->Set(test_host_port_pair, test_settings); - EXPECT_NE(0u, test_settings_storage->Get(test_host_port_pair).size()); + test_http_server_properties->SetSpdySettings(test_host_port_pair, + test_settings); + EXPECT_NE(0u, test_http_server_properties->GetSpdySettings( + test_host_port_pair).size()); spdy_session_pool->OnIPAddressChanged(); - EXPECT_EQ(0u, test_settings_storage->Get(test_host_port_pair).size()); + EXPECT_EQ(0u, test_http_server_properties->GetSpdySettings( + test_host_port_pair).size()); } } // namespace net diff --git a/net/spdy/spdy_websocket_stream_unittest.cc b/net/spdy/spdy_websocket_stream_unittest.cc index 0644c96..0f050a6 100644 --- a/net/spdy/spdy_websocket_stream_unittest.cc +++ b/net/spdy/spdy_websocket_stream_unittest.cc @@ -255,7 +255,7 @@ class SpdyWebSocketStreamTest : public testing::Test { if (throttling) { // Set max concurrent streams to 1. - spdy_session_pool->mutable_spdy_settings()->Set( + spdy_session_pool->http_server_properties()->SetSpdySettings( host_port_pair_, spdy_settings_to_set_); } |