summaryrefslogtreecommitdiffstats
path: root/chrome/browser/net
diff options
context:
space:
mode:
authorrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-30 21:13:09 +0000
committerrtenneti@chromium.org <rtenneti@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-30 21:13:09 +0000
commit6dd1134ebf789b23d79c2ff09126fbf82e9d4d68 (patch)
treeba1c0773c5de4d4a34f543d3e8791ac4ccbb3a07 /chrome/browser/net
parentcdcce8de8d45bfffd66f1e8cdca9ec5da906e6f2 (diff)
downloadchromium_src-6dd1134ebf789b23d79c2ff09126fbf82e9d4d68.zip
chromium_src-6dd1134ebf789b23d79c2ff09126fbf82e9d4d68.tar.gz
chromium_src-6dd1134ebf789b23d79c2ff09126fbf82e9d4d68.tar.bz2
SPDY: Respect SETTINGS_FLAG_CLEAR_PREVIOUSLY_PERSISTED_SETTINGS.
- Added ClearSpdySettings API call to clear the persisted SPDY setting data for a given host. SpdySession's OnSettings API calls this method to clear the persisted data. - ClearAllSpdySettings clears all the persisted data. - Add SpdyFramerVisitorInterface::OnSettings(). No behavioral change (no compiled change) outside tests. Merge internal change: 45922004 R=rch@chromium.org TEST=net unit tests and browser unit tests BUG=235737 Review URL: https://chromiumcodereview.appspot.com/14583002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@197469 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/net')
-rw-r--r--chrome/browser/net/http_server_properties_manager.cc11
-rw-r--r--chrome/browser/net/http_server_properties_manager.h8
-rw-r--r--chrome/browser/net/http_server_properties_manager_unittest.cc83
3 files changed, 98 insertions, 4 deletions
diff --git a/chrome/browser/net/http_server_properties_manager.cc b/chrome/browser/net/http_server_properties_manager.cc
index 0f2de16..1e30ae8 100644
--- a/chrome/browser/net/http_server_properties_manager.cc
+++ b/chrome/browser/net/http_server_properties_manager.cc
@@ -180,9 +180,16 @@ bool HttpServerPropertiesManager::SetSpdySetting(
return persist;
}
-void HttpServerPropertiesManager::ClearSpdySettings() {
+void HttpServerPropertiesManager::ClearSpdySettings(
+ const net::HostPortPair& host_port_pair) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
- http_server_properties_impl_->ClearSpdySettings();
+ http_server_properties_impl_->ClearSpdySettings(host_port_pair);
+ ScheduleUpdatePrefsOnIO();
+}
+
+void HttpServerPropertiesManager::ClearAllSpdySettings() {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
+ http_server_properties_impl_->ClearAllSpdySettings();
ScheduleUpdatePrefsOnIO();
}
diff --git a/chrome/browser/net/http_server_properties_manager.h b/chrome/browser/net/http_server_properties_manager.h
index d7b1b3cbf..cde2a0b 100644
--- a/chrome/browser/net/http_server_properties_manager.h
+++ b/chrome/browser/net/http_server_properties_manager.h
@@ -121,8 +121,12 @@ class HttpServerPropertiesManager
net::SpdySettingsFlags flags,
uint32 value) OVERRIDE;
- // Clears all SPDY settings.
- virtual void ClearSpdySettings() OVERRIDE;
+ // Clears all SPDY settings for a host.
+ virtual void ClearSpdySettings(
+ const net::HostPortPair& host_port_pair) OVERRIDE;
+
+ // Clears all SPDY settings for all hosts.
+ virtual void ClearAllSpdySettings() OVERRIDE;
// Returns all SPDY persistent settings.
virtual const net::SpdySettingsMap& spdy_settings_map() const OVERRIDE;
diff --git a/chrome/browser/net/http_server_properties_manager_unittest.cc b/chrome/browser/net/http_server_properties_manager_unittest.cc
index 3a6c1b4..f3e1061 100644
--- a/chrome/browser/net/http_server_properties_manager_unittest.cc
+++ b/chrome/browser/net/http_server_properties_manager_unittest.cc
@@ -118,6 +118,14 @@ class HttpServerPropertiesManagerTest : public testing::Test {
UpdatePrefsFromCacheOnIOConcrete));
}
+ void ExpectPrefsUpdateRepeatedly() {
+ EXPECT_CALL(*http_server_props_manager_, UpdatePrefsFromCacheOnIO(_))
+ .WillRepeatedly(
+ Invoke(http_server_props_manager_.get(),
+ &TestingHttpServerPropertiesManager::
+ UpdatePrefsFromCacheOnIOConcrete));
+ }
+
MessageLoop loop_;
TestingPrefServiceSimple pref_service_;
scoped_ptr<TestingHttpServerPropertiesManager> http_server_props_manager_;
@@ -266,6 +274,81 @@ TEST_F(HttpServerPropertiesManagerTest, SetSpdySetting) {
Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
}
+TEST_F(HttpServerPropertiesManagerTest, ClearSpdySetting) {
+ ExpectPrefsUpdateRepeatedly();
+
+ // Add SpdySetting for mail.google.com:443.
+ net::HostPortPair spdy_server_mail("mail.google.com", 443);
+ const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH;
+ const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST;
+ const uint32 value1 = 31337;
+ http_server_props_manager_->SetSpdySetting(
+ spdy_server_mail, id1, flags1, value1);
+
+ // Run the task.
+ loop_.RunUntilIdle();
+
+ const net::SettingsMap& settings_map1_ret =
+ http_server_props_manager_->GetSpdySettings(spdy_server_mail);
+ ASSERT_EQ(1U, settings_map1_ret.size());
+ net::SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1);
+ EXPECT_TRUE(it1_ret != settings_map1_ret.end());
+ net::SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second;
+ EXPECT_EQ(net::SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first);
+ EXPECT_EQ(value1, flags_and_value1_ret.second);
+
+ // Clear SpdySetting for mail.google.com:443.
+ http_server_props_manager_->ClearSpdySettings(spdy_server_mail);
+
+ // Run the task.
+ loop_.RunUntilIdle();
+
+ // Verify that there are no entries in the settings map for
+ // mail.google.com:443.
+ const net::SettingsMap& settings_map2_ret =
+ http_server_props_manager_->GetSpdySettings(spdy_server_mail);
+ ASSERT_EQ(0U, settings_map2_ret.size());
+
+ Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
+}
+
+TEST_F(HttpServerPropertiesManagerTest, ClearAllSpdySetting) {
+ ExpectPrefsUpdateRepeatedly();
+
+ // Add SpdySetting for mail.google.com:443.
+ net::HostPortPair spdy_server_mail("mail.google.com", 443);
+ const net::SpdySettingsIds id1 = net::SETTINGS_UPLOAD_BANDWIDTH;
+ const net::SpdySettingsFlags flags1 = net::SETTINGS_FLAG_PLEASE_PERSIST;
+ const uint32 value1 = 31337;
+ http_server_props_manager_->SetSpdySetting(
+ spdy_server_mail, id1, flags1, value1);
+
+ // Run the task.
+ loop_.RunUntilIdle();
+
+ const net::SettingsMap& settings_map1_ret =
+ http_server_props_manager_->GetSpdySettings(spdy_server_mail);
+ ASSERT_EQ(1U, settings_map1_ret.size());
+ net::SettingsMap::const_iterator it1_ret = settings_map1_ret.find(id1);
+ EXPECT_TRUE(it1_ret != settings_map1_ret.end());
+ net::SettingsFlagsAndValue flags_and_value1_ret = it1_ret->second;
+ EXPECT_EQ(net::SETTINGS_FLAG_PERSISTED, flags_and_value1_ret.first);
+ EXPECT_EQ(value1, flags_and_value1_ret.second);
+
+ // Clear All SpdySettings.
+ http_server_props_manager_->ClearAllSpdySettings();
+
+ // Run the task.
+ loop_.RunUntilIdle();
+
+ // Verify that there are no entries in the settings map.
+ const net::SpdySettingsMap& spdy_settings_map2_ret =
+ http_server_props_manager_->spdy_settings_map();
+ ASSERT_EQ(0U, spdy_settings_map2_ret.size());
+
+ Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
+}
+
TEST_F(HttpServerPropertiesManagerTest, HasAlternateProtocol) {
ExpectPrefsUpdate();