Commit 51e6066f authored by rkn@chromium.org's avatar rkn@chromium.org

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
parent 21c3c5bd
...@@ -177,6 +177,7 @@ Value* SpdySessionPool::SpdySessionPoolInfoToValue() const { ...@@ -177,6 +177,7 @@ Value* SpdySessionPool::SpdySessionPoolInfoToValue() const {
void SpdySessionPool::OnIPAddressChanged() { void SpdySessionPool::OnIPAddressChanged() {
CloseCurrentSessions(); CloseCurrentSessions();
spdy_settings_.Clear();
} }
void SpdySessionPool::OnSSLConfigChanged() { void SpdySessionPool::OnSSLConfigChanged() {
......
...@@ -527,6 +527,49 @@ TEST_F(SpdySessionTest, IPPoolingCloseCurrentSessions) { ...@@ -527,6 +527,49 @@ TEST_F(SpdySessionTest, IPPoolingCloseCurrentSessions) {
IPPoolingTest(true); 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
} // namespace net } // namespace net
// 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 // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
...@@ -46,5 +46,9 @@ void SpdySettingsStorage::Set(const HostPortPair& host_port_pair, ...@@ -46,5 +46,9 @@ void SpdySettingsStorage::Set(const HostPortPair& host_port_pair,
settings_map_[host_port_pair] = persistent_settings; settings_map_[host_port_pair] = persistent_settings;
} }
void SpdySettingsStorage::Clear() {
settings_map_.clear();
}
} // namespace net } // namespace net
...@@ -21,14 +21,19 @@ class NET_TEST SpdySettingsStorage { ...@@ -21,14 +21,19 @@ class NET_TEST SpdySettingsStorage {
SpdySettingsStorage(); 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. // 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; 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, void Set(const HostPortPair& host_port_pair,
const spdy::SpdySettings& settings); const spdy::SpdySettings& settings);
// Clears out the settings_map_ object.
void Clear();
private: private:
typedef std::map<HostPortPair, spdy::SpdySettings> SettingsMap; typedef std::map<HostPortPair, spdy::SpdySettings> SettingsMap;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment