summaryrefslogtreecommitdiffstats
path: root/net/spdy
diff options
context:
space:
mode:
authorrkn@chromium.org <rkn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-23 23:48:07 +0000
committerrkn@chromium.org <rkn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-05-23 23:48:07 +0000
commit51e6066f1d8af63caa7eb63a6eee458648ed4653 (patch)
tree98f326ba5ac882b93a305933e7f2c490eef3dba8 /net/spdy
parent21c3c5bddcfd0a03dd8df349b8f36601aba8a701 (diff)
downloadchromium_src-51e6066f1d8af63caa7eb63a6eee458648ed4653.zip
chromium_src-51e6066f1d8af63caa7eb63a6eee458648ed4653.tar.gz
chromium_src-51e6066f1d8af63caa7eb63a6eee458648ed4653.tar.bz2
Added a function "void SpdySettingsStorage::Clear()". Added a call to the
function "spdy_settings_.Clear()" to the function "void SpdySessionPool::OnIPAddressChanged()". BUG=55868 TEST="./net_unittests --gtest_filter=SpdySessionTest.ClearSettingsStorage" and "./net_unittests --gtest_filter=SpdySessionTest.ClearOnIPAddressChanged". Review URL: http://codereview.chromium.org/7046016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86362 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/spdy')
-rw-r--r--net/spdy/spdy_session_pool.cc1
-rw-r--r--net/spdy/spdy_session_unittest.cc43
-rw-r--r--net/spdy/spdy_settings_storage.cc6
-rw-r--r--net/spdy/spdy_settings_storage.h9
4 files changed, 56 insertions, 3 deletions
diff --git a/net/spdy/spdy_session_pool.cc b/net/spdy/spdy_session_pool.cc
index 9e49d45..da2d331 100644
--- a/net/spdy/spdy_session_pool.cc
+++ b/net/spdy/spdy_session_pool.cc
@@ -177,6 +177,7 @@ Value* SpdySessionPool::SpdySessionPoolInfoToValue() const {
void SpdySessionPool::OnIPAddressChanged() {
CloseCurrentSessions();
+ spdy_settings_.Clear();
}
void SpdySessionPool::OnSSLConfigChanged() {
diff --git a/net/spdy/spdy_session_unittest.cc b/net/spdy/spdy_session_unittest.cc
index cdcfb35..51fe66e 100644
--- a/net/spdy/spdy_session_unittest.cc
+++ b/net/spdy/spdy_session_unittest.cc
@@ -527,6 +527,49 @@ TEST_F(SpdySessionTest, IPPoolingCloseCurrentSessions) {
IPPoolingTest(true);
}
+TEST_F(SpdySessionTest, ClearSettingsStorage) {
+ SpdySettingsStorage settings_storage;
+ const std::string kTestHost("www.foo.com");
+ const int kTestPort = 80;
+ HostPortPair test_host_port_pair(kTestHost, kTestPort);
+ spdy::SpdySettings test_settings;
+ spdy::SettingsFlagsAndId id(0);
+ id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS);
+ id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST);
+ const size_t max_concurrent_streams = 2;
+ test_settings.push_back(spdy::SpdySetting(id, max_concurrent_streams));
+
+ settings_storage.Set(test_host_port_pair, test_settings);
+ EXPECT_NE(0u, settings_storage.Get(test_host_port_pair).size());
+ settings_storage.Clear();
+ EXPECT_EQ(0u, settings_storage.Get(test_host_port_pair).size());
+}
+
+TEST_F(SpdySessionTest, ClearSettingsStorageOnIPAddressChanged) {
+ const std::string kTestHost("www.foo.com");
+ const int kTestPort = 80;
+ HostPortPair test_host_port_pair(kTestHost, kTestPort);
+
+ SpdySessionDependencies session_deps;
+ scoped_refptr<HttpNetworkSession> http_session(
+ SpdySessionDependencies::SpdyCreateSession(&session_deps));
+ SpdySessionPool* spdy_session_pool(http_session->spdy_session_pool());
+
+ SpdySettingsStorage* test_settings_storage =
+ spdy_session_pool->mutable_spdy_settings();
+ spdy::SettingsFlagsAndId id(0);
+ id.set_id(spdy::SETTINGS_MAX_CONCURRENT_STREAMS);
+ id.set_flags(spdy::SETTINGS_FLAG_PLEASE_PERSIST);
+ const size_t max_concurrent_streams = 2;
+ 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());
+ spdy_session_pool->OnIPAddressChanged();
+ EXPECT_EQ(0u, test_settings_storage->Get(test_host_port_pair).size());
+}
+
} // namespace
} // namespace net
diff --git a/net/spdy/spdy_settings_storage.cc b/net/spdy/spdy_settings_storage.cc
index dc9bdcd..9d79c56 100644
--- a/net/spdy/spdy_settings_storage.cc
+++ b/net/spdy/spdy_settings_storage.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -46,5 +46,9 @@ void SpdySettingsStorage::Set(const HostPortPair& host_port_pair,
settings_map_[host_port_pair] = persistent_settings;
}
+void SpdySettingsStorage::Clear() {
+ settings_map_.clear();
+}
+
} // namespace net
diff --git a/net/spdy/spdy_settings_storage.h b/net/spdy/spdy_settings_storage.h
index 1ea492d..67bf0d1 100644
--- a/net/spdy/spdy_settings_storage.h
+++ b/net/spdy/spdy_settings_storage.h
@@ -21,14 +21,19 @@ class NET_TEST SpdySettingsStorage {
SpdySettingsStorage();
~SpdySettingsStorage();
- // Get a copy of the SpdySettings stored for a host.
+ // Gets a copy of the SpdySettings stored for a host.
// If no settings are stored, returns an empty set of settings.
+ // NOTE: Since settings_map_ may be cleared, don't store the address of the
+ // return value.
const spdy::SpdySettings& Get(const HostPortPair& host_port_pair) const;
- // Save settings for a host.
+ // Saves settings for a host.
void Set(const HostPortPair& host_port_pair,
const spdy::SpdySettings& settings);
+ // Clears out the settings_map_ object.
+ void Clear();
+
private:
typedef std::map<HostPortPair, spdy::SpdySettings> SettingsMap;