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

Unified Diff: net/http/http_stream_factory_impl_job_controller_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, 6 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_stream_factory_impl_job_controller_unittest.cc
diff --git a/net/http/http_stream_factory_impl_job_controller_unittest.cc b/net/http/http_stream_factory_impl_job_controller_unittest.cc
index 0e30b72664ec3dc8746d2d31a0f2e6e60e3a8fae..38216b9f66d97dbba0c51ebd10c42f90ea43b35d 100644
--- a/net/http/http_stream_factory_impl_job_controller_unittest.cc
+++ b/net/http/http_stream_factory_impl_job_controller_unittest.cc
@@ -122,6 +122,15 @@ class JobControllerPeer {
HttpStreamFactoryImpl::JobController* job_controller) {
return job_controller->main_job_is_blocked_;
}
+
+ static AlternativeServiceInfo GetAlternativeServiceInfoFor(
+ HttpStreamFactoryImpl::JobController* job_controller,
+ const HttpRequestInfo& request_info,
+ HttpStreamRequest::Delegate* delegate,
+ HttpStreamRequest::StreamType stream_type) {
+ return job_controller->GetAlternativeServiceInfoFor(request_info, delegate,
+ stream_type);
+ }
};
class HttpStreamFactoryImplJobControllerTest : public ::testing::Test {
@@ -193,7 +202,8 @@ class HttpStreamFactoryImplJobControllerTest : public ::testing::Test {
url::SchemeHostPort server(request_info.url);
base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
session_->http_server_properties()->SetAlternativeService(
- server, alternative_service, expiration);
+ server, alternative_service, expiration,
+ HttpNetworkSession::Params().quic_supported_versions);
}
void VerifyBrokenAlternateProtocolMapping(const HttpRequestInfo& request_info,
@@ -1480,4 +1490,61 @@ TEST_P(HttpStreamFactoryImplJobControllerPreconnectTest,
EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_));
}
+// Test that GetAlternativeServiceInfoFor will include a list of advertised
+// versions.
+TEST_F(HttpStreamFactoryImplJobControllerTest, GetAlternativeServiceInfoFor) {
+ HttpRequestInfo request_info;
+ request_info.method = "GET";
+ request_info.url = GURL("https://www.google.com");
+
+ Initialize(request_info);
+ url::SchemeHostPort server(request_info.url);
+ AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
+ HostPortPair host_port_pair = HostPortPair::FromURL(request_info.url);
+ base::Time expiration = base::Time::Now() + base::TimeDelta::FromDays(1);
+
+ // Set alternative service with no advertised version, JobController will
+ // append default supported quic versions when get alternative service info.
+ session_->http_server_properties()->SetAlternativeService(
+ server, alternative_service, expiration, QuicVersionVector());
+
+ AlternativeServiceInfo alt_svc_info =
+ JobControllerPeer::GetAlternativeServiceInfoFor(
+ job_controller_, request_info, &request_delegate_,
+ HttpStreamRequest::HTTP_STREAM);
+ const QuicVersionVector supported_versions =
+ session_->params().quic_supported_versions;
+ // Verify that JobController appends list of supported QUIC versions.
+ EXPECT_EQ(supported_versions.size(),
+ alt_svc_info.advertised_versions().size());
+ for (unsigned int i = 0; i < supported_versions.size(); i++) {
+ EXPECT_EQ(supported_versions[i], alt_svc_info.advertised_versions()[i]);
+ }
+
+ // Set alternative service for the same server with QUIC_VERSION_39 specified.
+ ASSERT_TRUE(session_->http_server_properties()->SetAlternativeService(
+ server, alternative_service, expiration, {QUIC_VERSION_39}));
+
+ alt_svc_info = JobControllerPeer::GetAlternativeServiceInfoFor(
+ job_controller_, request_info, &request_delegate_,
+ HttpStreamRequest::HTTP_STREAM);
+ EXPECT_EQ(1u, alt_svc_info.advertised_versions().size());
+ // Verify that JobController returns the single version specified in set.
+ EXPECT_EQ(QUIC_VERSION_39, alt_svc_info.advertised_versions()[0]);
+
+ // Set alternative service for the same server with two QUIC versions:
+ // QUIC_VERSION_35, QUIC_VERSION_39.
+ ASSERT_TRUE(session_->http_server_properties()->SetAlternativeService(
+ server, alternative_service, expiration,
+ {QUIC_VERSION_35, QUIC_VERSION_39}));
+
+ alt_svc_info = JobControllerPeer::GetAlternativeServiceInfoFor(
+ job_controller_, request_info, &request_delegate_,
+ HttpStreamRequest::HTTP_STREAM);
+ EXPECT_EQ(2u, alt_svc_info.advertised_versions().size());
+ // Verify that JobController returns the list of versions specified in set.
+ EXPECT_EQ(QUIC_VERSION_35, alt_svc_info.advertised_versions()[0]);
+ EXPECT_EQ(QUIC_VERSION_39, alt_svc_info.advertised_versions()[1]);
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698