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

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

Issue 2771263002: Retry upon 421 status code without IP pooling. (Closed)
Patch Set: Rebase. Created 3 years, 8 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 if (use_alternative_proxy_) { 155 if (use_alternative_proxy_) {
156 std::unique_ptr<ProxyService> proxy_service = 156 std::unique_ptr<ProxyService> proxy_service =
157 ProxyService::CreateFixedFromPacResult("HTTPS myproxy.org:443"); 157 ProxyService::CreateFixedFromPacResult("HTTPS myproxy.org:443");
158 session_deps_.proxy_service = std::move(proxy_service); 158 session_deps_.proxy_service = std::move(proxy_service);
159 } 159 }
160 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); 160 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_);
161 factory_ = 161 factory_ =
162 static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory()); 162 static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory());
163 job_controller_ = new HttpStreamFactoryImpl::JobController( 163 job_controller_ = new HttpStreamFactoryImpl::JobController(
164 factory_, &request_delegate_, session_.get(), &job_factory_, 164 factory_, &request_delegate_, session_.get(), &job_factory_,
165 request_info, is_preconnect_); 165 request_info, is_preconnect_, /* enable_ip_based_pooling = */ true);
166 HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller_); 166 HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller_);
167 } 167 }
168 168
169 TestProxyDelegate* test_proxy_delegate() const { 169 TestProxyDelegate* test_proxy_delegate() const {
170 return test_proxy_delegate_; 170 return test_proxy_delegate_;
171 } 171 }
172 172
173 ~HttpStreamFactoryImplJobControllerTest() override {} 173 ~HttpStreamFactoryImplJobControllerTest() override {}
174 174
175 void SetAlternativeService(const HttpRequestInfo& request_info, 175 void SetAlternativeService(const HttpRequestInfo& request_info,
(...skipping 20 matching lines...) Expand all
196 MockHttpStreamRequestDelegate request_delegate_; 196 MockHttpStreamRequestDelegate request_delegate_;
197 SpdySessionDependencies session_deps_; 197 SpdySessionDependencies session_deps_;
198 std::unique_ptr<HttpNetworkSession> session_; 198 std::unique_ptr<HttpNetworkSession> session_;
199 HttpStreamFactoryImpl* factory_; 199 HttpStreamFactoryImpl* factory_;
200 HttpStreamFactoryImpl::JobController* job_controller_; 200 HttpStreamFactoryImpl::JobController* job_controller_;
201 std::unique_ptr<HttpStreamFactoryImpl::Request> request_; 201 std::unique_ptr<HttpStreamFactoryImpl::Request> request_;
202 202
203 private: 203 private:
204 bool use_alternative_proxy_; 204 bool use_alternative_proxy_;
205 bool is_preconnect_; 205 bool is_preconnect_;
206
206 // Not owned by |this|. 207 // Not owned by |this|.
207 TestProxyDelegate* test_proxy_delegate_; 208 TestProxyDelegate* test_proxy_delegate_;
208 209
209 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImplJobControllerTest); 210 DISALLOW_COPY_AND_ASSIGN(HttpStreamFactoryImplJobControllerTest);
210 }; 211 };
211 212
212 TEST_F(HttpStreamFactoryImplJobControllerTest, 213 TEST_F(HttpStreamFactoryImplJobControllerTest,
213 OnStreamFailedWithNoAlternativeJob) { 214 OnStreamFailedWithNoAlternativeJob) {
214 ProxyConfig proxy_config; 215 ProxyConfig proxy_config;
215 proxy_config.set_auto_detect(true); 216 proxy_config.set_auto_detect(true);
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1329 void Initialize() { 1330 void Initialize() {
1330 session_deps_.http_server_properties = 1331 session_deps_.http_server_properties =
1331 base::MakeUnique<MockHttpServerProperties>(); 1332 base::MakeUnique<MockHttpServerProperties>();
1332 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); 1333 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_);
1333 factory_ = 1334 factory_ =
1334 static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory()); 1335 static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory());
1335 request_info_.method = "GET"; 1336 request_info_.method = "GET";
1336 request_info_.url = GURL("https://www.example.com"); 1337 request_info_.url = GURL("https://www.example.com");
1337 job_controller_ = new HttpStreamFactoryImpl::JobController( 1338 job_controller_ = new HttpStreamFactoryImpl::JobController(
1338 factory_, &request_delegate_, session_.get(), &job_factory_, 1339 factory_, &request_delegate_, session_.get(), &job_factory_,
1339 request_info_, true); 1340 request_info_, /* is_preconnect = */ true,
1341 /* enable_ip_based_pooling = */ true);
1340 HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller_); 1342 HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller_);
1341 } 1343 }
1342 1344
1343 protected: 1345 protected:
1344 void Preconnect(int num_streams) { 1346 void Preconnect(int num_streams) {
1345 job_controller_->Preconnect(num_streams, request_info_, SSLConfig(), 1347 job_controller_->Preconnect(num_streams, request_info_, SSLConfig(),
1346 SSLConfig()); 1348 SSLConfig());
1347 // Only one job is started. 1349 // Only one job is started.
1348 EXPECT_TRUE(job_controller_->main_job()); 1350 EXPECT_TRUE(job_controller_->main_job());
1349 EXPECT_FALSE(job_controller_->alternative_job()); 1351 EXPECT_FALSE(job_controller_->alternative_job());
(...skipping 30 matching lines...) Expand all
1380 Preconnect(kNumPreconects); 1382 Preconnect(kNumPreconects);
1381 // If experiment is enabled, only 1 stream is requested. 1383 // If experiment is enabled, only 1 stream is requested.
1382 EXPECT_EQ( 1384 EXPECT_EQ(
1383 (int)actual_num_connects, 1385 (int)actual_num_connects,
1384 HttpStreamFactoryImplJobPeer::GetNumStreams(job_controller_->main_job())); 1386 HttpStreamFactoryImplJobPeer::GetNumStreams(job_controller_->main_job()));
1385 base::RunLoop().RunUntilIdle(); 1387 base::RunLoop().RunUntilIdle();
1386 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); 1388 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_));
1387 } 1389 }
1388 1390
1389 } // namespace net 1391 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698