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

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: fix Canonical test 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
« no previous file with comments | « net/http/http_stream_factory.cc ('k') | net/http/http_stream_factory_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 42b823e9989c64b01034ab1074887a0eb9035350..1a46a9523fbdc76732d1b9cbc8a1c85f618eb7df 100644
--- a/net/http/http_stream_factory_impl_job_controller_unittest.cc
+++ b/net/http/http_stream_factory_impl_job_controller_unittest.cc
@@ -157,10 +157,20 @@ class JobControllerPeer {
HttpStreamFactoryImpl::JobController* job_controller) {
return job_controller->main_job_is_blocked_;
}
+
static bool main_job_is_resumed(
HttpStreamFactoryImpl::JobController* job_controller) {
return job_controller->main_job_is_resumed_;
}
+
+ 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 {
@@ -253,8 +263,14 @@ class HttpStreamFactoryImplJobControllerTest : public ::testing::Test {
HostPortPair host_port_pair = HostPortPair::FromURL(request_info.url);
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);
+ if (alternative_service.protocol == kProtoQUIC) {
+ session_->http_server_properties()->SetQuicAlternativeService(
+ server, alternative_service, expiration,
+ session_->params().quic_supported_versions);
+ } else {
+ session_->http_server_properties()->SetHttp2AlternativeService(
+ server, alternative_service, expiration);
+ }
}
void VerifyBrokenAlternateProtocolMapping(const HttpRequestInfo& request_info,
@@ -2069,6 +2085,57 @@ TEST_P(HttpStreamFactoryImplJobControllerPreconnectTest,
EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_));
}
+// Test that GetAlternativeServiceInfoFor will include a list of advertised
+// versions. Returns an empty list if advertised versions are missing in
+// HttpServerProperties.
+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.
+ session_->http_server_properties()->SetQuicAlternativeService(
+ server, alternative_service, expiration, QuicVersionVector());
+
+ AlternativeServiceInfo alt_svc_info =
+ JobControllerPeer::GetAlternativeServiceInfoFor(
+ job_controller_, request_info, &request_delegate_,
+ HttpStreamRequest::HTTP_STREAM);
+ // Verify that JobController get an empty list of supported QUIC versions.
+ EXPECT_TRUE(alt_svc_info.advertised_versions().empty());
+
+ // Set alternative service for the same server with QUIC_VERSION_39 specified.
+ ASSERT_TRUE(session_->http_server_properties()->SetQuicAlternativeService(
+ 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()->SetQuicAlternativeService(
+ 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 test
} // namespace net
« no previous file with comments | « net/http/http_stream_factory.cc ('k') | net/http/http_stream_factory_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698