| OLD | NEW |
| 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 | 8 |
| 9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 | 116 |
| 117 class HttpStreamFactoryImplJobControllerTest | 117 class HttpStreamFactoryImplJobControllerTest |
| 118 : public ::testing::Test, | 118 : public ::testing::Test, |
| 119 public ::testing::WithParamInterface<NextProto> { | 119 public ::testing::WithParamInterface<NextProto> { |
| 120 public: | 120 public: |
| 121 HttpStreamFactoryImplJobControllerTest() | 121 HttpStreamFactoryImplJobControllerTest() |
| 122 : session_deps_(ProxyService::CreateDirect()) { | 122 : session_deps_(ProxyService::CreateDirect()) { |
| 123 session_deps_.enable_quic = true; | 123 session_deps_.enable_quic = true; |
| 124 } | 124 } |
| 125 | 125 |
| 126 void Initialize(bool use_alternative_proxy) { | 126 void Initialize(const HttpRequestInfo& request_info, |
| 127 bool use_alternative_proxy, |
| 128 bool is_preconnect) { |
| 127 std::unique_ptr<TestProxyDelegate> test_proxy_delegate( | 129 std::unique_ptr<TestProxyDelegate> test_proxy_delegate( |
| 128 new TestProxyDelegate()); | 130 new TestProxyDelegate()); |
| 129 test_proxy_delegate_ = test_proxy_delegate.get(); | 131 test_proxy_delegate_ = test_proxy_delegate.get(); |
| 130 | 132 |
| 131 test_proxy_delegate->set_alternative_proxy_server( | 133 test_proxy_delegate->set_alternative_proxy_server( |
| 132 ProxyServer::FromPacString("QUIC myproxy.org:443")); | 134 ProxyServer::FromPacString("QUIC myproxy.org:443")); |
| 133 EXPECT_TRUE(test_proxy_delegate->alternative_proxy_server().is_quic()); | 135 EXPECT_TRUE(test_proxy_delegate->alternative_proxy_server().is_quic()); |
| 134 session_deps_.proxy_delegate = std::move(test_proxy_delegate); | 136 session_deps_.proxy_delegate = std::move(test_proxy_delegate); |
| 135 | 137 |
| 136 if (use_alternative_proxy) { | 138 if (use_alternative_proxy) { |
| 137 std::unique_ptr<ProxyService> proxy_service = | 139 std::unique_ptr<ProxyService> proxy_service = |
| 138 ProxyService::CreateFixedFromPacResult("HTTPS myproxy.org:443"); | 140 ProxyService::CreateFixedFromPacResult("HTTPS myproxy.org:443"); |
| 139 session_deps_.proxy_service = std::move(proxy_service); | 141 session_deps_.proxy_service = std::move(proxy_service); |
| 140 } | 142 } |
| 141 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); | 143 session_ = SpdySessionDependencies::SpdyCreateSession(&session_deps_); |
| 142 factory_ = | 144 factory_ = |
| 143 static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory()); | 145 static_cast<HttpStreamFactoryImpl*>(session_->http_stream_factory()); |
| 144 job_controller_ = new HttpStreamFactoryImpl::JobController( | 146 job_controller_ = new HttpStreamFactoryImpl::JobController( |
| 145 factory_, &request_delegate_, session_.get(), &job_factory_); | 147 factory_, &request_delegate_, session_.get(), &job_factory_, |
| 148 request_info, is_preconnect); |
| 146 HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller_); | 149 HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller_); |
| 147 } | 150 } |
| 148 | 151 |
| 149 TestProxyDelegate* test_proxy_delegate() const { | 152 TestProxyDelegate* test_proxy_delegate() const { |
| 150 return test_proxy_delegate_; | 153 return test_proxy_delegate_; |
| 151 } | 154 } |
| 152 | 155 |
| 153 ~HttpStreamFactoryImplJobControllerTest() {} | 156 ~HttpStreamFactoryImplJobControllerTest() {} |
| 154 | 157 |
| 155 void SetAlternativeService(const HttpRequestInfo& request_info, | 158 void SetAlternativeService(const HttpRequestInfo& request_info, |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 TEST_F(HttpStreamFactoryImplJobControllerTest, | 191 TEST_F(HttpStreamFactoryImplJobControllerTest, |
| 189 OnStreamFailedWithNoAlternativeJob) { | 192 OnStreamFailedWithNoAlternativeJob) { |
| 190 ProxyConfig proxy_config; | 193 ProxyConfig proxy_config; |
| 191 proxy_config.set_auto_detect(true); | 194 proxy_config.set_auto_detect(true); |
| 192 // Use asynchronous proxy resolver. | 195 // Use asynchronous proxy resolver. |
| 193 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 196 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 194 new MockAsyncProxyResolverFactory(false); | 197 new MockAsyncProxyResolverFactory(false); |
| 195 session_deps_.proxy_service.reset( | 198 session_deps_.proxy_service.reset( |
| 196 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 199 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
| 197 base::WrapUnique(proxy_resolver_factory), nullptr)); | 200 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 198 Initialize(false); | |
| 199 | 201 |
| 200 HttpRequestInfo request_info; | 202 HttpRequestInfo request_info; |
| 201 request_info.method = "GET"; | 203 request_info.method = "GET"; |
| 202 request_info.url = GURL("http://www.google.com"); | 204 request_info.url = GURL("http://www.google.com"); |
| 203 | 205 |
| 206 Initialize(request_info, false, false); |
| 207 |
| 204 request_.reset( | 208 request_.reset( |
| 205 job_controller_->Start(request_info, &request_delegate_, nullptr, | 209 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 206 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 210 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 207 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 211 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 208 | 212 |
| 209 EXPECT_TRUE(job_controller_->main_job()); | 213 EXPECT_TRUE(job_controller_->main_job()); |
| 210 | 214 |
| 211 // There's no other alternative job. Thus when stream failed, it should | 215 // There's no other alternative job. Thus when stream failed, it should |
| 212 // notify Request of the stream failure. | 216 // notify Request of the stream failure. |
| 213 EXPECT_CALL(request_delegate_, OnStreamFailed(ERR_FAILED, _)).Times(1); | 217 EXPECT_CALL(request_delegate_, OnStreamFailed(ERR_FAILED, _)).Times(1); |
| 214 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED, | 218 job_controller_->OnStreamFailed(job_factory_.main_job(), ERR_FAILED, |
| 215 SSLConfig()); | 219 SSLConfig()); |
| 216 } | 220 } |
| 217 | 221 |
| 218 TEST_F(HttpStreamFactoryImplJobControllerTest, | 222 TEST_F(HttpStreamFactoryImplJobControllerTest, |
| 219 OnStreamReadyWithNoAlternativeJob) { | 223 OnStreamReadyWithNoAlternativeJob) { |
| 220 ProxyConfig proxy_config; | 224 ProxyConfig proxy_config; |
| 221 proxy_config.set_auto_detect(true); | 225 proxy_config.set_auto_detect(true); |
| 222 // Use asynchronous proxy resolver. | 226 // Use asynchronous proxy resolver. |
| 223 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 227 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 224 new MockAsyncProxyResolverFactory(false); | 228 new MockAsyncProxyResolverFactory(false); |
| 225 session_deps_.proxy_service.reset( | 229 session_deps_.proxy_service.reset( |
| 226 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 230 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
| 227 base::WrapUnique(proxy_resolver_factory), nullptr)); | 231 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 228 Initialize(false); | |
| 229 | |
| 230 HttpRequestInfo request_info; | 232 HttpRequestInfo request_info; |
| 231 request_info.method = "GET"; | 233 request_info.method = "GET"; |
| 232 request_info.url = GURL("http://www.google.com"); | 234 request_info.url = GURL("http://www.google.com"); |
| 233 | 235 |
| 236 Initialize(request_info, false, false); |
| 237 |
| 234 request_.reset( | 238 request_.reset( |
| 235 job_controller_->Start(request_info, &request_delegate_, nullptr, | 239 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 236 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 240 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 237 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 241 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 238 | 242 |
| 239 // There's no other alternative job. Thus when a stream is ready, it should | 243 // There's no other alternative job. Thus when a stream is ready, it should |
| 240 // notify Request. | 244 // notify Request. |
| 241 HttpStream* http_stream = | 245 HttpStream* http_stream = |
| 242 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); | 246 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); |
| 243 job_factory_.main_job()->SetStream(http_stream); | 247 job_factory_.main_job()->SetStream(http_stream); |
| 244 | 248 |
| 245 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream)) | 249 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream)) |
| 246 .WillOnce(Invoke(DeleteHttpStreamPointer)); | 250 .WillOnce(Invoke(DeleteHttpStreamPointer)); |
| 247 job_controller_->OnStreamReady(job_factory_.main_job(), SSLConfig()); | 251 job_controller_->OnStreamReady(job_factory_.main_job(), SSLConfig()); |
| 248 } | 252 } |
| 249 | 253 |
| 250 // Test we cancel Jobs correctly when the Request is explicitly canceled | 254 // Test we cancel Jobs correctly when the Request is explicitly canceled |
| 251 // before any Job is bound to Request. | 255 // before any Job is bound to Request. |
| 252 TEST_F(HttpStreamFactoryImplJobControllerTest, CancelJobsBeforeBinding) { | 256 TEST_F(HttpStreamFactoryImplJobControllerTest, CancelJobsBeforeBinding) { |
| 253 ProxyConfig proxy_config; | 257 ProxyConfig proxy_config; |
| 254 proxy_config.set_auto_detect(true); | 258 proxy_config.set_auto_detect(true); |
| 255 // Use asynchronous proxy resolver. | 259 // Use asynchronous proxy resolver. |
| 256 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 260 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 257 new MockAsyncProxyResolverFactory(false); | 261 new MockAsyncProxyResolverFactory(false); |
| 258 session_deps_.proxy_service.reset(new ProxyService( | 262 session_deps_.proxy_service.reset(new ProxyService( |
| 259 base::WrapUnique(new ProxyConfigServiceFixed(proxy_config)), | 263 base::WrapUnique(new ProxyConfigServiceFixed(proxy_config)), |
| 260 base::WrapUnique(proxy_resolver_factory), nullptr)); | 264 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 261 Initialize(false); | |
| 262 | 265 |
| 263 HttpRequestInfo request_info; | 266 HttpRequestInfo request_info; |
| 264 request_info.method = "GET"; | 267 request_info.method = "GET"; |
| 265 request_info.url = GURL("https://www.google.com"); | 268 request_info.url = GURL("https://www.google.com"); |
| 266 | 269 |
| 270 Initialize(request_info, false, false); |
| 267 url::SchemeHostPort server(request_info.url); | 271 url::SchemeHostPort server(request_info.url); |
| 268 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 272 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 269 SetAlternativeService(request_info, alternative_service); | 273 SetAlternativeService(request_info, alternative_service); |
| 270 | 274 |
| 271 request_.reset( | 275 request_.reset( |
| 272 job_controller_->Start(request_info, &request_delegate_, nullptr, | 276 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 273 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 277 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 274 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 278 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 275 EXPECT_TRUE(job_controller_->main_job()); | 279 EXPECT_TRUE(job_controller_->main_job()); |
| 276 EXPECT_TRUE(job_controller_->alternative_job()); | 280 EXPECT_TRUE(job_controller_->alternative_job()); |
| 277 | 281 |
| 278 // Reset the Request will cancel all the Jobs since there's no Job determined | 282 // Reset the Request will cancel all the Jobs since there's no Job determined |
| 279 // to serve Request yet and JobController will notify the factory to delete | 283 // to serve Request yet and JobController will notify the factory to delete |
| 280 // itself upon completion. | 284 // itself upon completion. |
| 281 request_.reset(); | 285 request_.reset(); |
| 282 VerifyBrokenAlternateProtocolMapping(request_info, false); | 286 VerifyBrokenAlternateProtocolMapping(request_info, false); |
| 283 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); | 287 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); |
| 284 } | 288 } |
| 285 | 289 |
| 286 TEST_F(HttpStreamFactoryImplJobControllerTest, OnStreamFailedForBothJobs) { | 290 TEST_F(HttpStreamFactoryImplJobControllerTest, OnStreamFailedForBothJobs) { |
| 287 ProxyConfig proxy_config; | 291 ProxyConfig proxy_config; |
| 288 proxy_config.set_auto_detect(true); | 292 proxy_config.set_auto_detect(true); |
| 289 // Use asynchronous proxy resolver. | 293 // Use asynchronous proxy resolver. |
| 290 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 294 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 291 new MockAsyncProxyResolverFactory(false); | 295 new MockAsyncProxyResolverFactory(false); |
| 292 session_deps_.proxy_service.reset( | 296 session_deps_.proxy_service.reset( |
| 293 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 297 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
| 294 base::WrapUnique(proxy_resolver_factory), nullptr)); | 298 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 295 Initialize(false); | |
| 296 | 299 |
| 297 HttpRequestInfo request_info; | 300 HttpRequestInfo request_info; |
| 298 request_info.method = "GET"; | 301 request_info.method = "GET"; |
| 299 request_info.url = GURL("https://www.google.com"); | 302 request_info.url = GURL("https://www.google.com"); |
| 300 | 303 |
| 304 Initialize(request_info, false, false); |
| 301 url::SchemeHostPort server(request_info.url); | 305 url::SchemeHostPort server(request_info.url); |
| 302 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 306 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 303 SetAlternativeService(request_info, alternative_service); | 307 SetAlternativeService(request_info, alternative_service); |
| 304 | 308 |
| 305 request_.reset( | 309 request_.reset( |
| 306 job_controller_->Start(request_info, &request_delegate_, nullptr, | 310 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 307 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 311 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 308 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 312 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 309 EXPECT_TRUE(job_controller_->main_job()); | 313 EXPECT_TRUE(job_controller_->main_job()); |
| 310 EXPECT_TRUE(job_controller_->alternative_job()); | 314 EXPECT_TRUE(job_controller_->alternative_job()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 329 TEST_F(HttpStreamFactoryImplJobControllerTest, | 333 TEST_F(HttpStreamFactoryImplJobControllerTest, |
| 330 AltJobFailsAfterMainJobSucceeds) { | 334 AltJobFailsAfterMainJobSucceeds) { |
| 331 ProxyConfig proxy_config; | 335 ProxyConfig proxy_config; |
| 332 proxy_config.set_auto_detect(true); | 336 proxy_config.set_auto_detect(true); |
| 333 // Use asynchronous proxy resolver. | 337 // Use asynchronous proxy resolver. |
| 334 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 338 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 335 new MockAsyncProxyResolverFactory(false); | 339 new MockAsyncProxyResolverFactory(false); |
| 336 session_deps_.proxy_service.reset( | 340 session_deps_.proxy_service.reset( |
| 337 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 341 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
| 338 base::WrapUnique(proxy_resolver_factory), nullptr)); | 342 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 339 Initialize(false); | |
| 340 | 343 |
| 341 HttpRequestInfo request_info; | 344 HttpRequestInfo request_info; |
| 342 request_info.method = "GET"; | 345 request_info.method = "GET"; |
| 343 request_info.url = GURL("https://www.google.com"); | 346 request_info.url = GURL("https://www.google.com"); |
| 344 | 347 |
| 348 Initialize(request_info, false, false); |
| 345 url::SchemeHostPort server(request_info.url); | 349 url::SchemeHostPort server(request_info.url); |
| 346 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 350 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 347 SetAlternativeService(request_info, alternative_service); | 351 SetAlternativeService(request_info, alternative_service); |
| 348 | 352 |
| 349 request_.reset( | 353 request_.reset( |
| 350 job_controller_->Start(request_info, &request_delegate_, nullptr, | 354 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 351 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 355 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 352 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 356 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 353 EXPECT_TRUE(job_controller_->main_job()); | 357 EXPECT_TRUE(job_controller_->main_job()); |
| 354 EXPECT_TRUE(job_controller_->alternative_job()); | 358 EXPECT_TRUE(job_controller_->alternative_job()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 381 // Regression test for crbug.com/678768. | 385 // Regression test for crbug.com/678768. |
| 382 TEST_F(HttpStreamFactoryImplJobControllerTest, | 386 TEST_F(HttpStreamFactoryImplJobControllerTest, |
| 383 AltJobSucceedsMainJobBlockedControllerDestroyed) { | 387 AltJobSucceedsMainJobBlockedControllerDestroyed) { |
| 384 ProxyConfig proxy_config; | 388 ProxyConfig proxy_config; |
| 385 proxy_config.set_auto_detect(true); | 389 proxy_config.set_auto_detect(true); |
| 386 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 390 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 387 new MockAsyncProxyResolverFactory(false); | 391 new MockAsyncProxyResolverFactory(false); |
| 388 session_deps_.proxy_service.reset( | 392 session_deps_.proxy_service.reset( |
| 389 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 393 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
| 390 base::WrapUnique(proxy_resolver_factory), nullptr)); | 394 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 391 Initialize(false); | |
| 392 | |
| 393 HttpRequestInfo request_info; | 395 HttpRequestInfo request_info; |
| 394 request_info.method = "GET"; | 396 request_info.method = "GET"; |
| 395 request_info.url = GURL("https://www.google.com"); | 397 request_info.url = GURL("https://www.google.com"); |
| 396 | 398 |
| 399 Initialize(request_info, false, false); |
| 400 |
| 397 url::SchemeHostPort server(request_info.url); | 401 url::SchemeHostPort server(request_info.url); |
| 398 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 402 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 399 SetAlternativeService(request_info, alternative_service); | 403 SetAlternativeService(request_info, alternative_service); |
| 400 request_.reset( | 404 request_.reset( |
| 401 job_controller_->Start(request_info, &request_delegate_, nullptr, | 405 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 402 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 406 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 403 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 407 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 404 EXPECT_TRUE(job_controller_->main_job()); | 408 EXPECT_TRUE(job_controller_->main_job()); |
| 405 EXPECT_TRUE(job_controller_->alternative_job()); | 409 EXPECT_TRUE(job_controller_->alternative_job()); |
| 406 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); | 410 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 428 // JobController will be cleaned up. | 432 // JobController will be cleaned up. |
| 429 TEST_F(HttpStreamFactoryImplJobControllerTest, | 433 TEST_F(HttpStreamFactoryImplJobControllerTest, |
| 430 OrphanedJobCompletesControllerDestroyed) { | 434 OrphanedJobCompletesControllerDestroyed) { |
| 431 ProxyConfig proxy_config; | 435 ProxyConfig proxy_config; |
| 432 proxy_config.set_auto_detect(true); | 436 proxy_config.set_auto_detect(true); |
| 433 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 437 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 434 new MockAsyncProxyResolverFactory(false); | 438 new MockAsyncProxyResolverFactory(false); |
| 435 session_deps_.proxy_service.reset( | 439 session_deps_.proxy_service.reset( |
| 436 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 440 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
| 437 base::WrapUnique(proxy_resolver_factory), nullptr)); | 441 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 438 Initialize(false); | |
| 439 | |
| 440 HttpRequestInfo request_info; | 442 HttpRequestInfo request_info; |
| 441 request_info.method = "GET"; | 443 request_info.method = "GET"; |
| 442 request_info.url = GURL("https://www.google.com"); | 444 request_info.url = GURL("https://www.google.com"); |
| 443 | 445 |
| 446 Initialize(request_info, false, false); |
| 447 |
| 444 url::SchemeHostPort server(request_info.url); | 448 url::SchemeHostPort server(request_info.url); |
| 445 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 449 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 446 SetAlternativeService(request_info, alternative_service); | 450 SetAlternativeService(request_info, alternative_service); |
| 447 // Hack to use different URL for the main job to help differentiate the proxy | 451 // Hack to use different URL for the main job to help differentiate the proxy |
| 448 // requests. | 452 // requests. |
| 449 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); | 453 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); |
| 450 request_.reset( | 454 request_.reset( |
| 451 job_controller_->Start(request_info, &request_delegate_, nullptr, | 455 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 452 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 456 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 453 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 457 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 TEST_F(HttpStreamFactoryImplJobControllerTest, | 499 TEST_F(HttpStreamFactoryImplJobControllerTest, |
| 496 AltJobSucceedsAfterMainJobFailed) { | 500 AltJobSucceedsAfterMainJobFailed) { |
| 497 ProxyConfig proxy_config; | 501 ProxyConfig proxy_config; |
| 498 proxy_config.set_auto_detect(true); | 502 proxy_config.set_auto_detect(true); |
| 499 // Use asynchronous proxy resolver. | 503 // Use asynchronous proxy resolver. |
| 500 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 504 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 501 new MockAsyncProxyResolverFactory(false); | 505 new MockAsyncProxyResolverFactory(false); |
| 502 session_deps_.proxy_service.reset( | 506 session_deps_.proxy_service.reset( |
| 503 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 507 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
| 504 base::WrapUnique(proxy_resolver_factory), nullptr)); | 508 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 505 Initialize(false); | |
| 506 | |
| 507 HttpRequestInfo request_info; | 509 HttpRequestInfo request_info; |
| 508 request_info.method = "GET"; | 510 request_info.method = "GET"; |
| 509 request_info.url = GURL("https://www.google.com"); | 511 request_info.url = GURL("https://www.google.com"); |
| 510 | 512 |
| 513 Initialize(request_info, false, false); |
| 514 |
| 511 url::SchemeHostPort server(request_info.url); | 515 url::SchemeHostPort server(request_info.url); |
| 512 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 516 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 513 SetAlternativeService(request_info, alternative_service); | 517 SetAlternativeService(request_info, alternative_service); |
| 514 | 518 |
| 515 request_.reset( | 519 request_.reset( |
| 516 job_controller_->Start(request_info, &request_delegate_, nullptr, | 520 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 517 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 521 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 518 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 522 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 519 EXPECT_TRUE(job_controller_->main_job()); | 523 EXPECT_TRUE(job_controller_->main_job()); |
| 520 EXPECT_TRUE(job_controller_->alternative_job()); | 524 EXPECT_TRUE(job_controller_->alternative_job()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 540 MainJobSucceedsAfterAltJobFailed) { | 544 MainJobSucceedsAfterAltJobFailed) { |
| 541 base::HistogramTester histogram_tester; | 545 base::HistogramTester histogram_tester; |
| 542 ProxyConfig proxy_config; | 546 ProxyConfig proxy_config; |
| 543 proxy_config.set_auto_detect(true); | 547 proxy_config.set_auto_detect(true); |
| 544 // Use asynchronous proxy resolver. | 548 // Use asynchronous proxy resolver. |
| 545 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 549 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 546 new MockAsyncProxyResolverFactory(false); | 550 new MockAsyncProxyResolverFactory(false); |
| 547 session_deps_.proxy_service.reset( | 551 session_deps_.proxy_service.reset( |
| 548 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 552 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
| 549 base::WrapUnique(proxy_resolver_factory), nullptr)); | 553 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 550 Initialize(false); | |
| 551 | |
| 552 HttpRequestInfo request_info; | 554 HttpRequestInfo request_info; |
| 553 request_info.method = "GET"; | 555 request_info.method = "GET"; |
| 554 request_info.url = GURL("https://www.google.com"); | 556 request_info.url = GURL("https://www.google.com"); |
| 555 | 557 |
| 558 Initialize(request_info, false, false); |
| 559 |
| 556 url::SchemeHostPort server(request_info.url); | 560 url::SchemeHostPort server(request_info.url); |
| 557 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 561 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 558 SetAlternativeService(request_info, alternative_service); | 562 SetAlternativeService(request_info, alternative_service); |
| 559 | 563 |
| 560 request_.reset( | 564 request_.reset( |
| 561 job_controller_->Start(request_info, &request_delegate_, nullptr, | 565 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 562 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 566 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 563 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 567 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 564 EXPECT_TRUE(job_controller_->main_job()); | 568 EXPECT_TRUE(job_controller_->main_job()); |
| 565 EXPECT_TRUE(job_controller_->alternative_job()); | 569 EXPECT_TRUE(job_controller_->alternative_job()); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 592 base::HistogramTester histogram_tester; | 596 base::HistogramTester histogram_tester; |
| 593 ProxyConfig proxy_config; | 597 ProxyConfig proxy_config; |
| 594 proxy_config.set_auto_detect(true); | 598 proxy_config.set_auto_detect(true); |
| 595 // Use asynchronous proxy resolver. | 599 // Use asynchronous proxy resolver. |
| 596 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 600 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 597 new MockAsyncProxyResolverFactory(false); | 601 new MockAsyncProxyResolverFactory(false); |
| 598 session_deps_.proxy_service.reset( | 602 session_deps_.proxy_service.reset( |
| 599 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 603 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
| 600 base::WrapUnique(proxy_resolver_factory), nullptr)); | 604 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 601 session_deps_.quic_do_not_mark_as_broken_on_network_change = true; | 605 session_deps_.quic_do_not_mark_as_broken_on_network_change = true; |
| 602 Initialize(false); | |
| 603 | 606 |
| 604 HttpRequestInfo request_info; | 607 HttpRequestInfo request_info; |
| 605 request_info.method = "GET"; | 608 request_info.method = "GET"; |
| 606 request_info.url = GURL("https://www.google.com"); | 609 request_info.url = GURL("https://www.google.com"); |
| 610 Initialize(request_info, false, false); |
| 607 | 611 |
| 608 url::SchemeHostPort server(request_info.url); | 612 url::SchemeHostPort server(request_info.url); |
| 609 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 613 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 610 SetAlternativeService(request_info, alternative_service); | 614 SetAlternativeService(request_info, alternative_service); |
| 611 | 615 |
| 612 request_.reset( | 616 request_.reset( |
| 613 job_controller_->Start(request_info, &request_delegate_, nullptr, | 617 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 614 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 618 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 615 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 619 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 616 EXPECT_TRUE(job_controller_->main_job()); | 620 EXPECT_TRUE(job_controller_->main_job()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 641 // Get load state after main job fails and before alternative job succeeds. | 645 // Get load state after main job fails and before alternative job succeeds. |
| 642 TEST_F(HttpStreamFactoryImplJobControllerTest, GetLoadStateAfterMainJobFailed) { | 646 TEST_F(HttpStreamFactoryImplJobControllerTest, GetLoadStateAfterMainJobFailed) { |
| 643 ProxyConfig proxy_config; | 647 ProxyConfig proxy_config; |
| 644 proxy_config.set_auto_detect(true); | 648 proxy_config.set_auto_detect(true); |
| 645 // Use asynchronous proxy resolver. | 649 // Use asynchronous proxy resolver. |
| 646 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 650 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 647 new MockAsyncProxyResolverFactory(false); | 651 new MockAsyncProxyResolverFactory(false); |
| 648 session_deps_.proxy_service.reset(new ProxyService( | 652 session_deps_.proxy_service.reset(new ProxyService( |
| 649 base::WrapUnique(new ProxyConfigServiceFixed(proxy_config)), | 653 base::WrapUnique(new ProxyConfigServiceFixed(proxy_config)), |
| 650 base::WrapUnique(proxy_resolver_factory), nullptr)); | 654 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 651 Initialize(false); | |
| 652 | 655 |
| 653 HttpRequestInfo request_info; | 656 HttpRequestInfo request_info; |
| 654 request_info.method = "GET"; | 657 request_info.method = "GET"; |
| 655 request_info.url = GURL("https://www.google.com"); | 658 request_info.url = GURL("https://www.google.com"); |
| 656 | 659 |
| 660 Initialize(request_info, false, false); |
| 657 url::SchemeHostPort server(request_info.url); | 661 url::SchemeHostPort server(request_info.url); |
| 658 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 662 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 659 SetAlternativeService(request_info, alternative_service); | 663 SetAlternativeService(request_info, alternative_service); |
| 660 | 664 |
| 661 request_.reset( | 665 request_.reset( |
| 662 job_controller_->Start(request_info, &request_delegate_, nullptr, | 666 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 663 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 667 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 664 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 668 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 665 EXPECT_TRUE(job_controller_->main_job()); | 669 EXPECT_TRUE(job_controller_->main_job()); |
| 666 EXPECT_TRUE(job_controller_->alternative_job()); | 670 EXPECT_TRUE(job_controller_->alternative_job()); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 689 // Use failing ProxyResolverFactory which is unable to create ProxyResolver | 693 // Use failing ProxyResolverFactory which is unable to create ProxyResolver |
| 690 // to stall the alternative job and report to controller to maybe resume the | 694 // to stall the alternative job and report to controller to maybe resume the |
| 691 // main job. | 695 // main job. |
| 692 ProxyConfig proxy_config; | 696 ProxyConfig proxy_config; |
| 693 proxy_config.set_auto_detect(true); | 697 proxy_config.set_auto_detect(true); |
| 694 proxy_config.set_pac_mandatory(true); | 698 proxy_config.set_pac_mandatory(true); |
| 695 session_deps_.proxy_service.reset(new ProxyService( | 699 session_deps_.proxy_service.reset(new ProxyService( |
| 696 base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 700 base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
| 697 base::WrapUnique(new FailingProxyResolverFactory), nullptr)); | 701 base::WrapUnique(new FailingProxyResolverFactory), nullptr)); |
| 698 | 702 |
| 699 Initialize(false); | |
| 700 | |
| 701 HttpRequestInfo request_info; | 703 HttpRequestInfo request_info; |
| 702 request_info.method = "GET"; | 704 request_info.method = "GET"; |
| 703 request_info.url = GURL("https://www.google.com"); | 705 request_info.url = GURL("https://www.google.com"); |
| 704 | 706 |
| 707 Initialize(request_info, false, false); |
| 705 url::SchemeHostPort server(request_info.url); | 708 url::SchemeHostPort server(request_info.url); |
| 706 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 709 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 707 SetAlternativeService(request_info, alternative_service); | 710 SetAlternativeService(request_info, alternative_service); |
| 708 | 711 |
| 709 request_.reset( | 712 request_.reset( |
| 710 job_controller_->Start(request_info, &request_delegate_, nullptr, | 713 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 711 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 714 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 712 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 715 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 713 EXPECT_TRUE(job_controller_->main_job()); | 716 EXPECT_TRUE(job_controller_->main_job()); |
| 714 EXPECT_TRUE(job_controller_->alternative_job()); | 717 EXPECT_TRUE(job_controller_->alternative_job()); |
| 715 | 718 |
| 716 // Wait until OnStreamFailedCallback is executed on the alternative job. | 719 // Wait until OnStreamFailedCallback is executed on the alternative job. |
| 717 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(1); | 720 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(1); |
| 718 base::RunLoop().RunUntilIdle(); | 721 base::RunLoop().RunUntilIdle(); |
| 719 } | 722 } |
| 720 | 723 |
| 721 TEST_F(HttpStreamFactoryImplJobControllerTest, InvalidPortForQuic) { | 724 TEST_F(HttpStreamFactoryImplJobControllerTest, InvalidPortForQuic) { |
| 722 // Using a restricted port 101 for QUIC should fail and the alternative job | |
| 723 // should post OnStreamFailedCall on the controller to resume the main job. | |
| 724 Initialize(false); | |
| 725 | |
| 726 HttpRequestInfo request_info; | 725 HttpRequestInfo request_info; |
| 727 request_info.method = "GET"; | 726 request_info.method = "GET"; |
| 728 request_info.url = GURL("https://www.google.com"); | 727 request_info.url = GURL("https://www.google.com"); |
| 729 | 728 |
| 729 // Using a restricted port 101 for QUIC should fail and the alternative job |
| 730 // should post OnStreamFailedCall on the controller to resume the main job. |
| 731 Initialize(request_info, false, false); |
| 732 |
| 730 url::SchemeHostPort server(request_info.url); | 733 url::SchemeHostPort server(request_info.url); |
| 731 AlternativeService alternative_service(kProtoQUIC, server.host(), 101); | 734 AlternativeService alternative_service(kProtoQUIC, server.host(), 101); |
| 732 SetAlternativeService(request_info, alternative_service); | 735 SetAlternativeService(request_info, alternative_service); |
| 733 | 736 |
| 734 request_.reset( | 737 request_.reset( |
| 735 job_controller_->Start(request_info, &request_delegate_, nullptr, | 738 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 736 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 739 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 737 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 740 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 738 | 741 |
| 739 EXPECT_TRUE(job_factory_.main_job()->is_waiting()); | 742 EXPECT_TRUE(job_factory_.main_job()->is_waiting()); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 755 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 758 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 756 new MockAsyncProxyResolverFactory(false); | 759 new MockAsyncProxyResolverFactory(false); |
| 757 session_deps_.proxy_service.reset( | 760 session_deps_.proxy_service.reset( |
| 758 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 761 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
| 759 base::WrapUnique(proxy_resolver_factory), nullptr)); | 762 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 760 | 763 |
| 761 HangingResolver* host_resolver = new HangingResolver(); | 764 HangingResolver* host_resolver = new HangingResolver(); |
| 762 session_deps_.host_resolver.reset(host_resolver); | 765 session_deps_.host_resolver.reset(host_resolver); |
| 763 session_deps_.host_resolver->set_synchronous_mode(false); | 766 session_deps_.host_resolver->set_synchronous_mode(false); |
| 764 | 767 |
| 765 Initialize(false); | |
| 766 | |
| 767 HttpRequestInfo request_info; | 768 HttpRequestInfo request_info; |
| 768 request_info.method = "GET"; | 769 request_info.method = "GET"; |
| 769 request_info.url = GURL("https://www.google.com"); | 770 request_info.url = GURL("https://www.google.com"); |
| 770 | 771 |
| 772 Initialize(request_info, false, false); |
| 773 |
| 771 // Set a SPDY alternative service for the server. | 774 // Set a SPDY alternative service for the server. |
| 772 url::SchemeHostPort server(request_info.url); | 775 url::SchemeHostPort server(request_info.url); |
| 773 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 776 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 774 SetAlternativeService(request_info, alternative_service); | 777 SetAlternativeService(request_info, alternative_service); |
| 775 // Hack to use different URL for the main job to help differentiate the proxy | 778 // Hack to use different URL for the main job to help differentiate the proxy |
| 776 // requests. | 779 // requests. |
| 777 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); | 780 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); |
| 778 | 781 |
| 779 request_.reset( | 782 request_.reset( |
| 780 job_controller_->Start(request_info, &request_delegate_, nullptr, | 783 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 818 | 821 |
| 819 ProxyConfig proxy_config; | 822 ProxyConfig proxy_config; |
| 820 proxy_config.set_auto_detect(true); | 823 proxy_config.set_auto_detect(true); |
| 821 // Use asynchronous proxy resolver. | 824 // Use asynchronous proxy resolver. |
| 822 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 825 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
| 823 new MockAsyncProxyResolverFactory(false); | 826 new MockAsyncProxyResolverFactory(false); |
| 824 session_deps_.proxy_service.reset( | 827 session_deps_.proxy_service.reset( |
| 825 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 828 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
| 826 base::WrapUnique(proxy_resolver_factory), nullptr)); | 829 base::WrapUnique(proxy_resolver_factory), nullptr)); |
| 827 | 830 |
| 828 Initialize(false); | |
| 829 | |
| 830 HttpRequestInfo request_info; | 831 HttpRequestInfo request_info; |
| 831 request_info.method = "GET"; | 832 request_info.method = "GET"; |
| 832 request_info.url = GURL("https://www.google.com"); | 833 request_info.url = GURL("https://www.google.com"); |
| 833 | 834 |
| 835 Initialize(request_info, false, false); |
| 834 url::SchemeHostPort server(request_info.url); | 836 url::SchemeHostPort server(request_info.url); |
| 835 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 837 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 836 SetAlternativeService(request_info, alternative_service); | 838 SetAlternativeService(request_info, alternative_service); |
| 837 // Hack to use different URL for the main job to help differentiate the proxy | 839 // Hack to use different URL for the main job to help differentiate the proxy |
| 838 // requests. | 840 // requests. |
| 839 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); | 841 job_factory_.UseDifferentURLForMainJob(GURL("http://www.google.com")); |
| 840 | 842 |
| 841 request_.reset( | 843 request_.reset( |
| 842 job_controller_->Start(request_info, &request_delegate_, nullptr, | 844 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 843 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 845 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| (...skipping 26 matching lines...) Expand all Loading... |
| 870 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); | 872 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); |
| 871 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(1); | 873 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(1); |
| 872 | 874 |
| 873 base::RunLoop().RunUntilIdle(); | 875 base::RunLoop().RunUntilIdle(); |
| 874 } | 876 } |
| 875 | 877 |
| 876 TEST_F(HttpStreamFactoryImplJobControllerTest, DelayedTCP) { | 878 TEST_F(HttpStreamFactoryImplJobControllerTest, DelayedTCP) { |
| 877 HangingResolver* resolver = new HangingResolver(); | 879 HangingResolver* resolver = new HangingResolver(); |
| 878 session_deps_.host_resolver.reset(resolver); | 880 session_deps_.host_resolver.reset(resolver); |
| 879 | 881 |
| 880 Initialize(false); | 882 HttpRequestInfo request_info; |
| 883 request_info.method = "GET"; |
| 884 request_info.url = GURL("https://www.google.com"); |
| 885 |
| 886 Initialize(request_info, false, false); |
| 881 | 887 |
| 882 // Enable delayed TCP and set time delay for waiting job. | 888 // Enable delayed TCP and set time delay for waiting job. |
| 883 QuicStreamFactory* quic_stream_factory = session_->quic_stream_factory(); | 889 QuicStreamFactory* quic_stream_factory = session_->quic_stream_factory(); |
| 884 test::QuicStreamFactoryPeer::SetDelayTcpRace(quic_stream_factory, true); | 890 test::QuicStreamFactoryPeer::SetDelayTcpRace(quic_stream_factory, true); |
| 885 quic_stream_factory->set_require_confirmation(false); | 891 quic_stream_factory->set_require_confirmation(false); |
| 886 ServerNetworkStats stats1; | 892 ServerNetworkStats stats1; |
| 887 stats1.srtt = base::TimeDelta::FromMicroseconds(10); | 893 stats1.srtt = base::TimeDelta::FromMicroseconds(10); |
| 888 session_->http_server_properties()->SetServerNetworkStats( | 894 session_->http_server_properties()->SetServerNetworkStats( |
| 889 url::SchemeHostPort(GURL("https://www.google.com")), stats1); | 895 url::SchemeHostPort(GURL("https://www.google.com")), stats1); |
| 890 | 896 |
| 891 HttpRequestInfo request_info; | |
| 892 request_info.method = "GET"; | |
| 893 request_info.url = GURL("https://www.google.com"); | |
| 894 | |
| 895 // Set a SPDY alternative service for the server. | 897 // Set a SPDY alternative service for the server. |
| 896 url::SchemeHostPort server(request_info.url); | 898 url::SchemeHostPort server(request_info.url); |
| 897 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 899 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
| 898 SetAlternativeService(request_info, alternative_service); | 900 SetAlternativeService(request_info, alternative_service); |
| 899 | 901 |
| 900 request_.reset( | 902 request_.reset( |
| 901 job_controller_->Start(request_info, &request_delegate_, nullptr, | 903 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 902 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 904 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 903 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 905 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 904 EXPECT_TRUE(job_controller_->main_job()); | 906 EXPECT_TRUE(job_controller_->main_job()); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 915 base::RunLoop().RunUntilIdle(); | 917 base::RunLoop().RunUntilIdle(); |
| 916 } | 918 } |
| 917 | 919 |
| 918 // Verifies that the alternative proxy server job is not created if the URL | 920 // Verifies that the alternative proxy server job is not created if the URL |
| 919 // scheme is HTTPS. | 921 // scheme is HTTPS. |
| 920 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpsURL) { | 922 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpsURL) { |
| 921 // Using hanging resolver will cause the alternative job to hang indefinitely. | 923 // Using hanging resolver will cause the alternative job to hang indefinitely. |
| 922 HangingResolver* resolver = new HangingResolver(); | 924 HangingResolver* resolver = new HangingResolver(); |
| 923 session_deps_.host_resolver.reset(resolver); | 925 session_deps_.host_resolver.reset(resolver); |
| 924 | 926 |
| 925 Initialize(true); | |
| 926 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); | |
| 927 | |
| 928 HttpRequestInfo request_info; | 927 HttpRequestInfo request_info; |
| 929 request_info.method = "GET"; | 928 request_info.method = "GET"; |
| 930 request_info.url = GURL("https://mail.example.org/"); | 929 request_info.url = GURL("https://mail.example.org/"); |
| 930 Initialize(request_info, false, false); |
| 931 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); |
| 931 | 932 |
| 932 request_.reset( | 933 request_.reset( |
| 933 job_controller_->Start(request_info, &request_delegate_, nullptr, | 934 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 934 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 935 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 935 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 936 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 936 EXPECT_TRUE(job_controller_->main_job()); | 937 EXPECT_TRUE(job_controller_->main_job()); |
| 937 EXPECT_FALSE(job_controller_->main_job()->is_waiting()); | 938 EXPECT_FALSE(job_controller_->main_job()->is_waiting()); |
| 938 EXPECT_FALSE(job_controller_->alternative_job()); | 939 EXPECT_FALSE(job_controller_->alternative_job()); |
| 939 | 940 |
| 940 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); | 941 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); |
| 941 base::RunLoop().RunUntilIdle(); | 942 base::RunLoop().RunUntilIdle(); |
| 942 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations()); | 943 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations()); |
| 943 } | 944 } |
| 944 | 945 |
| 945 // Verifies that the alternative proxy server job is not created if the main job | 946 // Verifies that the alternative proxy server job is not created if the main job |
| 946 // does not fetch the resource through a proxy. | 947 // does not fetch the resource through a proxy. |
| 947 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpURLWithNoProxy) { | 948 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpURLWithNoProxy) { |
| 948 // Using hanging resolver will cause the alternative job to hang indefinitely. | 949 // Using hanging resolver will cause the alternative job to hang indefinitely. |
| 949 HangingResolver* resolver = new HangingResolver(); | 950 HangingResolver* resolver = new HangingResolver(); |
| 950 session_deps_.host_resolver.reset(resolver); | 951 session_deps_.host_resolver.reset(resolver); |
| 951 | 952 |
| 952 Initialize(false); | |
| 953 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); | |
| 954 | |
| 955 HttpRequestInfo request_info; | 953 HttpRequestInfo request_info; |
| 956 request_info.method = "GET"; | 954 request_info.method = "GET"; |
| 957 request_info.url = GURL("http://mail.example.org/"); | 955 request_info.url = GURL("http://mail.example.org/"); |
| 958 | 956 |
| 957 Initialize(request_info, false, false); |
| 958 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); |
| 959 |
| 959 request_.reset( | 960 request_.reset( |
| 960 job_controller_->Start(request_info, &request_delegate_, nullptr, | 961 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 961 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 962 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 962 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 963 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 963 EXPECT_TRUE(job_controller_->main_job()); | 964 EXPECT_TRUE(job_controller_->main_job()); |
| 964 EXPECT_FALSE(job_controller_->main_job()->is_waiting()); | 965 EXPECT_FALSE(job_controller_->main_job()->is_waiting()); |
| 965 EXPECT_FALSE(job_controller_->alternative_job()); | 966 EXPECT_FALSE(job_controller_->alternative_job()); |
| 966 | 967 |
| 967 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); | 968 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); |
| 968 base::RunLoop().RunUntilIdle(); | 969 base::RunLoop().RunUntilIdle(); |
| 969 | 970 |
| 970 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations()); | 971 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations()); |
| 971 } | 972 } |
| 972 | 973 |
| 973 // Verifies that the main job is resumed properly after a delay when the | 974 // Verifies that the main job is resumed properly after a delay when the |
| 974 // alternative proxy server job hangs. | 975 // alternative proxy server job hangs. |
| 975 TEST_F(HttpStreamFactoryImplJobControllerTest, DelayedTCPAlternativeProxy) { | 976 TEST_F(HttpStreamFactoryImplJobControllerTest, DelayedTCPAlternativeProxy) { |
| 976 // Using hanging resolver will cause the alternative job to hang indefinitely. | 977 // Using hanging resolver will cause the alternative job to hang indefinitely. |
| 977 HangingResolver* resolver = new HangingResolver(); | 978 HangingResolver* resolver = new HangingResolver(); |
| 978 session_deps_.host_resolver.reset(resolver); | 979 session_deps_.host_resolver.reset(resolver); |
| 979 | 980 |
| 980 Initialize(true); | 981 HttpRequestInfo request_info; |
| 982 request_info.method = "GET"; |
| 983 request_info.url = GURL("http://mail.example.org/"); |
| 984 Initialize(request_info, true, false); |
| 985 |
| 981 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); | 986 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); |
| 982 | 987 |
| 983 // Enable delayed TCP and set time delay for waiting job. | 988 // Enable delayed TCP and set time delay for waiting job. |
| 984 QuicStreamFactory* quic_stream_factory = session_->quic_stream_factory(); | 989 QuicStreamFactory* quic_stream_factory = session_->quic_stream_factory(); |
| 985 test::QuicStreamFactoryPeer::SetDelayTcpRace(quic_stream_factory, true); | 990 test::QuicStreamFactoryPeer::SetDelayTcpRace(quic_stream_factory, true); |
| 986 quic_stream_factory->set_require_confirmation(false); | 991 quic_stream_factory->set_require_confirmation(false); |
| 987 ServerNetworkStats stats1; | 992 ServerNetworkStats stats1; |
| 988 stats1.srtt = base::TimeDelta::FromMicroseconds(10); | 993 stats1.srtt = base::TimeDelta::FromMicroseconds(10); |
| 989 session_->http_server_properties()->SetServerNetworkStats( | 994 session_->http_server_properties()->SetServerNetworkStats( |
| 990 url::SchemeHostPort(GURL("https://myproxy.org")), stats1); | 995 url::SchemeHostPort(GURL("https://myproxy.org")), stats1); |
| 991 | 996 |
| 992 HttpRequestInfo request_info; | |
| 993 request_info.method = "GET"; | |
| 994 request_info.url = GURL("http://mail.example.org/"); | |
| 995 | |
| 996 request_.reset( | 997 request_.reset( |
| 997 job_controller_->Start(request_info, &request_delegate_, nullptr, | 998 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 998 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 999 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 999 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 1000 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 1000 EXPECT_TRUE(job_controller_->main_job()); | 1001 EXPECT_TRUE(job_controller_->main_job()); |
| 1001 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); | 1002 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); |
| 1002 EXPECT_TRUE(job_controller_->alternative_job()); | 1003 EXPECT_TRUE(job_controller_->alternative_job()); |
| 1003 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); | 1004 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); |
| 1004 | 1005 |
| 1005 // The alternative proxy server job stalls when connecting to the alternative | 1006 // The alternative proxy server job stalls when connecting to the alternative |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1031 EXPECT_EQ(1, test_proxy_delegate()->get_alternative_proxy_invocations()); | 1032 EXPECT_EQ(1, test_proxy_delegate()->get_alternative_proxy_invocations()); |
| 1032 } | 1033 } |
| 1033 | 1034 |
| 1034 // Verifies that the alternative proxy server job fails immediately, and the | 1035 // Verifies that the alternative proxy server job fails immediately, and the |
| 1035 // main job is not blocked. | 1036 // main job is not blocked. |
| 1036 TEST_F(HttpStreamFactoryImplJobControllerTest, FailAlternativeProxy) { | 1037 TEST_F(HttpStreamFactoryImplJobControllerTest, FailAlternativeProxy) { |
| 1037 // Using failing resolver will cause the alternative job to fail. | 1038 // Using failing resolver will cause the alternative job to fail. |
| 1038 FailingHostResolver* resolver = new FailingHostResolver(); | 1039 FailingHostResolver* resolver = new FailingHostResolver(); |
| 1039 session_deps_.host_resolver.reset(resolver); | 1040 session_deps_.host_resolver.reset(resolver); |
| 1040 | 1041 |
| 1041 Initialize(true); | 1042 HttpRequestInfo request_info; |
| 1043 request_info.method = "GET"; |
| 1044 request_info.url = GURL("http://mail.example.org/"); |
| 1045 Initialize(request_info, true, false); |
| 1042 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); | 1046 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); |
| 1043 | 1047 |
| 1044 // Enable delayed TCP and set time delay for waiting job. | 1048 // Enable delayed TCP and set time delay for waiting job. |
| 1045 QuicStreamFactory* quic_stream_factory = session_->quic_stream_factory(); | 1049 QuicStreamFactory* quic_stream_factory = session_->quic_stream_factory(); |
| 1046 test::QuicStreamFactoryPeer::SetDelayTcpRace(quic_stream_factory, true); | 1050 test::QuicStreamFactoryPeer::SetDelayTcpRace(quic_stream_factory, true); |
| 1047 quic_stream_factory->set_require_confirmation(false); | 1051 quic_stream_factory->set_require_confirmation(false); |
| 1048 ServerNetworkStats stats1; | 1052 ServerNetworkStats stats1; |
| 1049 stats1.srtt = base::TimeDelta::FromMicroseconds(300 * 1000); | 1053 stats1.srtt = base::TimeDelta::FromMicroseconds(300 * 1000); |
| 1050 session_->http_server_properties()->SetServerNetworkStats( | 1054 session_->http_server_properties()->SetServerNetworkStats( |
| 1051 url::SchemeHostPort(GURL("https://myproxy.org")), stats1); | 1055 url::SchemeHostPort(GURL("https://myproxy.org")), stats1); |
| 1052 | 1056 |
| 1053 HttpRequestInfo request_info; | |
| 1054 request_info.method = "GET"; | |
| 1055 request_info.url = GURL("http://mail.example.org/"); | |
| 1056 | |
| 1057 request_.reset( | 1057 request_.reset( |
| 1058 job_controller_->Start(request_info, &request_delegate_, nullptr, | 1058 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 1059 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 1059 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 1060 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 1060 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 1061 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); | 1061 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); |
| 1062 EXPECT_TRUE(job_controller_->alternative_job()); | 1062 EXPECT_TRUE(job_controller_->alternative_job()); |
| 1063 | 1063 |
| 1064 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)).Times(0); | 1064 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)).Times(0); |
| 1065 | 1065 |
| 1066 // Since the alternative proxy server job is started in the next message loop, | 1066 // Since the alternative proxy server job is started in the next message loop, |
| 1067 // the main job would remain blocked until the alternative proxy starts, and | 1067 // the main job would remain blocked until the alternative proxy starts, and |
| 1068 // fails. | 1068 // fails. |
| 1069 EXPECT_CALL(*job_factory_.main_job(), Resume()) | 1069 EXPECT_CALL(*job_factory_.main_job(), Resume()) |
| 1070 .WillOnce(Invoke(testing::CreateFunctor( | 1070 .WillOnce(Invoke(testing::CreateFunctor( |
| 1071 &JobControllerPeer::VerifyWaitingTimeForMainJob, job_controller_, | 1071 &JobControllerPeer::VerifyWaitingTimeForMainJob, job_controller_, |
| 1072 base::TimeDelta::FromMicroseconds(0)))); | 1072 base::TimeDelta::FromMicroseconds(0)))); |
| 1073 | 1073 |
| 1074 base::RunLoop().RunUntilIdle(); | 1074 base::RunLoop().RunUntilIdle(); |
| 1075 EXPECT_FALSE(job_controller_->alternative_job()); | 1075 EXPECT_FALSE(job_controller_->alternative_job()); |
| 1076 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); | 1076 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); |
| 1077 // Since the main job did not complete successfully, the alternative proxy | 1077 // Since the main job did not complete successfully, the alternative proxy |
| 1078 // server should not be marked as bad. | 1078 // server should not be marked as bad. |
| 1079 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_valid()); | 1079 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_valid()); |
| 1080 EXPECT_EQ(1, test_proxy_delegate()->get_alternative_proxy_invocations()); | 1080 EXPECT_EQ(1, test_proxy_delegate()->get_alternative_proxy_invocations()); |
| 1081 } | 1081 } |
| 1082 | 1082 |
| 1083 TEST_F(HttpStreamFactoryImplJobControllerTest, | 1083 TEST_F(HttpStreamFactoryImplJobControllerTest, |
| 1084 AlternativeProxyServerJobFailsAfterMainJobSucceeds) { | 1084 AlternativeProxyServerJobFailsAfterMainJobSucceeds) { |
| 1085 base::HistogramTester histogram_tester; | 1085 base::HistogramTester histogram_tester; |
| 1086 Initialize(true); | |
| 1087 | |
| 1088 HttpRequestInfo request_info; | 1086 HttpRequestInfo request_info; |
| 1089 request_info.method = "GET"; | 1087 request_info.method = "GET"; |
| 1090 request_info.url = GURL("http://www.google.com"); | 1088 request_info.url = GURL("http://www.google.com"); |
| 1089 Initialize(request_info, true, false); |
| 1091 | 1090 |
| 1092 url::SchemeHostPort server(request_info.url); | 1091 url::SchemeHostPort server(request_info.url); |
| 1093 | 1092 |
| 1094 request_.reset( | 1093 request_.reset( |
| 1095 job_controller_->Start(request_info, &request_delegate_, nullptr, | 1094 job_controller_->Start(request_info, &request_delegate_, nullptr, |
| 1096 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, | 1095 NetLogWithSource(), HttpStreamRequest::HTTP_STREAM, |
| 1097 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); | 1096 DEFAULT_PRIORITY, SSLConfig(), SSLConfig())); |
| 1098 EXPECT_TRUE(job_controller_->main_job()); | 1097 EXPECT_TRUE(job_controller_->main_job()); |
| 1099 EXPECT_TRUE(job_controller_->alternative_job()); | 1098 EXPECT_TRUE(job_controller_->alternative_job()); |
| 1100 | 1099 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1124 1); | 1123 1); |
| 1125 } | 1124 } |
| 1126 | 1125 |
| 1127 // When preconnect to a H2 supported server, only 1 connection is opened. | 1126 // When preconnect to a H2 supported server, only 1 connection is opened. |
| 1128 TEST_F(HttpStreamFactoryImplJobControllerTest, | 1127 TEST_F(HttpStreamFactoryImplJobControllerTest, |
| 1129 PreconnectMultipleStreamsToH2Server) { | 1128 PreconnectMultipleStreamsToH2Server) { |
| 1130 MockRead reads[] = {MockRead(ASYNC, OK)}; | 1129 MockRead reads[] = {MockRead(ASYNC, OK)}; |
| 1131 SequencedSocketData data(reads, arraysize(reads), nullptr, 0); | 1130 SequencedSocketData data(reads, arraysize(reads), nullptr, 0); |
| 1132 session_deps_.socket_factory->AddSocketDataProvider(&data); | 1131 session_deps_.socket_factory->AddSocketDataProvider(&data); |
| 1133 | 1132 |
| 1134 Initialize(false); | |
| 1135 HttpRequestInfo request_info; | 1133 HttpRequestInfo request_info; |
| 1136 request_info.method = "GET"; | 1134 request_info.method = "GET"; |
| 1137 request_info.url = GURL("http://www.example.com"); | 1135 request_info.url = GURL("http://www.example.com"); |
| 1136 Initialize(request_info, false, /*is_preconnect=*/true); |
| 1138 | 1137 |
| 1139 url::SchemeHostPort server(request_info.url); | 1138 url::SchemeHostPort server(request_info.url); |
| 1140 | 1139 |
| 1141 // Sets server support Http/2. | 1140 // Sets server support Http/2. |
| 1142 session_->http_server_properties()->SetSupportsSpdy(server, true); | 1141 session_->http_server_properties()->SetSupportsSpdy(server, true); |
| 1143 | 1142 |
| 1144 job_controller_->Preconnect(/*num_streams=*/5, request_info, SSLConfig(), | 1143 job_controller_->Preconnect(/*num_streams=*/5, request_info, SSLConfig(), |
| 1145 SSLConfig()); | 1144 SSLConfig()); |
| 1146 // Only one job is started. | 1145 // Only one job is started. |
| 1147 EXPECT_TRUE(job_controller_->main_job()); | 1146 EXPECT_TRUE(job_controller_->main_job()); |
| 1148 EXPECT_FALSE(job_controller_->alternative_job()); | 1147 EXPECT_FALSE(job_controller_->alternative_job()); |
| 1149 // There is only 1 connect even though multiple streams were requested. | 1148 // There is only 1 connect even though multiple streams were requested. |
| 1150 EXPECT_EQ(1, HttpStreamFactoryImplJobPeer::GetNumStreams( | 1149 EXPECT_EQ(1, HttpStreamFactoryImplJobPeer::GetNumStreams( |
| 1151 job_controller_->main_job())); | 1150 job_controller_->main_job())); |
| 1152 | 1151 |
| 1153 base::RunLoop().RunUntilIdle(); | 1152 base::RunLoop().RunUntilIdle(); |
| 1154 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); | 1153 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); |
| 1155 } | 1154 } |
| 1156 | 1155 |
| 1157 } // namespace net | 1156 } // namespace net |
| OLD | NEW |