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

Side by Side Diff: net/http/http_stream_factory_impl_job_controller_unittest.cc

Issue 2693043008: Resume the main job immediately when QUIC job fails, not wait for the head start timer to exprie (Closed)
Patch Set: sync with master 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/http/http_stream_factory_impl_job_controller.h" 5 #include "net/http/http_stream_factory_impl_job_controller.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 url::SchemeHostPort server(request_info.url); 908 url::SchemeHostPort server(request_info.url);
909 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); 909 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
910 SetAlternativeService(request_info, alternative_service); 910 SetAlternativeService(request_info, alternative_service);
911 911
912 request_.reset( 912 request_.reset(
913 job_controller_->Start(request_info, &request_delegate_, nullptr, 913 job_controller_->Start(request_info, &request_delegate_, nullptr,
914 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, 914 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM,
915 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); 915 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
916 EXPECT_TRUE(job_controller_->main_job()); 916 EXPECT_TRUE(job_controller_->main_job());
917 EXPECT_TRUE(job_controller_->alternative_job()); 917 EXPECT_TRUE(job_controller_->alternative_job());
918 EXPECT_TRUE(job_controller_->main_job()->is_waiting());
918 919
919 // The alternative job stalls as host resolution hangs when creating the QUIC 920 // The alternative job stalls as host resolution hangs when creating the QUIC
920 // request and controller should resume the main job after delay. 921 // request and controller should resume the main job after delay.
921 // Verify the waiting time for delayed main job. 922 base::RunLoop run_loop;
922 EXPECT_CALL(*job_factory_.main_job(), Resume()) 923 EXPECT_CALL(*job_factory_.main_job(), Resume())
924 .Times(1)
925 .WillOnce(testing::DoAll(
926 testing::Invoke(testing::CreateFunctor(
927 &JobControllerPeer::VerifyWaitingTimeForMainJob, job_controller_,
928 base::TimeDelta::FromMicroseconds(15))),
929 testing::Invoke([&run_loop]() { run_loop.Quit(); })));
930
931 // Wait for the main job to be resumed.
932 run_loop.Run();
933
934 EXPECT_TRUE(job_controller_->main_job());
935 EXPECT_TRUE(job_controller_->alternative_job());
936
937 // |alternative_job| fails but should not report status to Request.
938 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0);
939
940 EXPECT_FALSE(JobControllerPeer::main_job_is_blocked(job_controller_));
941 // OnStreamFailed will not resume the main job again since it's been resumed
942 // already.
943 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0);
944
945 job_controller_->OnStreamFailed(job_factory_.alternative_job(),
946 ERR_NETWORK_CHANGED, SSLConfig());
947 }
948
949 TEST_F(HttpStreamFactoryImplJobControllerTest,
950 ResumeMainJobImmediatelyOnStreamFailed) {
951 HangingResolver* resolver = new HangingResolver();
952 session_deps_.host_resolver.reset(resolver);
953
954 HttpRequestInfo request_info;
955 request_info.method = "GET";
956 request_info.url = GURL("https://www.google.com");
957
958 Initialize(request_info, false, false);
959
960 // Enable delayed TCP and set time delay for waiting job.
961 QuicStreamFactory* quic_stream_factory = session_->quic_stream_factory();
962 test::QuicStreamFactoryPeer::SetDelayTcpRace(quic_stream_factory, true);
963 quic_stream_factory->set_require_confirmation(false);
964 ServerNetworkStats stats1;
965 stats1.srtt = base::TimeDelta::FromMicroseconds(10);
966 session_->http_server_properties()->SetServerNetworkStats(
967 url::SchemeHostPort(GURL("https://www.google.com")), stats1);
968
969 // Set a SPDY alternative service for the server.
970 url::SchemeHostPort server(request_info.url);
971 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
972 SetAlternativeService(request_info, alternative_service);
973
974 request_.reset(
975 job_controller_->Start(request_info, &request_delegate_, nullptr,
976 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM,
977 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
978 EXPECT_TRUE(job_controller_->main_job());
979 EXPECT_TRUE(job_controller_->alternative_job());
980 EXPECT_TRUE(job_controller_->main_job()->is_waiting());
981
982 // |alternative_job| fails but should not report status to Request.
983 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0);
984
985 // The alternative job stalls as host resolution hangs when creating the QUIC
986 // request and controller should resume the main job with delay.
987 // OnStreamFailed should resume the main job immediately.
988 EXPECT_CALL(*job_factory_.main_job(), Resume())
989 .Times(1)
923 .WillOnce(Invoke(testing::CreateFunctor( 990 .WillOnce(Invoke(testing::CreateFunctor(
924 &JobControllerPeer::VerifyWaitingTimeForMainJob, job_controller_, 991 &JobControllerPeer::VerifyWaitingTimeForMainJob, job_controller_,
925 base::TimeDelta::FromMicroseconds(15)))); 992 base::TimeDelta::FromMicroseconds(0))));
993
994 job_controller_->OnStreamFailed(job_factory_.alternative_job(),
995 ERR_NETWORK_CHANGED, SSLConfig());
926 996
927 base::RunLoop().RunUntilIdle(); 997 base::RunLoop().RunUntilIdle();
928 } 998 }
929
930 // Verifies that the alternative proxy server job is not created if the URL 999 // Verifies that the alternative proxy server job is not created if the URL
931 // scheme is HTTPS. 1000 // scheme is HTTPS.
932 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpsURL) { 1001 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpsURL) {
933 // Using hanging resolver will cause the alternative job to hang indefinitely. 1002 // Using hanging resolver will cause the alternative job to hang indefinitely.
934 HangingResolver* resolver = new HangingResolver(); 1003 HangingResolver* resolver = new HangingResolver();
935 session_deps_.host_resolver.reset(resolver); 1004 session_deps_.host_resolver.reset(resolver);
936 1005
937 HttpRequestInfo request_info; 1006 HttpRequestInfo request_info;
938 request_info.method = "GET"; 1007 request_info.method = "GET";
939 request_info.url = GURL("https://mail.example.org/"); 1008 request_info.url = GURL("https://mail.example.org/");
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 Preconnect(kNumPreconects); 1297 Preconnect(kNumPreconects);
1229 // If experiment is enabled, only 1 stream is requested. 1298 // If experiment is enabled, only 1 stream is requested.
1230 EXPECT_EQ( 1299 EXPECT_EQ(
1231 (int)actual_num_connects, 1300 (int)actual_num_connects,
1232 HttpStreamFactoryImplJobPeer::GetNumStreams(job_controller_->main_job())); 1301 HttpStreamFactoryImplJobPeer::GetNumStreams(job_controller_->main_job()));
1233 base::RunLoop().RunUntilIdle(); 1302 base::RunLoop().RunUntilIdle();
1234 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); 1303 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_));
1235 } 1304 }
1236 1305
1237 } // namespace net 1306 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698