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

Unified Diff: net/http/http_stream_factory_impl_job_controller_unittest.cc

Issue 2701913003: Resume the main job immediately when QUIC job fails, not wait for the head start timer to exprie (Closed)
Patch Set: Created 3 years, 10 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_impl_job_controller.cc ('k') | net/http/http_stream_factory_test_util.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 d0b7fc0784db247a94a71c2801e352dbb6624ec1..e5fff136db724851c3ab9529e8c44aa679f5685e 100644
--- a/net/http/http_stream_factory_impl_job_controller_unittest.cc
+++ b/net/http/http_stream_factory_impl_job_controller_unittest.cc
@@ -842,18 +842,87 @@ TEST_F(HttpStreamFactoryImplJobControllerTest, DelayedTCP) {
DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
EXPECT_TRUE(job_controller_->main_job());
EXPECT_TRUE(job_controller_->alternative_job());
+ EXPECT_TRUE(job_controller_->main_job()->is_waiting());
// The alternative job stalls as host resolution hangs when creating the QUIC
// request and controller should resume the main job after delay.
- // Verify the waiting time for delayed main job.
+ base::RunLoop run_loop;
EXPECT_CALL(*job_factory_.main_job(), Resume())
+ .Times(1)
+ .WillOnce(testing::DoAll(
+ testing::Invoke(testing::CreateFunctor(
+ &JobControllerPeer::VerifyWaitingTimeForMainJob, job_controller_,
+ base::TimeDelta::FromMicroseconds(15))),
+ testing::Invoke([&run_loop]() { run_loop.Quit(); })));
+
+ // Wait for the main job to be resumed.
+ run_loop.Run();
+
+ EXPECT_TRUE(job_controller_->main_job());
+ EXPECT_TRUE(job_controller_->alternative_job());
+
+ // |alternative_job| fails but should not report status to Request.
+ EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0);
+
+ EXPECT_FALSE(JobControllerPeer::main_job_is_blocked(job_controller_));
+ // OnStreamFailed will not resume the main job again since it's been resumed
+ // already.
+ EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0);
+
+ job_controller_->OnStreamFailed(job_factory_.alternative_job(),
+ ERR_NETWORK_CHANGED, SSLConfig());
+}
+
+TEST_F(HttpStreamFactoryImplJobControllerTest,
+ ResumeMainJobImmediatelyOnStreamFailed) {
+ HangingResolver* resolver = new HangingResolver();
+ session_deps_.host_resolver.reset(resolver);
+
+ 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();
+ test::QuicStreamFactoryPeer::SetDelayTcpRace(quic_stream_factory, true);
+ quic_stream_factory->set_require_confirmation(false);
+ ServerNetworkStats stats1;
+ stats1.srtt = base::TimeDelta::FromMicroseconds(10);
+ session_->http_server_properties()->SetServerNetworkStats(
+ url::SchemeHostPort(GURL("https://www.google.com")), stats1);
+
+ // Set a SPDY alternative service for the server.
+ url::SchemeHostPort server(request_info.url);
+ AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
+ SetAlternativeService(request_info, alternative_service);
+
+ request_.reset(
+ job_controller_->Start(request_info, &request_delegate_, nullptr,
+ NetLogWithSource(), HttpStreamRequest::HTTP_STREAM,
+ DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
+ EXPECT_TRUE(job_controller_->main_job());
+ EXPECT_TRUE(job_controller_->alternative_job());
+ EXPECT_TRUE(job_controller_->main_job()->is_waiting());
+
+ // |alternative_job| fails but should not report status to Request.
+ EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0);
+
+ // The alternative job stalls as host resolution hangs when creating the QUIC
+ // request and controller should resume the main job with delay.
+ // OnStreamFailed should resume the main job immediately.
+ EXPECT_CALL(*job_factory_.main_job(), Resume())
+ .Times(1)
.WillOnce(Invoke(testing::CreateFunctor(
&JobControllerPeer::VerifyWaitingTimeForMainJob, job_controller_,
- base::TimeDelta::FromMicroseconds(15))));
+ base::TimeDelta::FromMicroseconds(0))));
+
+ job_controller_->OnStreamFailed(job_factory_.alternative_job(),
+ ERR_NETWORK_CHANGED, SSLConfig());
base::RunLoop().RunUntilIdle();
}
-
// Verifies that the alternative proxy server job is not created if the URL
// scheme is HTTPS.
TEST_F(HttpStreamFactoryImplJobControllerTest, HttpsURL) {
« no previous file with comments | « net/http/http_stream_factory_impl_job_controller.cc ('k') | net/http/http_stream_factory_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698