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

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

Issue 2690393005: Cap the delay time for the main job when racing with QUIC for delayed (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 unified diff | Download patch
« no previous file with comments | « net/http/http_stream_factory_impl_job_controller.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 928 matching lines...) Expand 10 before | Expand all | Expand 10 after
939 939
940 EXPECT_FALSE(JobControllerPeer::main_job_is_blocked(job_controller_)); 940 EXPECT_FALSE(JobControllerPeer::main_job_is_blocked(job_controller_));
941 // OnStreamFailed will not resume the main job again since it's been resumed 941 // OnStreamFailed will not resume the main job again since it's been resumed
942 // already. 942 // already.
943 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); 943 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0);
944 944
945 job_controller_->OnStreamFailed(job_factory_.alternative_job(), 945 job_controller_->OnStreamFailed(job_factory_.alternative_job(),
946 ERR_NETWORK_CHANGED, SSLConfig()); 946 ERR_NETWORK_CHANGED, SSLConfig());
947 } 947 }
948 948
949 TEST_F(HttpStreamFactoryImplJobControllerTest, DelayedTCPWithLargeSrtt) {
950 HangingResolver* resolver = new HangingResolver();
951 session_deps_.host_resolver.reset(resolver);
952
953 HttpRequestInfo request_info;
954 request_info.method = "GET";
955 request_info.url = GURL("https://www.google.com");
956
957 Initialize(request_info, false, false);
958
959 // Enable delayed TCP and set a extremely large time delay for waiting job.
960 QuicStreamFactory* quic_stream_factory = session_->quic_stream_factory();
961 test::QuicStreamFactoryPeer::SetDelayTcpRace(quic_stream_factory, true);
962 quic_stream_factory->set_require_confirmation(false);
963 ServerNetworkStats stats1;
964 stats1.srtt = base::TimeDelta::FromSeconds(100);
965 session_->http_server_properties()->SetServerNetworkStats(
966 url::SchemeHostPort(GURL("https://www.google.com")), stats1);
967
968 // Set a SPDY alternative service for the server.
969 url::SchemeHostPort server(request_info.url);
970 AlternativeService alternative_service(kProtoQUIC, server.host(), 443);
971 SetAlternativeService(request_info, alternative_service);
972
973 request_.reset(
974 job_controller_->Start(request_info, &request_delegate_, nullptr,
975 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM,
976 DEFAULT_PRIORITY, SSLConfig(), SSLConfig()));
977 EXPECT_TRUE(job_controller_->main_job());
978 EXPECT_TRUE(job_controller_->alternative_job());
979 EXPECT_TRUE(job_controller_->main_job()->is_waiting());
980
981 // The alternative job stalls as host resolution hangs when creating the QUIC
982 // request and controller should resume the main job after delay.
983 base::RunLoop run_loop;
984 EXPECT_CALL(*job_factory_.main_job(), Resume())
985 .Times(1)
986 .WillOnce(
987 testing::DoAll(testing::Invoke(testing::CreateFunctor(
988 &JobControllerPeer::VerifyWaitingTimeForMainJob,
989 job_controller_, base::TimeDelta::FromSeconds(3))),
Jana 2017/02/15 22:08:26 Readability nit: Can you add a kMaxDelayTimeForMai
Zhongyi Shi 2017/02/15 22:20:01 Done.
990 testing::Invoke([&run_loop]() { run_loop.Quit(); })));
991
992 // Wait for the main job to be resumed.
993 run_loop.Run();
994 }
995
949 TEST_F(HttpStreamFactoryImplJobControllerTest, 996 TEST_F(HttpStreamFactoryImplJobControllerTest,
950 ResumeMainJobImmediatelyOnStreamFailed) { 997 ResumeMainJobImmediatelyOnStreamFailed) {
951 HangingResolver* resolver = new HangingResolver(); 998 HangingResolver* resolver = new HangingResolver();
952 session_deps_.host_resolver.reset(resolver); 999 session_deps_.host_resolver.reset(resolver);
953 1000
954 HttpRequestInfo request_info; 1001 HttpRequestInfo request_info;
955 request_info.method = "GET"; 1002 request_info.method = "GET";
956 request_info.url = GURL("https://www.google.com"); 1003 request_info.url = GURL("https://www.google.com");
957 1004
958 Initialize(request_info, false, false); 1005 Initialize(request_info, false, false);
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 Preconnect(kNumPreconects); 1344 Preconnect(kNumPreconects);
1298 // If experiment is enabled, only 1 stream is requested. 1345 // If experiment is enabled, only 1 stream is requested.
1299 EXPECT_EQ( 1346 EXPECT_EQ(
1300 (int)actual_num_connects, 1347 (int)actual_num_connects,
1301 HttpStreamFactoryImplJobPeer::GetNumStreams(job_controller_->main_job())); 1348 HttpStreamFactoryImplJobPeer::GetNumStreams(job_controller_->main_job()));
1302 base::RunLoop().RunUntilIdle(); 1349 base::RunLoop().RunUntilIdle();
1303 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); 1350 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_));
1304 } 1351 }
1305 1352
1306 } // namespace net 1353 } // namespace net
OLDNEW
« no previous file with comments | « net/http/http_stream_factory_impl_job_controller.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698