| 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 b21d15d935905417bf63876f5094f15cd88ff71e..9422788cf43940a65db775876f735decc5ccae68 100644
|
| --- a/net/http/http_stream_factory_impl_job_controller_unittest.cc
|
| +++ b/net/http/http_stream_factory_impl_job_controller_unittest.cc
|
| @@ -123,7 +123,9 @@ class HttpStreamFactoryImplJobControllerTest
|
| session_deps_.enable_quic = true;
|
| }
|
|
|
| - void Initialize(bool use_alternative_proxy) {
|
| + void Initialize(const HttpRequestInfo& request_info,
|
| + bool use_alternative_proxy,
|
| + bool is_preconnect) {
|
| std::unique_ptr<TestProxyDelegate> test_proxy_delegate(
|
| new TestProxyDelegate());
|
| test_proxy_delegate_ = test_proxy_delegate.get();
|
| @@ -142,7 +144,8 @@ class HttpStreamFactoryImplJobControllerTest
|
| factory_ =
|
| static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory());
|
| job_controller_ = new HttpStreamFactoryImpl::JobController(
|
| - factory_, &request_delegate_, session_.get(), &job_factory_);
|
| + factory_, &request_delegate_, session_.get(), &job_factory_,
|
| + request_info, is_preconnect);
|
| HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller_);
|
| }
|
|
|
| @@ -195,12 +198,13 @@ TEST_F(HttpStreamFactoryImplJobControllerTest,
|
| session_deps_.proxy_service.reset(
|
| new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
|
| base::WrapUnique(proxy_resolver_factory), nullptr));
|
| - Initialize(false);
|
|
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("http://www.google.com");
|
|
|
| + Initialize(request_info, false, false);
|
| +
|
| request_.reset(
|
| job_controller_->Start(request_info, &request_delegate_, nullptr,
|
| NetLogWithSource(), HttpStreamRequest::HTTP_STREAM,
|
| @@ -225,12 +229,12 @@ TEST_F(HttpStreamFactoryImplJobControllerTest,
|
| session_deps_.proxy_service.reset(
|
| new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
|
| base::WrapUnique(proxy_resolver_factory), nullptr));
|
| - Initialize(false);
|
| -
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("http://www.google.com");
|
|
|
| + Initialize(request_info, false, false);
|
| +
|
| request_.reset(
|
| job_controller_->Start(request_info, &request_delegate_, nullptr,
|
| NetLogWithSource(), HttpStreamRequest::HTTP_STREAM,
|
| @@ -258,12 +262,12 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, CancelJobsBeforeBinding) {
|
| session_deps_.proxy_service.reset(new ProxyService(
|
| base::WrapUnique(new ProxyConfigServiceFixed(proxy_config)),
|
| base::WrapUnique(proxy_resolver_factory), nullptr));
|
| - Initialize(false);
|
|
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("https://www.google.com");
|
|
|
| + Initialize(request_info, false, false);
|
| url::SchemeHostPort server(request_info.url);
|
| AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
|
| SetAlternativeService(request_info, alternative_service);
|
| @@ -292,12 +296,12 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, OnStreamFailedForBothJobs) {
|
| session_deps_.proxy_service.reset(
|
| new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
|
| base::WrapUnique(proxy_resolver_factory), nullptr));
|
| - Initialize(false);
|
|
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("https://www.google.com");
|
|
|
| + Initialize(request_info, false, false);
|
| url::SchemeHostPort server(request_info.url);
|
| AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
|
| SetAlternativeService(request_info, alternative_service);
|
| @@ -336,12 +340,12 @@ TEST_F(HttpStreamFactoryImplJobControllerTest,
|
| session_deps_.proxy_service.reset(
|
| new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
|
| base::WrapUnique(proxy_resolver_factory), nullptr));
|
| - Initialize(false);
|
|
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("https://www.google.com");
|
|
|
| + Initialize(request_info, false, false);
|
| url::SchemeHostPort server(request_info.url);
|
| AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
|
| SetAlternativeService(request_info, alternative_service);
|
| @@ -388,12 +392,12 @@ TEST_F(HttpStreamFactoryImplJobControllerTest,
|
| session_deps_.proxy_service.reset(
|
| new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
|
| base::WrapUnique(proxy_resolver_factory), nullptr));
|
| - Initialize(false);
|
| -
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("https://www.google.com");
|
|
|
| + Initialize(request_info, false, false);
|
| +
|
| url::SchemeHostPort server(request_info.url);
|
| AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
|
| SetAlternativeService(request_info, alternative_service);
|
| @@ -435,12 +439,12 @@ TEST_F(HttpStreamFactoryImplJobControllerTest,
|
| session_deps_.proxy_service.reset(
|
| new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
|
| base::WrapUnique(proxy_resolver_factory), nullptr));
|
| - Initialize(false);
|
| -
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("https://www.google.com");
|
|
|
| + Initialize(request_info, false, false);
|
| +
|
| url::SchemeHostPort server(request_info.url);
|
| AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
|
| SetAlternativeService(request_info, alternative_service);
|
| @@ -502,12 +506,12 @@ TEST_F(HttpStreamFactoryImplJobControllerTest,
|
| session_deps_.proxy_service.reset(
|
| new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
|
| base::WrapUnique(proxy_resolver_factory), nullptr));
|
| - Initialize(false);
|
| -
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("https://www.google.com");
|
|
|
| + Initialize(request_info, false, false);
|
| +
|
| url::SchemeHostPort server(request_info.url);
|
| AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
|
| SetAlternativeService(request_info, alternative_service);
|
| @@ -546,12 +550,12 @@ TEST_F(HttpStreamFactoryImplJobControllerTest,
|
| session_deps_.proxy_service.reset(
|
| new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
|
| base::WrapUnique(proxy_resolver_factory), nullptr));
|
| - Initialize(false);
|
| -
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("https://www.google.com");
|
|
|
| + Initialize(request_info, false, false);
|
| +
|
| url::SchemeHostPort server(request_info.url);
|
| AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
|
| SetAlternativeService(request_info, alternative_service);
|
| @@ -592,12 +596,12 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, GetLoadStateAfterMainJobFailed) {
|
| session_deps_.proxy_service.reset(new ProxyService(
|
| base::WrapUnique(new ProxyConfigServiceFixed(proxy_config)),
|
| base::WrapUnique(proxy_resolver_factory), nullptr));
|
| - Initialize(false);
|
|
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("https://www.google.com");
|
|
|
| + Initialize(request_info, false, false);
|
| url::SchemeHostPort server(request_info.url);
|
| AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
|
| SetAlternativeService(request_info, alternative_service);
|
| @@ -640,12 +644,11 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, DoNotResumeMainJobBeforeWait) {
|
| base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
|
| base::WrapUnique(new FailingProxyResolverFactory), nullptr));
|
|
|
| - Initialize(false);
|
| -
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("https://www.google.com");
|
|
|
| + Initialize(request_info, false, false);
|
| url::SchemeHostPort server(request_info.url);
|
| AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
|
| SetAlternativeService(request_info, alternative_service);
|
| @@ -663,14 +666,14 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, DoNotResumeMainJobBeforeWait) {
|
| }
|
|
|
| TEST_F(HttpStreamFactoryImplJobControllerTest, InvalidPortForQuic) {
|
| - // Using a restricted port 101 for QUIC should fail and the alternative job
|
| - // should post OnStreamFailedCall on the controller to resume the main job.
|
| - Initialize(false);
|
| -
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("https://www.google.com");
|
|
|
| + // Using a restricted port 101 for QUIC should fail and the alternative job
|
| + // should post OnStreamFailedCall on the controller to resume the main job.
|
| + Initialize(request_info, false, false);
|
| +
|
| url::SchemeHostPort server(request_info.url);
|
| AlternativeService alternative_service(kProtoQUIC, server.host(), 101);
|
| SetAlternativeService(request_info, alternative_service);
|
| @@ -706,12 +709,12 @@ TEST_F(HttpStreamFactoryImplJobControllerTest,
|
| session_deps_.host_resolver.reset(host_resolver);
|
| session_deps_.host_resolver->set_synchronous_mode(false);
|
|
|
| - Initialize(false);
|
| -
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("https://www.google.com");
|
|
|
| + Initialize(request_info, false, false);
|
| +
|
| // Set a SPDY alternative service for the server.
|
| url::SchemeHostPort server(request_info.url);
|
| AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
|
| @@ -769,12 +772,11 @@ TEST_F(HttpStreamFactoryImplJobControllerTest,
|
| new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
|
| base::WrapUnique(proxy_resolver_factory), nullptr));
|
|
|
| - Initialize(false);
|
| -
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("https://www.google.com");
|
|
|
| + Initialize(request_info, false, false);
|
| url::SchemeHostPort server(request_info.url);
|
| AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
|
| SetAlternativeService(request_info, alternative_service);
|
| @@ -821,7 +823,11 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, DelayedTCP) {
|
| HangingResolver* resolver = new HangingResolver();
|
| session_deps_.host_resolver.reset(resolver);
|
|
|
| - Initialize(false);
|
| + HttpRequestInfo request_info;
|
| + request_info.method = "GET";
|
| + request_info.url = GURL("https://www.google.com");
|
| +
|
| + Initialize(request_info, false, false);
|
|
|
| // Enable delayed TCP and set time delay for waiting job.
|
| QuicStreamFactory* quic_stream_factory = session_->quic_stream_factory();
|
| @@ -832,10 +838,6 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, DelayedTCP) {
|
| session_->http_server_properties()->SetServerNetworkStats(
|
| url::SchemeHostPort(GURL("https://www.google.com")), stats1);
|
|
|
| - HttpRequestInfo request_info;
|
| - request_info.method = "GET";
|
| - request_info.url = GURL("https://www.google.com");
|
| -
|
| // Set a SPDY alternative service for the server.
|
| url::SchemeHostPort server(request_info.url);
|
| AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
|
| @@ -866,12 +868,11 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, HttpsURL) {
|
| HangingResolver* resolver = new HangingResolver();
|
| session_deps_.host_resolver.reset(resolver);
|
|
|
| - Initialize(true);
|
| - EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic());
|
| -
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("https://mail.example.org/");
|
| + Initialize(request_info, false, false);
|
| + EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic());
|
|
|
| request_.reset(
|
| job_controller_->Start(request_info, &request_delegate_, nullptr,
|
| @@ -893,13 +894,13 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, HttpURLWithNoProxy) {
|
| HangingResolver* resolver = new HangingResolver();
|
| session_deps_.host_resolver.reset(resolver);
|
|
|
| - Initialize(false);
|
| - EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic());
|
| -
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("http://mail.example.org/");
|
|
|
| + Initialize(request_info, false, false);
|
| + EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic());
|
| +
|
| request_.reset(
|
| job_controller_->Start(request_info, &request_delegate_, nullptr,
|
| NetLogWithSource(), HttpStreamRequest::HTTP_STREAM,
|
| @@ -921,7 +922,11 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, DelayedTCPAlternativeProxy) {
|
| HangingResolver* resolver = new HangingResolver();
|
| session_deps_.host_resolver.reset(resolver);
|
|
|
| - Initialize(true);
|
| + HttpRequestInfo request_info;
|
| + request_info.method = "GET";
|
| + request_info.url = GURL("http://mail.example.org/");
|
| + Initialize(request_info, true, false);
|
| +
|
| EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic());
|
|
|
| // Enable delayed TCP and set time delay for waiting job.
|
| @@ -933,10 +938,6 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, DelayedTCPAlternativeProxy) {
|
| session_->http_server_properties()->SetServerNetworkStats(
|
| url::SchemeHostPort(GURL("https://myproxy.org")), stats1);
|
|
|
| - HttpRequestInfo request_info;
|
| - request_info.method = "GET";
|
| - request_info.url = GURL("http://mail.example.org/");
|
| -
|
| request_.reset(
|
| job_controller_->Start(request_info, &request_delegate_, nullptr,
|
| NetLogWithSource(), HttpStreamRequest::HTTP_STREAM,
|
| @@ -982,7 +983,10 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, FailAlternativeProxy) {
|
| FailingHostResolver* resolver = new FailingHostResolver();
|
| session_deps_.host_resolver.reset(resolver);
|
|
|
| - Initialize(true);
|
| + HttpRequestInfo request_info;
|
| + request_info.method = "GET";
|
| + request_info.url = GURL("http://mail.example.org/");
|
| + Initialize(request_info, true, false);
|
| EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic());
|
|
|
| // Enable delayed TCP and set time delay for waiting job.
|
| @@ -994,10 +998,6 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, FailAlternativeProxy) {
|
| session_->http_server_properties()->SetServerNetworkStats(
|
| url::SchemeHostPort(GURL("https://myproxy.org")), stats1);
|
|
|
| - HttpRequestInfo request_info;
|
| - request_info.method = "GET";
|
| - request_info.url = GURL("http://mail.example.org/");
|
| -
|
| request_.reset(
|
| job_controller_->Start(request_info, &request_delegate_, nullptr,
|
| NetLogWithSource(), HttpStreamRequest::HTTP_STREAM,
|
| @@ -1027,11 +1027,10 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, FailAlternativeProxy) {
|
| TEST_F(HttpStreamFactoryImplJobControllerTest,
|
| AlternativeProxyServerJobFailsAfterMainJobSucceeds) {
|
| base::HistogramTester histogram_tester;
|
| - Initialize(true);
|
| -
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("http://www.google.com");
|
| + Initialize(request_info, true, false);
|
|
|
| url::SchemeHostPort server(request_info.url);
|
|
|
| @@ -1075,10 +1074,10 @@ TEST_F(HttpStreamFactoryImplJobControllerTest,
|
| SequencedSocketData data(reads, arraysize(reads), nullptr, 0);
|
| session_deps_.socket_factory->AddSocketDataProvider(&data);
|
|
|
| - Initialize(false);
|
| HttpRequestInfo request_info;
|
| request_info.method = "GET";
|
| request_info.url = GURL("http://www.example.com");
|
| + Initialize(request_info, false, /*is_preconnect=*/true);
|
|
|
| url::SchemeHostPort server(request_info.url);
|
|
|
|
|