| 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 5471fd11d465e161139f1bd188eb732823a543fb..cafd10ca986248faa93b03e803b49fecb57201c7 100644
|
| --- a/net/http/http_server_properties_manager_unittest.cc
|
| +++ b/net/http/http_server_properties_manager_unittest.cc
|
| @@ -206,7 +206,7 @@ class HttpServerPropertiesManagerTest : public testing::TestWithParam<int> {
|
| UpdatePrefsFromCacheOnNetworkThreadConcrete));
|
| }
|
|
|
| - bool HasAlternativeService(const HostPortPair& server) {
|
| + bool HasAlternativeService(const SchemeOriginPair& server) {
|
| const AlternativeServiceVector alternative_service_vector =
|
| http_server_props_manager_->GetAlternativeServices(server);
|
| return !alternative_service_vector.empty();
|
| @@ -233,7 +233,9 @@ TEST_P(HttpServerPropertiesManagerTest,
|
|
|
| base::DictionaryValue* server_pref_dict = new base::DictionaryValue;
|
| HostPortPair google_server("www.google.com", 80);
|
| + SchemeOriginPair google_scheme_origin_pair("https", google_server);
|
| HostPortPair mail_server("mail.google.com", 80);
|
| + SchemeOriginPair mail_scheme_origin_pair("https", mail_server);
|
|
|
| // Set supports_spdy for www.google.com:80.
|
| server_pref_dict->SetBoolean("supports_spdy", true);
|
| @@ -347,11 +349,13 @@ TEST_P(HttpServerPropertiesManagerTest,
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
|
|
| // Verify SupportsSpdy.
|
| - EXPECT_TRUE(
|
| - http_server_props_manager_->SupportsRequestPriority(google_server));
|
| - EXPECT_TRUE(http_server_props_manager_->SupportsRequestPriority(mail_server));
|
| - EXPECT_FALSE(http_server_props_manager_->SupportsRequestPriority(
|
| - HostPortPair::FromString("foo.google.com:1337")));
|
| + 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(SchemeOriginPair(
|
| + "http", HostPortPair::FromString("foo.google.com:1337"))));
|
|
|
| // Verify alternative service.
|
| if (GetParam() == 4) {
|
| @@ -488,13 +492,15 @@ TEST_P(HttpServerPropertiesManagerTest, BadCachedHostPortPair) {
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
|
|
| // Verify that nothing is set.
|
| - EXPECT_FALSE(http_server_props_manager_->SupportsRequestPriority(
|
| - HostPortPair::FromString("www.google.com:65536")));
|
| + HostPortPair host_port_pair =
|
| + HostPortPair::FromString("www.google.com:65536");
|
| + SchemeOriginPair scheme_origin("https", host_port_pair);
|
| EXPECT_FALSE(
|
| - HasAlternativeService(HostPortPair::FromString("www.google.com:65536")));
|
| + http_server_props_manager_->SupportsRequestPriority(scheme_origin));
|
| +
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| const ServerNetworkStats* stats1 =
|
| - http_server_props_manager_->GetServerNetworkStats(
|
| - HostPortPair::FromString("www.google.com:65536"));
|
| + http_server_props_manager_->GetServerNetworkStats(host_port_pair);
|
| EXPECT_EQ(nullptr, stats1);
|
| EXPECT_EQ(0u, http_server_props_manager_->quic_server_info_map().size());
|
| }
|
| @@ -544,8 +550,9 @@ TEST_P(HttpServerPropertiesManagerTest, BadCachedAltProtocolPort) {
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
|
|
| // Verify alternative service is not set.
|
| - EXPECT_FALSE(
|
| - HasAlternativeService(HostPortPair::FromString("www.google.com:80")));
|
| + SchemeOriginPair scheme_origin("http",
|
| + HostPortPair::FromString("www.google.com:80"));
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| }
|
|
|
| TEST_P(HttpServerPropertiesManagerTest, SupportsSpdy) {
|
| @@ -557,8 +564,9 @@ TEST_P(HttpServerPropertiesManagerTest, SupportsSpdy) {
|
|
|
| // Add mail.google.com:443 as a supporting spdy server.
|
| HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + SchemeOriginPair scheme_origin("https", spdy_server_mail);
|
| EXPECT_FALSE(
|
| - http_server_props_manager_->SupportsRequestPriority(spdy_server_mail));
|
| + http_server_props_manager_->SupportsRequestPriority(scheme_origin));
|
| http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true);
|
| // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once.
|
| http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true);
|
| @@ -567,7 +575,7 @@ TEST_P(HttpServerPropertiesManagerTest, SupportsSpdy) {
|
| base::RunLoop().RunUntilIdle();
|
|
|
| EXPECT_TRUE(
|
| - http_server_props_manager_->SupportsRequestPriority(spdy_server_mail));
|
| + http_server_props_manager_->SupportsRequestPriority(scheme_origin));
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
| }
|
|
|
| @@ -679,22 +687,22 @@ TEST_P(HttpServerPropertiesManagerTest, GetAlternativeServices) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| - HostPortPair spdy_server_mail("mail.google.com", 80);
|
| - EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| + SchemeOriginPair scheme_origin("http", "mail.google.com", 80);
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| const AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com",
|
| 443);
|
| http_server_props_manager_->SetAlternativeService(
|
| - spdy_server_mail, alternative_service, 1.0, one_day_from_now_);
|
| + scheme_origin, alternative_service, 1.0, one_day_from_now_);
|
| // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once.
|
| http_server_props_manager_->SetAlternativeService(
|
| - spdy_server_mail, alternative_service, 1.0, one_day_from_now_);
|
| + scheme_origin, alternative_service, 1.0, one_day_from_now_);
|
|
|
| // Run the task.
|
| base::RunLoop().RunUntilIdle();
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
|
|
| AlternativeServiceVector alternative_service_vector =
|
| - http_server_props_manager_->GetAlternativeServices(spdy_server_mail);
|
| + http_server_props_manager_->GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(alternative_service, alternative_service_vector[0]);
|
| }
|
| @@ -703,8 +711,8 @@ TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServices) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| - HostPortPair spdy_server_mail("mail.google.com", 80);
|
| - EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| + SchemeOriginPair scheme_origin("http", "mail.google.com", 80);
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| AlternativeServiceInfoVector alternative_service_info_vector;
|
| const AlternativeService alternative_service1(NPN_HTTP_2, "mail.google.com",
|
| 443);
|
| @@ -714,69 +722,69 @@ TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServices) {
|
| alternative_service_info_vector.push_back(
|
| AlternativeServiceInfo(alternative_service2, 1.0, one_day_from_now_));
|
| http_server_props_manager_->SetAlternativeServices(
|
| - spdy_server_mail, alternative_service_info_vector);
|
| + scheme_origin, alternative_service_info_vector);
|
| // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once.
|
| http_server_props_manager_->SetAlternativeServices(
|
| - spdy_server_mail, alternative_service_info_vector);
|
| + scheme_origin, alternative_service_info_vector);
|
|
|
| // Run the task.
|
| base::RunLoop().RunUntilIdle();
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
|
|
| AlternativeServiceVector alternative_service_vector =
|
| - http_server_props_manager_->GetAlternativeServices(spdy_server_mail);
|
| + http_server_props_manager_->GetAlternativeServices(scheme_origin);
|
| ASSERT_EQ(2u, alternative_service_vector.size());
|
| EXPECT_EQ(alternative_service1, alternative_service_vector[0]);
|
| EXPECT_EQ(alternative_service2, alternative_service_vector[1]);
|
| }
|
|
|
| TEST_P(HttpServerPropertiesManagerTest, SetAlternativeServicesEmpty) {
|
| - HostPortPair spdy_server_mail("mail.google.com", 80);
|
| - EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| + SchemeOriginPair scheme_origin("http", "mail.google.com", 80);
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| const AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com",
|
| 443);
|
| http_server_props_manager_->SetAlternativeServices(
|
| - spdy_server_mail, AlternativeServiceInfoVector());
|
| + scheme_origin, AlternativeServiceInfoVector());
|
| // ExpectScheduleUpdatePrefsOnNetworkThread() should not be called.
|
|
|
| // Run the task.
|
| base::RunLoop().RunUntilIdle();
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
|
|
| - EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| }
|
|
|
| TEST_P(HttpServerPropertiesManagerTest, ClearAlternativeServices) {
|
| ExpectPrefsUpdate();
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
|
|
| - HostPortPair spdy_server_mail("mail.google.com", 80);
|
| - EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| + SchemeOriginPair scheme_origin("http", "mail.google.com", 80);
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com", 443);
|
| http_server_props_manager_->SetAlternativeService(
|
| - spdy_server_mail, alternative_service, 1.0, one_day_from_now_);
|
| + scheme_origin, alternative_service, 1.0, one_day_from_now_);
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
| - http_server_props_manager_->ClearAlternativeServices(spdy_server_mail);
|
| + http_server_props_manager_->ClearAlternativeServices(scheme_origin);
|
| // ExpectScheduleUpdatePrefsOnNetworkThread() should be called only once.
|
| - http_server_props_manager_->ClearAlternativeServices(spdy_server_mail);
|
| + http_server_props_manager_->ClearAlternativeServices(scheme_origin);
|
|
|
| // Run the task.
|
| base::RunLoop().RunUntilIdle();
|
| Mock::VerifyAndClearExpectations(http_server_props_manager_.get());
|
|
|
| - EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| }
|
|
|
| TEST_P(HttpServerPropertiesManagerTest, ConfirmAlternativeService) {
|
| ExpectPrefsUpdate();
|
|
|
| - HostPortPair spdy_server_mail("mail.google.com", 80);
|
| - EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| + SchemeOriginPair scheme_origin("http", "mail.google.com", 80);
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com", 443);
|
|
|
| ExpectScheduleUpdatePrefsOnNetworkThread();
|
| http_server_props_manager_->SetAlternativeService(
|
| - spdy_server_mail, alternative_service, 1.0, one_day_from_now_);
|
| + scheme_origin, alternative_service, 1.0, one_day_from_now_);
|
|
|
| EXPECT_FALSE(http_server_props_manager_->IsAlternativeServiceBroken(
|
| alternative_service));
|
| @@ -883,10 +891,11 @@ TEST_P(HttpServerPropertiesManagerTest, Clear) {
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| HostPortPair spdy_server_mail("mail.google.com", 443);
|
| + SchemeOriginPair scheme_origin("http", spdy_server_mail);
|
| http_server_props_manager_->SetSupportsSpdy(spdy_server_mail, true);
|
| AlternativeService alternative_service(NPN_HTTP_2, "mail.google.com", 1234);
|
| http_server_props_manager_->SetAlternativeService(
|
| - spdy_server_mail, alternative_service, 1.0, one_day_from_now_);
|
| + scheme_origin, alternative_service, 1.0, one_day_from_now_);
|
| IPAddress actual_address(127, 0, 0, 1);
|
| http_server_props_manager_->SetSupportsQuic(true, actual_address);
|
| ServerNetworkStats stats;
|
| @@ -908,8 +917,8 @@ TEST_P(HttpServerPropertiesManagerTest, Clear) {
|
| base::RunLoop().RunUntilIdle();
|
|
|
| EXPECT_TRUE(
|
| - http_server_props_manager_->SupportsRequestPriority(spdy_server_mail));
|
| - EXPECT_TRUE(HasAlternativeService(spdy_server_mail));
|
| + http_server_props_manager_->SupportsRequestPriority(scheme_origin));
|
| + EXPECT_TRUE(HasAlternativeService(scheme_origin));
|
| IPAddress address;
|
| EXPECT_TRUE(http_server_props_manager_->GetSupportsQuic(&address));
|
| EXPECT_EQ(actual_address, address);
|
| @@ -938,8 +947,8 @@ TEST_P(HttpServerPropertiesManagerTest, Clear) {
|
| base::RunLoop().Run();
|
|
|
| EXPECT_FALSE(
|
| - http_server_props_manager_->SupportsRequestPriority(spdy_server_mail));
|
| - EXPECT_FALSE(HasAlternativeService(spdy_server_mail));
|
| + http_server_props_manager_->SupportsRequestPriority(scheme_origin));
|
| + EXPECT_FALSE(HasAlternativeService(scheme_origin));
|
| EXPECT_FALSE(http_server_props_manager_->GetSupportsQuic(&address));
|
| const ServerNetworkStats* stats2 =
|
| http_server_props_manager_->GetServerNetworkStats(spdy_server_mail);
|
| @@ -1024,7 +1033,7 @@ TEST_P(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| std::string server = StringPrintf("www.google.com:%d", i);
|
| AlternativeServiceVector alternative_service_vector =
|
| http_server_props_manager_->GetAlternativeServices(
|
| - HostPortPair::FromString(server));
|
| + SchemeOriginPair("https", HostPortPair::FromString(server)));
|
| ASSERT_EQ(1u, alternative_service_vector.size());
|
| EXPECT_EQ(QUIC, alternative_service_vector[0].protocol);
|
| EXPECT_EQ(i, alternative_service_vector[0].port);
|
| @@ -1039,8 +1048,9 @@ TEST_P(HttpServerPropertiesManagerTest, BadSupportsQuic) {
|
| TEST_P(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
|
| ExpectScheduleUpdatePrefsOnNetworkThreadRepeatedly();
|
|
|
| - const HostPortPair server_www("www.google.com", 80);
|
| + SchemeOriginPair server_www("http", "www.google.com", 80);
|
| const HostPortPair server_mail("mail.google.com", 80);
|
| + SchemeOriginPair mail_server("http", server_mail);
|
|
|
| // Set alternate protocol.
|
| AlternativeServiceInfoVector alternative_service_info_vector;
|
| @@ -1062,7 +1072,7 @@ TEST_P(HttpServerPropertiesManagerTest, UpdateCacheWithPrefs) {
|
| 444);
|
| base::Time expiration3 = base::Time::Max();
|
| http_server_props_manager_->SetAlternativeService(
|
| - server_mail, mail_alternative_service, 0.2, expiration3);
|
| + mail_server, mail_alternative_service, 0.2, expiration3);
|
|
|
| // Set ServerNetworkStats.
|
| ServerNetworkStats stats;
|
| @@ -1122,13 +1132,13 @@ TEST_P(HttpServerPropertiesManagerTest, AddToAlternativeServiceMap) {
|
| base::DictionaryValue* server_dict;
|
| ASSERT_TRUE(server_value->GetAsDictionary(&server_dict));
|
|
|
| - const HostPortPair host_port_pair("example.com", 443);
|
| + SchemeOriginPair scheme_origin("https", "example.com", 443);
|
| AlternativeServiceMap alternative_service_map(/*max_size=*/5);
|
| EXPECT_TRUE(http_server_props_manager_->AddToAlternativeServiceMap(
|
| - host_port_pair, *server_dict, &alternative_service_map));
|
| + scheme_origin, *server_dict, &alternative_service_map));
|
|
|
| AlternativeServiceMap::iterator it =
|
| - alternative_service_map.Get(host_port_pair);
|
| + alternative_service_map.Get(scheme_origin);
|
| ASSERT_NE(alternative_service_map.end(), it);
|
| AlternativeServiceInfoVector alternative_service_info_vector = it->second;
|
| ASSERT_EQ(3u, alternative_service_info_vector.size());
|
| @@ -1193,9 +1203,9 @@ TEST_P(HttpServerPropertiesManagerTest,
|
| alternative_service_info_vector.push_back(AlternativeServiceInfo(
|
| valid_alternative_service, 1.0, time_one_day_later));
|
|
|
| - const HostPortPair host_port_pair("www.example.com", 443);
|
| + SchemeOriginPair scheme_origin("https", "www.example.com", 443);
|
| http_server_props_manager_->SetAlternativeServices(
|
| - host_port_pair, alternative_service_info_vector);
|
| + scheme_origin, alternative_service_info_vector);
|
|
|
| // Update cache.
|
| ExpectPrefsUpdate();
|
| @@ -1256,13 +1266,13 @@ TEST_P(HttpServerPropertiesManagerTest, DoNotLoadExpiredAlternativeService) {
|
| server_pref_dict.SetWithoutPathExpansion("alternative_service",
|
| alternative_service_list.release());
|
|
|
| - const HostPortPair host_port_pair("example.com", 443);
|
| + SchemeOriginPair scheme_origin("https", "example.com", 443);
|
| AlternativeServiceMap alternative_service_map(/*max_size=*/5);
|
| ASSERT_TRUE(http_server_props_manager_->AddToAlternativeServiceMap(
|
| - host_port_pair, server_pref_dict, &alternative_service_map));
|
| + scheme_origin, server_pref_dict, &alternative_service_map));
|
|
|
| AlternativeServiceMap::iterator it =
|
| - alternative_service_map.Get(host_port_pair);
|
| + alternative_service_map.Get(scheme_origin);
|
| ASSERT_NE(alternative_service_map.end(), it);
|
| AlternativeServiceInfoVector alternative_service_info_vector = it->second;
|
| ASSERT_EQ(1u, alternative_service_info_vector.size());
|
|
|