Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Unified Diff: net/http/http_server_properties_impl_unittest.cc

Issue 2901093004: Add and persist a new field in AlternativeServiceInfo to list QUIC verisons advertised (Closed)
Patch Set: self review Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/http/http_server_properties_impl_unittest.cc
diff --git a/net/http/http_server_properties_impl_unittest.cc b/net/http/http_server_properties_impl_unittest.cc
index 18edad7b91476d00a0a108cf99903fb297cda57f..27b6eeaae51598fdb38e0045d0b6fe19796b0af5 100644
--- a/net/http/http_server_properties_impl_unittest.cc
+++ b/net/http/http_server_properties_impl_unittest.cc
@@ -12,6 +12,7 @@
#include "base/values.h"
#include "net/base/host_port_pair.h"
#include "net/base/ip_address.h"
+#include "net/http/http_network_session.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "url/gurl.h"
@@ -60,7 +61,9 @@ class HttpServerPropertiesImplTest : public testing::Test {
const AlternativeService& alternative_service) {
const base::Time expiration =
base::Time::Now() + base::TimeDelta::FromDays(1);
- return impl_.SetAlternativeService(origin, alternative_service, expiration);
+ return impl_.SetAlternativeService(
+ origin, alternative_service, expiration,
+ HttpNetworkSession::Params().quic_supported_versions);
}
HttpServerPropertiesImpl impl_;
@@ -364,20 +367,24 @@ TEST_F(AlternateProtocolServerPropertiesTest, ExcludeOrigin) {
AlternativeServiceInfoVector alternative_service_info_vector;
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
// Same hostname, same port, TCP: should be ignored.
- AlternativeServiceInfo alternative_service_info1(kProtoHTTP2, "foo", 443,
- expiration);
+ AlternativeServiceInfo alternative_service_info1(
+ AlternativeService(kProtoHTTP2, "foo", 443), expiration,
+ HttpNetworkSession::Params().quic_supported_versions);
alternative_service_info_vector.push_back(alternative_service_info1);
// Different hostname: GetAlternativeServiceInfos should return this one.
- AlternativeServiceInfo alternative_service_info2(kProtoHTTP2, "bar", 443,
- expiration);
+ AlternativeServiceInfo alternative_service_info2(
+ AlternativeService(kProtoHTTP2, "bar", 443), expiration,
+ HttpNetworkSession::Params().quic_supported_versions);
alternative_service_info_vector.push_back(alternative_service_info2);
// Different port: GetAlternativeServiceInfos should return this one too.
- AlternativeServiceInfo alternative_service_info3(kProtoHTTP2, "foo", 80,
- expiration);
+ AlternativeServiceInfo alternative_service_info3(
+ AlternativeService(kProtoHTTP2, "foo", 80), expiration,
+ HttpNetworkSession::Params().quic_supported_versions);
alternative_service_info_vector.push_back(alternative_service_info3);
// QUIC: GetAlternativeServices should return this one too.
- AlternativeServiceInfo alternative_service_info4(kProtoQUIC, "foo", 443,
- expiration);
+ AlternativeServiceInfo alternative_service_info4(
+ AlternativeService(kProtoQUIC, "foo", 443), expiration,
+ HttpNetworkSession::Params().quic_supported_versions);
alternative_service_info_vector.push_back(alternative_service_info4);
url::SchemeHostPort test_server("https", "foo", 443);
@@ -401,7 +408,9 @@ TEST_F(AlternateProtocolServerPropertiesTest, Set) {
const base::Time now = base::Time::Now();
base::Time expiration1 = now + base::TimeDelta::FromDays(1);
// 1st entry in the memory.
- impl_.SetAlternativeService(test_server1, alternative_service1, expiration1);
+ impl_.SetAlternativeService(
+ test_server1, alternative_service1, expiration1,
+ HttpNetworkSession::Params().quic_supported_versions);
// |test_server2| has an alternative service, which will be
// overwritten by SetAlternativeServiceServers(), because
@@ -410,8 +419,9 @@ TEST_F(AlternateProtocolServerPropertiesTest, Set) {
AlternativeServiceInfoVector alternative_service_info_vector;
const AlternativeService alternative_service2(kProtoHTTP2, "bar2", 443);
base::Time expiration2 = now + base::TimeDelta::FromDays(2);
- alternative_service_info_vector.push_back(
- AlternativeServiceInfo(alternative_service2, expiration2));
+ alternative_service_info_vector.push_back(AlternativeServiceInfo(
+ alternative_service2, expiration2,
+ HttpNetworkSession::Params().quic_supported_versions));
url::SchemeHostPort test_server2("http", "foo2", 80);
// 0th entry in the memory.
impl_.SetAlternativeServices(test_server2, alternative_service_info_vector);
@@ -422,8 +432,9 @@ TEST_F(AlternateProtocolServerPropertiesTest, Set) {
AlternativeServiceMap::NO_AUTO_EVICT);
const AlternativeService alternative_service3(kProtoHTTP2, "bar3", 123);
base::Time expiration3 = now + base::TimeDelta::FromDays(3);
- const AlternativeServiceInfo alternative_service_info1(alternative_service3,
- expiration3);
+ const AlternativeServiceInfo alternative_service_info1(
+ alternative_service3, expiration3,
+ HttpNetworkSession::Params().quic_supported_versions);
// Simulate updating data for 0th entry with data from Preferences.
alternative_service_map.Put(
test_server2,
@@ -432,8 +443,9 @@ TEST_F(AlternateProtocolServerPropertiesTest, Set) {
url::SchemeHostPort test_server3("http", "foo3", 80);
const AlternativeService alternative_service4(kProtoHTTP2, "bar4", 1234);
base::Time expiration4 = now + base::TimeDelta::FromDays(4);
- const AlternativeServiceInfo alternative_service_info2(alternative_service4,
- expiration4);
+ const AlternativeServiceInfo alternative_service_info2(
+ alternative_service4, expiration4,
+ HttpNetworkSession::Params().quic_supported_versions);
// Add an old entry from Preferences, this will be added to end of recency
// list.
alternative_service_map.Put(
@@ -496,8 +508,9 @@ TEST_F(AlternateProtocolServerPropertiesTest, EmptyVector) {
url::SchemeHostPort server("https", "foo", 443);
const AlternativeService alternative_service(kProtoHTTP2, "bar", 443);
base::Time expiration = base::Time::Now() - base::TimeDelta::FromDays(1);
- const AlternativeServiceInfo alternative_service_info(alternative_service,
- expiration);
+ const AlternativeServiceInfo alternative_service_info(
+ alternative_service, expiration,
+ HttpNetworkSession::Params().quic_supported_versions);
AlternativeServiceMap alternative_service_map(
AlternativeServiceMap::NO_AUTO_EVICT);
alternative_service_map.Put(
@@ -529,8 +542,9 @@ TEST_F(AlternateProtocolServerPropertiesTest, EmptyVectorForCanonical) {
url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
const AlternativeService alternative_service(kProtoHTTP2, "", 443);
base::Time expiration = base::Time::Now() - base::TimeDelta::FromDays(1);
- const AlternativeServiceInfo alternative_service_info(alternative_service,
- expiration);
+ const AlternativeServiceInfo alternative_service_info(
+ alternative_service, expiration,
+ HttpNetworkSession::Params().quic_supported_versions);
AlternativeServiceMap alternative_service_map(
AlternativeServiceMap::NO_AUTO_EVICT);
alternative_service_map.Put(
@@ -563,8 +577,9 @@ TEST_F(AlternateProtocolServerPropertiesTest, ClearServerWithCanonical) {
url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
const AlternativeService alternative_service(kProtoQUIC, "", 443);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
- const AlternativeServiceInfo alternative_service_info(alternative_service,
- expiration);
+ const AlternativeServiceInfo alternative_service_info(
+ alternative_service, expiration,
+ HttpNetworkSession::Params().quic_supported_versions);
impl_.SetAlternativeServices(
canonical_server,
@@ -637,11 +652,14 @@ TEST_F(AlternateProtocolServerPropertiesTest, SetBroken) {
// SetAlternativeServices should add a broken alternative service to the map.
AlternativeServiceInfoVector alternative_service_info_vector2;
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
- alternative_service_info_vector2.push_back(
- AlternativeServiceInfo(alternative_service1, expiration));
+
+ alternative_service_info_vector2.push_back(AlternativeServiceInfo(
+ alternative_service1, expiration,
+ HttpNetworkSession::Params().quic_supported_versions));
const AlternativeService alternative_service2(kProtoHTTP2, "foo", 1234);
- alternative_service_info_vector2.push_back(
- AlternativeServiceInfo(alternative_service2, expiration));
+ alternative_service_info_vector2.push_back(AlternativeServiceInfo(
+ alternative_service2, expiration,
+ HttpNetworkSession::Params().quic_supported_versions));
impl_.SetAlternativeServices(test_server, alternative_service_info_vector2);
alternative_service_info_vector =
impl_.GetAlternativeServiceInfos(test_server);
@@ -671,14 +689,16 @@ TEST_F(AlternateProtocolServerPropertiesTest, MaxAge) {
// First alternative service expired one day ago, should not be returned by
// GetAlternativeServiceInfos().
const AlternativeService alternative_service1(kProtoHTTP2, "foo", 443);
- alternative_service_info_vector.push_back(
- AlternativeServiceInfo(alternative_service1, now - one_day));
+ alternative_service_info_vector.push_back(AlternativeServiceInfo(
+ alternative_service1, now - one_day,
+ HttpNetworkSession::Params().quic_supported_versions));
// Second alterrnative service will expire one day from now, should be
// returned by GetAlternativeSerices().
const AlternativeService alternative_service2(kProtoHTTP2, "bar", 1234);
- alternative_service_info_vector.push_back(
- AlternativeServiceInfo(alternative_service2, now + one_day));
+ alternative_service_info_vector.push_back(AlternativeServiceInfo(
+ alternative_service2, now + one_day,
+ HttpNetworkSession::Params().quic_supported_versions));
url::SchemeHostPort test_server("http", "foo", 80);
impl_.SetAlternativeServices(test_server, alternative_service_info_vector);
@@ -698,14 +718,16 @@ TEST_F(AlternateProtocolServerPropertiesTest, MaxAgeCanonical) {
// First alternative service expired one day ago, should not be returned by
// GetAlternativeServiceInfos().
const AlternativeService alternative_service1(kProtoHTTP2, "foo", 443);
- alternative_service_info_vector.push_back(
- AlternativeServiceInfo(alternative_service1, now - one_day));
+ alternative_service_info_vector.push_back(AlternativeServiceInfo(
+ alternative_service1, now - one_day,
+ HttpNetworkSession::Params().quic_supported_versions));
// Second alterrnative service will expire one day from now, should be
// returned by GetAlternativeSerices().
const AlternativeService alternative_service2(kProtoHTTP2, "bar", 1234);
- alternative_service_info_vector.push_back(
- AlternativeServiceInfo(alternative_service2, now + one_day));
+ alternative_service_info_vector.push_back(AlternativeServiceInfo(
+ alternative_service2, now + one_day,
+ HttpNetworkSession::Params().quic_supported_versions));
url::SchemeHostPort canonical_server("https", "bar.c.youtube.com", 443);
impl_.SetAlternativeServices(canonical_server,
@@ -723,11 +745,13 @@ TEST_F(AlternateProtocolServerPropertiesTest, AlternativeServiceWithScheme) {
AlternativeServiceInfoVector alternative_service_info_vector;
const AlternativeService alternative_service1(kProtoHTTP2, "foo", 443);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
- alternative_service_info_vector.push_back(
- AlternativeServiceInfo(alternative_service1, expiration));
+ alternative_service_info_vector.push_back(AlternativeServiceInfo(
+ alternative_service1, expiration,
+ HttpNetworkSession::Params().quic_supported_versions));
const AlternativeService alternative_service2(kProtoHTTP2, "bar", 1234);
- alternative_service_info_vector.push_back(
- AlternativeServiceInfo(alternative_service2, expiration));
+ alternative_service_info_vector.push_back(AlternativeServiceInfo(
+ alternative_service2, expiration,
+ HttpNetworkSession::Params().quic_supported_versions));
// Set Alt-Svc list for |http_server|.
url::SchemeHostPort http_server("http", "foo", 80);
impl_.SetAlternativeServices(http_server, alternative_service_info_vector);
@@ -759,11 +783,13 @@ TEST_F(AlternateProtocolServerPropertiesTest, ClearAlternativeServices) {
AlternativeServiceInfoVector alternative_service_info_vector;
const AlternativeService alternative_service1(kProtoHTTP2, "foo", 443);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
- alternative_service_info_vector.push_back(
- AlternativeServiceInfo(alternative_service1, expiration));
+ alternative_service_info_vector.push_back(AlternativeServiceInfo(
+ alternative_service1, expiration,
+ HttpNetworkSession::Params().quic_supported_versions));
const AlternativeService alternative_service2(kProtoHTTP2, "bar", 1234);
- alternative_service_info_vector.push_back(
- AlternativeServiceInfo(alternative_service2, expiration));
+ alternative_service_info_vector.push_back(AlternativeServiceInfo(
+ alternative_service2, expiration,
+ HttpNetworkSession::Params().quic_supported_versions));
url::SchemeHostPort test_server("http", "foo", 80);
impl_.SetAlternativeServices(test_server, alternative_service_info_vector);
@@ -848,11 +874,13 @@ TEST_F(AlternateProtocolServerPropertiesTest, Canonical) {
const AlternativeService canonical_alternative_service1(
kProtoQUIC, "bar.c.youtube.com", 1234);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
- alternative_service_info_vector.push_back(
- AlternativeServiceInfo(canonical_alternative_service1, expiration));
+ alternative_service_info_vector.push_back(AlternativeServiceInfo(
+ canonical_alternative_service1, expiration,
+ HttpNetworkSession::Params().quic_supported_versions));
const AlternativeService canonical_alternative_service2(kProtoHTTP2, "", 443);
- alternative_service_info_vector.push_back(
- AlternativeServiceInfo(canonical_alternative_service2, expiration));
+ alternative_service_info_vector.push_back(AlternativeServiceInfo(
+ canonical_alternative_service2, expiration,
+ HttpNetworkSession::Params().quic_supported_versions));
impl_.SetAlternativeServices(canonical_server,
alternative_service_info_vector);

Powered by Google App Engine
This is Rietveld 408576698