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

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 compile in components 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 ffc80c42a8986104b720227fd5e3ca52c0059214..e3df6fa33340560898daccf992d8abe1a687f487 100644
--- a/net/http/http_stream_factory_impl_job_controller_unittest.cc
+++ b/net/http/http_stream_factory_impl_job_controller_unittest.cc
@@ -158,10 +158,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 {
@@ -261,7 +271,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,
@@ -338,18 +349,18 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, ProxyResolutionFailsAsync) {
ProxyConfig proxy_config;
proxy_config.set_pac_url(GURL("http://fooproxyurl"));
proxy_config.set_pac_mandatory(true);
- MockAsyncProxyResolverFactory* proxy_resolver_factory =
- new MockAsyncProxyResolverFactory(false);
- MockAsyncProxyResolver resolver;
- session_deps_.proxy_service.reset(
- new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
- base::WrapUnique(proxy_resolver_factory), nullptr));
+ session_deps_.proxy_service.reset(new ProxyService(
Bence 2017/06/08 17:44:51 session_deps_.proxy_service = base::MakeUnique<Pro
Zhongyi Shi 2017/06/08 23:11:16 This is a change not related to this CL. Not sure
+ base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
+ base::WrapUnique(new FailingProxyResolverFactory), nullptr));
Bence 2017/06/08 17:44:52 base::MakeUnique<FailingProxyResolverFactory>()
Zhongyi Shi 2017/06/08 23:11:16 ditto.
HttpRequestInfo request_info;
request_info.method = "GET";
request_info.url = GURL("http://www.google.com");
Initialize(request_info);
+ EXPECT_CALL(request_delegate_,
+ OnStreamFailed(ERR_MANDATORY_PROXY_CONFIGURATION_FAILED, _))
+ .Times(1);
request_ =
job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(),
HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY);
@@ -357,14 +368,11 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, ProxyResolutionFailsAsync) {
EXPECT_FALSE(job_controller_->main_job());
EXPECT_FALSE(job_controller_->alternative_job());
- EXPECT_EQ(LOAD_STATE_RESOLVING_PROXY_FOR_URL,
- job_controller_->GetLoadState());
+ // Make sure calling GetLoadState() when before job
+ // creation does not crash.
+ // Regression test for crbug.com/723920.
+ EXPECT_EQ(LOAD_STATE_IDLE, job_controller_->GetLoadState());
- EXPECT_CALL(request_delegate_,
- OnStreamFailed(ERR_MANDATORY_PROXY_CONFIGURATION_FAILED, _))
- .Times(1);
- proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder(
- ERR_FAILED, &resolver);
base::RunLoop().RunUntilIdle();
request_.reset();
EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_));
@@ -1728,4 +1736,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