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

Unified Diff: net/http/http_stream_factory_impl_job_controller_unittest.cc

Issue 2621983004: Improve HttpStreamFactory NetLog events (Closed)
Patch Set: Address Bence comments and change back to auto Created 3 years, 11 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 f541a8e3c35e2447d2e6b95f702fea4d389188a4..39024b996702f6bcd20185bd6727a19bc0cb3790 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);
@@ -547,12 +551,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);
@@ -599,11 +603,11 @@ TEST_F(HttpStreamFactoryImplJobControllerTest,
new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config),
base::WrapUnique(proxy_resolver_factory), nullptr));
session_deps_.quic_do_not_mark_as_broken_on_network_change = true;
- 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);
@@ -648,12 +652,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);
@@ -696,12 +700,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);
@@ -719,14 +722,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);
@@ -762,12 +765,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);
@@ -825,12 +828,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);
@@ -877,7 +879,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();
@@ -888,10 +894,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);
@@ -922,12 +924,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,
@@ -949,13 +950,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,
@@ -977,7 +978,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.
@@ -989,10 +994,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,
@@ -1038,7 +1039,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.
@@ -1050,10 +1054,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,
@@ -1083,11 +1083,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);
@@ -1131,10 +1130,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);
« no previous file with comments | « net/http/http_stream_factory_impl_job_controller.cc ('k') | net/http/http_stream_factory_impl_request_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698