diff options
author | rtenneti <rtenneti@chromium.org> | 2015-06-05 16:14:12 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-06-05 23:14:44 +0000 |
commit | 5b3bb8590cd76530932dd2eb47667a19c191cc2d (patch) | |
tree | c03e45c6711ba9597cc634ed54c838794c760916 /net/http/http_server_properties_manager_unittest.cc | |
parent | bd002c0484db244b493d9eeb671d9476024c1b33 (diff) | |
download | chromium_src-5b3bb8590cd76530932dd2eb47667a19c191cc2d.zip chromium_src-5b3bb8590cd76530932dd2eb47667a19c191cc2d.tar.gz chromium_src-5b3bb8590cd76530932dd2eb47667a19c191cc2d.tar.bz2 |
HttpServerProperties - Don't persist if ConfirmAlternativeService is
called with the same origin (HostPortPair) more than once and if we
didn't change anything in broken_alternative_services_ (in other words
the return value of IsAlternativeServiceBroken hasn't changed).
This change reduces the number of times ConfirmAlternativeService tries to
persist HttpServerProperties to disk (currently ~17% of persist calls
are due to ConfirmAlternativeService).
BUG=451256
R=rch@chromium.org
Review URL: https://codereview.chromium.org/1142413004
Cr-Commit-Position: refs/heads/master@{#333169}
Diffstat (limited to 'net/http/http_server_properties_manager_unittest.cc')
-rw-r--r-- | net/http/http_server_properties_manager_unittest.cc | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/net/http/http_server_properties_manager_unittest.cc b/net/http/http_server_properties_manager_unittest.cc index 751888d..8aaa9d1 100644 --- a/net/http/http_server_properties_manager_unittest.cc +++ b/net/http/http_server_properties_manager_unittest.cc @@ -549,6 +549,52 @@ TEST_F(HttpServerPropertiesManagerTest, ClearAlternativeService) { EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); } +TEST_F(HttpServerPropertiesManagerTest, ConfirmAlternativeService) { + ExpectPrefsUpdate(); + + HostPortPair spdy_server_mail("mail.google.com", 80); + EXPECT_FALSE(HasAlternativeService(spdy_server_mail)); + AlternativeService alternative_service(NPN_SPDY_4, "mail.google.com", 443); + + ExpectScheduleUpdatePrefsOnNetworkThread(); + http_server_props_manager_->SetAlternativeService(spdy_server_mail, + alternative_service, 1.0); + + EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( + alternative_service)); + EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( + alternative_service)); + + ExpectScheduleUpdatePrefsOnNetworkThread(); + http_server_props_manager_->MarkAlternativeServiceBroken(alternative_service); + EXPECT_TRUE(http_server_props_manager_->IsAlternativeServiceBroken( + alternative_service)); + EXPECT_TRUE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( + alternative_service)); + + ExpectScheduleUpdatePrefsOnNetworkThread(); + http_server_props_manager_->ConfirmAlternativeService(alternative_service); + EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( + alternative_service)); + EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( + alternative_service)); + // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once. + http_server_props_manager_->ConfirmAlternativeService(alternative_service); + EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( + alternative_service)); + EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( + alternative_service)); + + // Run the task. + base::RunLoop().RunUntilIdle(); + Mock::VerifyAndClearExpectations(http_server_props_manager_.get()); + + EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken( + alternative_service)); + EXPECT_FALSE(http_server_props_manager_->WasAlternativeServiceRecentlyBroken( + alternative_service)); +} + TEST_F(HttpServerPropertiesManagerTest, SupportsQuic) { ExpectPrefsUpdate(); ExpectScheduleUpdatePrefsOnNetworkThread(); |