| Index: net/http/http_server_properties_manager_unittest.cc
|
| diff --git a/net/http/http_server_properties_manager_unittest.cc b/net/http/http_server_properties_manager_unittest.cc
|
| index 1caa2f5c864d1fb42ec34eb1d49b4ea7f5c99e9f..18659ef5fe4784b04cb518cd24b8a148ae02bd76 100644
|
| --- a/net/http/http_server_properties_manager_unittest.cc
|
| +++ b/net/http/http_server_properties_manager_unittest.cc
|
| @@ -224,211 +224,6 @@ INSTANTIATE_TEST_CASE_P(Tests,
|
| HttpServerPropertiesManagerTest,
|
| ::testing::ValuesIn(kHttpServerPropertiesVersions));
|
|
|
| -TEST_P(HttpServerPropertiesManagerTest,
|
| - SingleUpdateForTwoSpdyServerPrefChanges) {
|
| - ExpectCacheUpdate();
|
| -
|
| - // Set up the prefs for www.google.com:80 and mail.google.com:80 and then set
|
| - // it twice. Only expect a single cache update.
|
| -
|
| - base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
|
| - HostPortPair google_server("www.google.com", 80);
|
| - url::SchemeHostPort google_scheme_origin_pair("https", "www.google.com", 80);
|
| - HostPortPair mail_server("mail.google.com", 80);
|
| - url::SchemeHostPort mail_scheme_origin_pair("https", "mail.google.com", 80);
|
| -
|
| - // Set supports_spdy for www.google.com:80.
|
| - server_pref_dict->SetBoolean("supports_spdy", true);
|
| -
|
| - // Set up alternative_services for www.google.com:80.
|
| - base::DictionaryValue* alternative_service_dict0 = new base::DictionaryValue;
|
| - alternative_service_dict0->SetInteger("port", 443);
|
| - alternative_service_dict0->SetString("protocol_str", "npn-h2");
|
| - base::DictionaryValue* alternative_service_dict1 = new base::DictionaryValue;
|
| - alternative_service_dict1->SetInteger("port", 1234);
|
| - alternative_service_dict1->SetString("protocol_str", "quic");
|
| - base::ListValue* alternative_service_list0 = new base::ListValue;
|
| - alternative_service_list0->Append(alternative_service_dict0);
|
| - alternative_service_list0->Append(alternative_service_dict1);
|
| - server_pref_dict->SetWithoutPathExpansion("alternative_service",
|
| - alternative_service_list0);
|
| -
|
| - // Set up ServerNetworkStats for www.google.com:80.
|
| - base::DictionaryValue* stats = new base::DictionaryValue;
|
| - stats->SetInteger("srtt", 10);
|
| - server_pref_dict->SetWithoutPathExpansion("network_stats", stats);
|
| -
|
| - // Set the server preference for www.google.com:80.
|
| - base::DictionaryValue* servers_dict = new base::DictionaryValue;
|
| - servers_dict->SetWithoutPathExpansion("www.google.com:80", server_pref_dict);
|
| - base::ListValue* servers_list = nullptr;
|
| - if (GetParam() == 4) {
|
| - servers_list = new base::ListValue;
|
| - // |servers_list| takes ownership of |servers_dict|.
|
| - servers_list->AppendIfNotPresent(servers_dict);
|
| - servers_dict = new base::DictionaryValue;
|
| - }
|
| -
|
| - // Set the preference for mail.google.com server.
|
| - base::DictionaryValue* server_pref_dict1 = new base::DictionaryValue;
|
| -
|
| - // Set supports_spdy for mail.google.com:80
|
| - server_pref_dict1->SetBoolean("supports_spdy", true);
|
| -
|
| - // Set up alternative_services for mail.google.com:80.
|
| - base::DictionaryValue* alternative_service_dict2 = new base::DictionaryValue;
|
| - alternative_service_dict2->SetString("protocol_str", "npn-spdy/3.1");
|
| - alternative_service_dict2->SetInteger("port", 444);
|
| - base::ListValue* alternative_service_list1 = new base::ListValue;
|
| - alternative_service_list1->Append(alternative_service_dict2);
|
| - server_pref_dict1->SetWithoutPathExpansion("alternative_service",
|
| - alternative_service_list1);
|
| -
|
| - // Set up ServerNetworkStats for mail.google.com:80 and it is the MRU server.
|
| - base::DictionaryValue* stats1 = new base::DictionaryValue;
|
| - stats1->SetInteger("srtt", 20);
|
| - server_pref_dict1->SetWithoutPathExpansion("network_stats", stats1);
|
| - // Set the server preference for mail.google.com:80.
|
| - servers_dict->SetWithoutPathExpansion("mail.google.com:80",
|
| - server_pref_dict1);
|
| - base::DictionaryValue http_server_properties_dict;
|
| - if (GetParam() == 4) {
|
| - // |servers_list| takes ownership of |servers_dict|.
|
| - servers_list->AppendIfNotPresent(servers_dict);
|
| - HttpServerPropertiesManager::SetVersion(&http_server_properties_dict, -1);
|
| - http_server_properties_dict.SetWithoutPathExpansion("servers",
|
| - servers_list);
|
| - } else {
|
| - HttpServerPropertiesManager::SetVersion(&http_server_properties_dict,
|
| - GetParam());
|
| - http_server_properties_dict.SetWithoutPathExpansion("servers",
|
| - servers_dict);
|
| - }
|
| - base::DictionaryValue* supports_quic = new base::DictionaryValue;
|
| - supports_quic->SetBoolean("used_quic", true);
|
| - supports_quic->SetString("address", "127.0.0.1");
|
| - http_server_properties_dict.SetWithoutPathExpansion("supports_quic",
|
| - supports_quic);
|
| -
|
| - // Set quic_server_info for www.google.com:80, mail.google.com:80 and
|
| - // play.google.com:80 and verify the MRU.
|
| - http_server_props_manager_->SetMaxServerConfigsStoredInProperties(3);
|
| - base::DictionaryValue* quic_servers_dict = new base::DictionaryValue;
|
| - base::DictionaryValue* quic_server_pref_dict1 = new base::DictionaryValue;
|
| - std::string quic_server_info1("quic_server_info1");
|
| - quic_server_pref_dict1->SetStringWithoutPathExpansion("server_info",
|
| - quic_server_info1);
|
| - base::DictionaryValue* quic_server_pref_dict2 = new base::DictionaryValue;
|
| - std::string quic_server_info2("quic_server_info2");
|
| - quic_server_pref_dict2->SetStringWithoutPathExpansion("server_info",
|
| - quic_server_info2);
|
| - base::DictionaryValue* quic_server_pref_dict3 = new base::DictionaryValue;
|
| - std::string quic_server_info3("quic_server_info3");
|
| - quic_server_pref_dict3->SetStringWithoutPathExpansion("server_info",
|
| - quic_server_info3);
|
| - // Set the quic_server_info1 for www.google.com server.
|
| - QuicServerId google_quic_server_id("www.google.com", 80);
|
| - quic_servers_dict->SetWithoutPathExpansion(google_quic_server_id.ToString(),
|
| - quic_server_pref_dict1);
|
| - // Set the quic_server_info2 for mail.google.com server.
|
| - QuicServerId mail_quic_server_id("mail.google.com", 80);
|
| - quic_servers_dict->SetWithoutPathExpansion(mail_quic_server_id.ToString(),
|
| - quic_server_pref_dict2);
|
| - // Set the quic_server_info3 for play.google.com server.
|
| - QuicServerId play_quic_server_id("play.google.com", 80);
|
| - quic_servers_dict->SetWithoutPathExpansion(play_quic_server_id.ToString(),
|
| - quic_server_pref_dict3);
|
| - http_server_properties_dict.SetWithoutPathExpansion("quic_servers",
|
| - quic_servers_dict);
|
| -
|
| - // Set the same value for kHttpServerProperties multiple times.
|
| - pref_delegate_->SetPrefs(http_server_properties_dict);
|
| - pref_delegate_->SetPrefs(http_server_properties_dict);
|
| -
|
| - base::RunLoop().RunUntilIdle();
|
| - Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
| -
|
| - // Verify SupportsSpdy.
|
| - EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(
|
| - google_scheme_origin_pair));
|
| - EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(
|
| - mail_scheme_origin_pair));
|
| - EXPECT_FALSE(http_server_props_manager_->SupportsRequestPriority(
|
| - url::SchemeHostPort("http", "foo.google.com", 1337)));
|
| -
|
| - // Verify alternative service.
|
| - if (GetParam() == 4) {
|
| - const AlternativeServiceMap& map =
|
| - http_server_props_manager_->alternative_service_map();
|
| - ASSERT_EQ(2u, map.size());
|
| -
|
| - AlternativeServiceMap::const_iterator map_it = map.begin();
|
| - EXPECT_EQ("mail.google.com", map_it->first.host());
|
| - ASSERT_EQ(1u, map_it->second.size());
|
| - EXPECT_EQ(NPN_SPDY_3_1, map_it->second[0].alternative_service.protocol);
|
| - EXPECT_TRUE(map_it->second[0].alternative_service.host.empty());
|
| - EXPECT_EQ(444, map_it->second[0].alternative_service.port);
|
| - ++map_it;
|
| - EXPECT_EQ("www.google.com", map_it->first.host());
|
| - ASSERT_EQ(2u, map_it->second.size());
|
| - EXPECT_EQ(NPN_HTTP_2, map_it->second[0].alternative_service.protocol);
|
| - EXPECT_TRUE(map_it->second[0].alternative_service.host.empty());
|
| - EXPECT_EQ(443, map_it->second[0].alternative_service.port);
|
| - EXPECT_EQ(QUIC, map_it->second[1].alternative_service.protocol);
|
| - EXPECT_TRUE(map_it->second[1].alternative_service.host.empty());
|
| - EXPECT_EQ(1234, map_it->second[1].alternative_service.port);
|
| - } else {
|
| - const AlternativeServiceMap& map =
|
| - http_server_props_manager_->alternative_service_map();
|
| - ASSERT_EQ(2u, map.size());
|
| - AlternativeServiceMap::const_iterator map_it = map.begin();
|
| - EXPECT_EQ("www.google.com", map_it->first.host());
|
| - ASSERT_EQ(2u, map_it->second.size());
|
| - EXPECT_EQ(NPN_HTTP_2, map_it->second[0].alternative_service.protocol);
|
| - EXPECT_TRUE(map_it->second[0].alternative_service.host.empty());
|
| - EXPECT_EQ(443, map_it->second[0].alternative_service.port);
|
| - EXPECT_EQ(QUIC, map_it->second[1].alternative_service.protocol);
|
| - EXPECT_TRUE(map_it->second[1].alternative_service.host.empty());
|
| - EXPECT_EQ(1234, map_it->second[1].alternative_service.port);
|
| - ++map_it;
|
| - EXPECT_EQ("mail.google.com", map_it->first.host());
|
| - ASSERT_EQ(1u, map_it->second.size());
|
| - EXPECT_EQ(NPN_SPDY_3_1, map_it->second[0].alternative_service.protocol);
|
| - EXPECT_TRUE(map_it->second[0].alternative_service.host.empty());
|
| - EXPECT_EQ(444, map_it->second[0].alternative_service.port);
|
| - }
|
| -
|
| - // Verify SupportsQuic.
|
| - IPAddress last_address;
|
| - EXPECT_TRUE(http_server_props_manager_->GetSupportsQuic(&last_address));
|
| - EXPECT_EQ("127.0.0.1", last_address.ToString());
|
| -
|
| - // Verify ServerNetworkStats.
|
| - const ServerNetworkStats* stats2 =
|
| - http_server_props_manager_->GetServerNetworkStats(google_server);
|
| - EXPECT_EQ(10, stats2->srtt.ToInternalValue());
|
| - const ServerNetworkStats* stats3 =
|
| - http_server_props_manager_->GetServerNetworkStats(mail_server);
|
| - EXPECT_EQ(20, stats3->srtt.ToInternalValue());
|
| -
|
| - // Verify QuicServerInfo.
|
| - EXPECT_EQ(quic_server_info1, *http_server_props_manager_->GetQuicServerInfo(
|
| - google_quic_server_id));
|
| - EXPECT_EQ(quic_server_info2, *http_server_props_manager_->GetQuicServerInfo(
|
| - mail_quic_server_id));
|
| - EXPECT_EQ(quic_server_info3, *http_server_props_manager_->GetQuicServerInfo(
|
| - play_quic_server_id));
|
| -
|
| - // Verify the MRU order.
|
| - http_server_props_manager_->SetMaxServerConfigsStoredInProperties(2);
|
| - EXPECT_EQ(nullptr, http_server_props_manager_->GetQuicServerInfo(
|
| - google_quic_server_id));
|
| - EXPECT_EQ(quic_server_info2, *http_server_props_manager_->GetQuicServerInfo(
|
| - mail_quic_server_id));
|
| - EXPECT_EQ(quic_server_info3, *http_server_props_manager_->GetQuicServerInfo(
|
| - play_quic_server_id));
|
| -}
|
| -
|
| TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
|
| ExpectCacheUpdate();
|
| // The prefs are automaticalls updated in the case corruption is detected.
|
| @@ -500,7 +295,7 @@ TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
|
|
|
| EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| const ServerNetworkStats* stats1 =
|
| - http_server_props_manager_->GetServerNetworkStats(host_port_pair);
|
| + http_server_props_manager_->GetServerNetworkStats(scheme_origin);
|
| EXPECT_EQ(nullptr, stats1);
|
| EXPECT_EQ(0u, http_server_props_manager_->quic_server_info_map().size());
|
| }
|
| @@ -562,13 +357,13 @@ TEST_P(HttpServerPropertiesManagerTest, SupportsSpdy) {
|
| // ScheduleUpdatePrefsOnNetworkThread.
|
|
|
| // Add mail.google.com:443 as a supporting spdy server.
|
| - HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + // HostPortPair spdy_server_mail("mail.google.com", 443);
|
| url::SchemeHostPort scheme_origin("https", "mail.google.com", 443);
|
| EXPECT_FALSE(
|
| http_server_props_manager_->SupportsRequestPriority(scheme_origin));
|
| - http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true);
|
| + http_server_props_manager_->SetSupportsSpdy(scheme_origin, true);
|
| // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once.
|
| - http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true);
|
| + http_server_props_manager_->SetSupportsSpdy(scheme_origin, true);
|
|
|
| // Run the task.
|
| base::RunLoop().RunUntilIdle();
|
| @@ -583,7 +378,7 @@ TEST_P(HttpServerPropertiesManagerTest, SetSpdySetting) {
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| // Add SpdySetting for mail.google.com:443.
|
| - HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
|
| const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH;
|
| const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST;
|
| const uint32_t value1 = 31337;
|
| @@ -610,7 +405,7 @@ TEST_P(HttpServerPropertiesManagerTest, ClearSpdySetting) {
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| // Add SpdySetting for mail.google.com:443.
|
| - HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
|
| const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH;
|
| const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST;
|
| const uint32_t value1 = 31337;
|
| @@ -649,7 +444,7 @@ TEST_P(HttpServerPropertiesManagerTest, ClearAllSpdySetting) {
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| // Add SpdySetting for mail.google.com:443.
|
| - HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
|
| const SpdySettingsIds id1 = SETTINGS_UPLOAD_BANDWIDTH;
|
| const SpdySettingsFlags flags1 = SETTINGS_FLAG_PLEASE_PERSIST;
|
| const uint32_t value1 = 31337;
|
| @@ -844,7 +639,7 @@ TEST_P(HttpServerPropertiesManagerTest, ServerNetworkStats) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| - HostPortPair mail_server("mail.google.com", 80);
|
| + url::SchemeHostPort mail_server("http", "mail.google.com", 80);
|
| const ServerNetworkStats* stats =
|
| http_server_props_manager_->GetServerNetworkStats(mail_server);
|
| EXPECT_EQ(nullptr, stats);
|
| @@ -889,12 +684,11 @@ TEST_P(HttpServerPropertiesManagerTest, Clear) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| - HostPortPair spdy_server_mail("mail.google.com", 443);
|
| - url::SchemeHostPort scheme_origin("http", "mail.google.com", 443);
|
| + url::SchemeHostPort spdy_server_mail("https", "mail.google.com", 443);
|
| http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true);
|
| AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com", 1234);
|
| http_server_props_manager_->SetAlternativeService(
|
| - scheme_origin, alternative_service, one_day_from_now_);
|
| + spdy_server_mail, alternative_service, one_day_from_now_);
|
| IPAddress actual_address(127, 0, 0, 1);
|
| http_server_props_manager_->SetSupportsQuic(true, actual_address);
|
| ServerNetworkStats stats;
|
| @@ -916,8 +710,8 @@ TEST_P(HttpServerPropertiesManagerTest, Clear) {
|
| base::RunLoop().RunUntilIdle();
|
|
|
| EXPECT_TRUE(
|
| - http_server_props_manager_->SupportsRequestPriority(scheme_origin));
|
| - EXPECT_TRUE(HasAlternativeService(scheme_origin));
|
| + http_server_props_manager_->SupportsRequestPriority(spdy_server_mail));
|
| + EXPECT_TRUE(HasAlternativeService(spdy_server_mail));
|
| IPAddress address;
|
| EXPECT_TRUE(http_server_props_manager_->GetSupportsQuic(&address));
|
| EXPECT_EQ(actual_address, address);
|
| @@ -946,8 +740,8 @@ TEST_P(HttpServerPropertiesManagerTest, Clear) {
|
| base::RunLoop().Run();
|
|
|
| EXPECT_FALSE(
|
| - http_server_props_manager_->SupportsRequestPriority(scheme_origin));
|
| - EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| + http_server_props_manager_->SupportsRequestPriority(spdy_server_mail));
|
| + EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address));
|
| const ServerNetworkStats* stats2 =
|
| http_server_props_manager_->GetServerNetworkStats(spdy_server_mail);
|
| @@ -1033,13 +827,9 @@ TEST_P(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| AlternativeServiceVector alternative_service_vector =
|
| http_server_props_manager_->GetAlternativeServices(
|
| url::SchemeHostPort("https", "www.google.com", i));
|
| - if (GetParam() > 4) {
|
| - ASSERT_EQ(1u, alternative_service_vector.size());
|
| - EXPECT_EQ(QUIC, alternative_service_vector[0].protocol);
|
| - EXPECT_EQ(i, alternative_service_vector[0].port);
|
| - } else {
|
| - EXPECT_EQ(0u, alternative_service_vector.size());
|
| - }
|
| + ASSERT_EQ(1u, alternative_service_vector.size());
|
| + EXPECT_EQ(QUIC, alternative_service_vector[0].protocol);
|
| + EXPECT_EQ(i, alternative_service_vector[0].port);
|
| }
|
|
|
| // Verify SupportsQuic.
|
| @@ -1051,9 +841,8 @@ TEST_P(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| TEST_P(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| - url::SchemeHostPort server_www("http", "www.google.com", 80);
|
| - const HostPortPair server_mail("mail.google.com", 80);
|
| - url::SchemeHostPort mail_server("http", "mail.google.com", 80);
|
| + const url::SchemeHostPort server_www("http", "www.google.com", 80);
|
| + const url::SchemeHostPort server_mail("http", "mail.google.com", 80);
|
|
|
| // Set alternate protocol.
|
| AlternativeServiceInfoVector alternative_service_info_vector;
|
| @@ -1075,7 +864,7 @@ TEST_P(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
|
| 444);
|
| base::Time expiration3 = base::Time::Max();
|
| http_server_props_manager_->SetAlternativeService(
|
| - mail_server, mail_alternative_service, expiration3);
|
| + server_mail, mail_alternative_service, expiration3);
|
|
|
| // Set ServerNetworkStats.
|
| ServerNetworkStats stats;
|
|
|