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 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 base::WrapUnique(new FailingProxyResolverFactory), nullptr)); | 307 base::WrapUnique(new FailingProxyResolverFactory), nullptr)); |
308 HttpRequestInfo request_info; | 308 HttpRequestInfo request_info; |
309 request_info.method = "GET"; | 309 request_info.method = "GET"; |
310 request_info.url = GURL("http://www.google.com"); | 310 request_info.url = GURL("http://www.google.com"); |
311 | 311 |
312 Initialize(request_info); | 312 Initialize(request_info); |
313 | 313 |
314 EXPECT_CALL(request_delegate_, | 314 EXPECT_CALL(request_delegate_, |
315 OnStreamFailed(ERR_MANDATORY_PROXY_CONFIGURATION_FAILED, _)) | 315 OnStreamFailed(ERR_MANDATORY_PROXY_CONFIGURATION_FAILED, _)) |
316 .Times(1); | 316 .Times(1); |
317 request_.reset( | 317 request_ = |
318 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 318 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
319 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 319 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
320 | 320 |
321 EXPECT_FALSE(job_controller_->main_job()); | 321 EXPECT_FALSE(job_controller_->main_job()); |
322 EXPECT_FALSE(job_controller_->alternative_job()); | 322 EXPECT_FALSE(job_controller_->alternative_job()); |
323 | 323 |
324 // Make sure calling GetLoadState() when before job creation does not crash. | 324 // Make sure calling GetLoadState() when before job creation does not crash. |
325 // Regression test for crbug.com/723920. | 325 // Regression test for crbug.com/723920. |
326 EXPECT_EQ(LOAD_STATE_IDLE, job_controller_->GetLoadState()); | 326 EXPECT_EQ(LOAD_STATE_IDLE, job_controller_->GetLoadState()); |
327 | 327 |
328 base::RunLoop().RunUntilIdle(); | 328 base::RunLoop().RunUntilIdle(); |
329 request_.reset(); | 329 request_.reset(); |
330 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); | 330 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); |
331 } | 331 } |
332 | 332 |
333 TEST_F(HttpStreamFactoryImplJobControllerTest, ProxyResolutionFailsAsync) { | 333 TEST_F(HttpStreamFactoryImplJobControllerTest, ProxyResolutionFailsAsync) { |
334 ProxyConfig proxy_config; | 334 ProxyConfig proxy_config; |
335 proxy_config.set_pac_url(GURL("http://fooproxyurl")); | 335 proxy_config.set_pac_url(GURL("http://fooproxyurl")); |
336 proxy_config.set_pac_mandatory(true); | 336 proxy_config.set_pac_mandatory(true); |
337 MockAsyncProxyResolverFactory* proxy_resolver_factory = | 337 MockAsyncProxyResolverFactory* proxy_resolver_factory = |
338 new MockAsyncProxyResolverFactory(false); | 338 new MockAsyncProxyResolverFactory(false); |
339 MockAsyncProxyResolver resolver; | 339 MockAsyncProxyResolver resolver; |
340 session_deps_.proxy_service.reset( | 340 session_deps_.proxy_service.reset( |
341 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), | 341 new ProxyService(base::MakeUnique<ProxyConfigServiceFixed>(proxy_config), |
342 base::WrapUnique(proxy_resolver_factory), nullptr)); | 342 base::WrapUnique(proxy_resolver_factory), nullptr)); |
343 HttpRequestInfo request_info; | 343 HttpRequestInfo request_info; |
344 request_info.method = "GET"; | 344 request_info.method = "GET"; |
345 request_info.url = GURL("http://www.google.com"); | 345 request_info.url = GURL("http://www.google.com"); |
346 | 346 |
347 Initialize(request_info); | 347 Initialize(request_info); |
348 | 348 |
349 request_.reset( | 349 request_ = |
350 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 350 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
351 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 351 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
352 | 352 |
353 EXPECT_FALSE(job_controller_->main_job()); | 353 EXPECT_FALSE(job_controller_->main_job()); |
354 EXPECT_FALSE(job_controller_->alternative_job()); | 354 EXPECT_FALSE(job_controller_->alternative_job()); |
355 | 355 |
356 EXPECT_EQ(LOAD_STATE_RESOLVING_PROXY_FOR_URL, | 356 EXPECT_EQ(LOAD_STATE_RESOLVING_PROXY_FOR_URL, |
357 job_controller_->GetLoadState()); | 357 job_controller_->GetLoadState()); |
358 | 358 |
359 EXPECT_CALL(request_delegate_, | 359 EXPECT_CALL(request_delegate_, |
360 OnStreamFailed(ERR_MANDATORY_PROXY_CONFIGURATION_FAILED, _)) | 360 OnStreamFailed(ERR_MANDATORY_PROXY_CONFIGURATION_FAILED, _)) |
361 .Times(1); | 361 .Times(1); |
362 proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder( | 362 proxy_resolver_factory->pending_requests()[0]->CompleteNowWithForwarder( |
363 ERR_FAILED, &resolver); | 363 ERR_FAILED, &resolver); |
364 base::RunLoop().RunUntilIdle(); | 364 base::RunLoop().RunUntilIdle(); |
365 request_.reset(); | 365 request_.reset(); |
366 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); | 366 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); |
367 } | 367 } |
368 | 368 |
369 TEST_F(HttpStreamFactoryImplJobControllerTest, NoSupportedProxies) { | 369 TEST_F(HttpStreamFactoryImplJobControllerTest, NoSupportedProxies) { |
370 session_deps_.proxy_service = | 370 session_deps_.proxy_service = |
371 ProxyService::CreateFixedFromPacResult("QUIC myproxy.org:443"); | 371 ProxyService::CreateFixedFromPacResult("QUIC myproxy.org:443"); |
372 session_deps_.enable_quic = false; | 372 session_deps_.enable_quic = false; |
373 HttpRequestInfo request_info; | 373 HttpRequestInfo request_info; |
374 request_info.method = "GET"; | 374 request_info.method = "GET"; |
375 request_info.url = GURL("http://www.google.com"); | 375 request_info.url = GURL("http://www.google.com"); |
376 | 376 |
377 Initialize(request_info); | 377 Initialize(request_info); |
378 | 378 |
379 EXPECT_CALL(request_delegate_, OnStreamFailed(ERR_NO_SUPPORTED_PROXIES, _)) | 379 EXPECT_CALL(request_delegate_, OnStreamFailed(ERR_NO_SUPPORTED_PROXIES, _)) |
380 .Times(1); | 380 .Times(1); |
381 request_.reset( | 381 request_ = |
382 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 382 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
383 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 383 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
384 | 384 |
385 EXPECT_FALSE(job_controller_->main_job()); | 385 EXPECT_FALSE(job_controller_->main_job()); |
386 EXPECT_FALSE(job_controller_->alternative_job()); | 386 EXPECT_FALSE(job_controller_->alternative_job()); |
387 | 387 |
388 base::RunLoop().RunUntilIdle(); | 388 base::RunLoop().RunUntilIdle(); |
389 request_.reset(); | 389 request_.reset(); |
390 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); | 390 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); |
391 } | 391 } |
392 | 392 |
393 class JobControllerReconsiderProxyAfterErrorTest | 393 class JobControllerReconsiderProxyAfterErrorTest |
(...skipping 12 matching lines...) Expand all Loading... |
406 } | 406 } |
407 | 407 |
408 std::unique_ptr<HttpStreamRequest> CreateJobController( | 408 std::unique_ptr<HttpStreamRequest> CreateJobController( |
409 const HttpRequestInfo& request_info) { | 409 const HttpRequestInfo& request_info) { |
410 HttpStreamFactoryImpl::JobController* job_controller = | 410 HttpStreamFactoryImpl::JobController* job_controller = |
411 new HttpStreamFactoryImpl::JobController( | 411 new HttpStreamFactoryImpl::JobController( |
412 factory_, &request_delegate_, session_.get(), &default_job_factory_, | 412 factory_, &request_delegate_, session_.get(), &default_job_factory_, |
413 request_info, is_preconnect_, enable_ip_based_pooling_, | 413 request_info, is_preconnect_, enable_ip_based_pooling_, |
414 enable_alternative_services_, SSLConfig(), SSLConfig()); | 414 enable_alternative_services_, SSLConfig(), SSLConfig()); |
415 HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller); | 415 HttpStreamFactoryImplPeer::AddJobController(factory_, job_controller); |
416 return base::WrapUnique(job_controller->Start( | 416 return job_controller->Start( |
417 &request_delegate_, nullptr, NetLogWithSource(), | 417 &request_delegate_, nullptr, NetLogWithSource(), |
418 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 418 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
419 } | 419 } |
420 | 420 |
421 private: | 421 private: |
422 // Use real Jobs so that Job::Resume() is not mocked out. When main job is | 422 // Use real Jobs so that Job::Resume() is not mocked out. When main job is |
423 // resumed it will use mock socket data. | 423 // resumed it will use mock socket data. |
424 HttpStreamFactoryImpl::JobFactory default_job_factory_; | 424 HttpStreamFactoryImpl::JobFactory default_job_factory_; |
425 }; | 425 }; |
426 | 426 |
427 INSTANTIATE_TEST_CASE_P( | 427 INSTANTIATE_TEST_CASE_P( |
428 /* no prefix */, | 428 /* no prefix */, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 OnStreamFailedWithNoAlternativeJob) { | 545 OnStreamFailedWithNoAlternativeJob) { |
546 tcp_data_ = base::MakeUnique<SequencedSocketData>(nullptr, 0, nullptr, 0); | 546 tcp_data_ = base::MakeUnique<SequencedSocketData>(nullptr, 0, nullptr, 0); |
547 tcp_data_->set_connect_data(MockConnect(ASYNC, ERR_FAILED)); | 547 tcp_data_->set_connect_data(MockConnect(ASYNC, ERR_FAILED)); |
548 | 548 |
549 HttpRequestInfo request_info; | 549 HttpRequestInfo request_info; |
550 request_info.method = "GET"; | 550 request_info.method = "GET"; |
551 request_info.url = GURL("http://www.google.com"); | 551 request_info.url = GURL("http://www.google.com"); |
552 | 552 |
553 Initialize(request_info); | 553 Initialize(request_info); |
554 | 554 |
555 request_.reset( | 555 request_ = |
556 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 556 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
557 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 557 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
558 | 558 |
559 EXPECT_TRUE(job_controller_->main_job()); | 559 EXPECT_TRUE(job_controller_->main_job()); |
560 EXPECT_FALSE(job_controller_->alternative_job()); | 560 EXPECT_FALSE(job_controller_->alternative_job()); |
561 | 561 |
562 // There's no other alternative job. Thus when stream failed, it should | 562 // There's no other alternative job. Thus when stream failed, it should |
563 // notify Request of the stream failure. | 563 // notify Request of the stream failure. |
564 EXPECT_CALL(request_delegate_, OnStreamFailed(ERR_FAILED, _)).Times(1); | 564 EXPECT_CALL(request_delegate_, OnStreamFailed(ERR_FAILED, _)).Times(1); |
565 base::RunLoop().RunUntilIdle(); | 565 base::RunLoop().RunUntilIdle(); |
566 } | 566 } |
567 | 567 |
568 TEST_F(HttpStreamFactoryImplJobControllerTest, | 568 TEST_F(HttpStreamFactoryImplJobControllerTest, |
569 OnStreamReadyWithNoAlternativeJob) { | 569 OnStreamReadyWithNoAlternativeJob) { |
570 tcp_data_ = base::MakeUnique<SequencedSocketData>(nullptr, 0, nullptr, 0); | 570 tcp_data_ = base::MakeUnique<SequencedSocketData>(nullptr, 0, nullptr, 0); |
571 tcp_data_->set_connect_data(MockConnect(ASYNC, OK)); | 571 tcp_data_->set_connect_data(MockConnect(ASYNC, OK)); |
572 | 572 |
573 HttpRequestInfo request_info; | 573 HttpRequestInfo request_info; |
574 request_info.method = "GET"; | 574 request_info.method = "GET"; |
575 request_info.url = GURL("http://www.google.com"); | 575 request_info.url = GURL("http://www.google.com"); |
576 | 576 |
577 Initialize(request_info); | 577 Initialize(request_info); |
578 | 578 |
579 request_.reset( | 579 request_ = |
580 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 580 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
581 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 581 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
582 | 582 |
583 // There's no other alternative job. Thus when a stream is ready, it should | 583 // There's no other alternative job. Thus when a stream is ready, it should |
584 // notify Request. | 584 // notify Request. |
585 EXPECT_TRUE(job_controller_->main_job()); | 585 EXPECT_TRUE(job_controller_->main_job()); |
586 | 586 |
587 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) | 587 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) |
588 .WillOnce(Invoke(DeleteHttpStreamPointer)); | 588 .WillOnce(Invoke(DeleteHttpStreamPointer)); |
589 base::RunLoop().RunUntilIdle(); | 589 base::RunLoop().RunUntilIdle(); |
590 } | 590 } |
591 | 591 |
(...skipping 10 matching lines...) Expand all Loading... |
602 tcp_data_->set_connect_data(MockConnect(ASYNC, OK)); | 602 tcp_data_->set_connect_data(MockConnect(ASYNC, OK)); |
603 HttpRequestInfo request_info; | 603 HttpRequestInfo request_info; |
604 request_info.method = "GET"; | 604 request_info.method = "GET"; |
605 request_info.url = GURL("https://www.google.com"); | 605 request_info.url = GURL("https://www.google.com"); |
606 | 606 |
607 Initialize(request_info); | 607 Initialize(request_info); |
608 url::SchemeHostPort server(request_info.url); | 608 url::SchemeHostPort server(request_info.url); |
609 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 609 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
610 SetAlternativeService(request_info, alternative_service); | 610 SetAlternativeService(request_info, alternative_service); |
611 | 611 |
612 request_.reset( | 612 request_ = |
613 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 613 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
614 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 614 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
615 EXPECT_TRUE(job_controller_->main_job()); | 615 EXPECT_TRUE(job_controller_->main_job()); |
616 EXPECT_TRUE(job_controller_->alternative_job()); | 616 EXPECT_TRUE(job_controller_->alternative_job()); |
617 | 617 |
618 // Reset the Request will cancel all the Jobs since there's no Job determined | 618 // Reset the Request will cancel all the Jobs since there's no Job determined |
619 // to serve Request yet and JobController will notify the factory to delete | 619 // to serve Request yet and JobController will notify the factory to delete |
620 // itself upon completion. | 620 // itself upon completion. |
621 request_.reset(); | 621 request_.reset(); |
622 VerifyBrokenAlternateProtocolMapping(request_info, false); | 622 VerifyBrokenAlternateProtocolMapping(request_info, false); |
623 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); | 623 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); |
624 } | 624 } |
625 | 625 |
626 TEST_F(HttpStreamFactoryImplJobControllerTest, OnStreamFailedForBothJobs) { | 626 TEST_F(HttpStreamFactoryImplJobControllerTest, OnStreamFailedForBothJobs) { |
627 quic_data_ = base::MakeUnique<test::MockQuicData>(); | 627 quic_data_ = base::MakeUnique<test::MockQuicData>(); |
628 quic_data_->AddConnect(ASYNC, ERR_FAILED); | 628 quic_data_->AddConnect(ASYNC, ERR_FAILED); |
629 tcp_data_ = base::MakeUnique<SequencedSocketData>(nullptr, 0, nullptr, 0); | 629 tcp_data_ = base::MakeUnique<SequencedSocketData>(nullptr, 0, nullptr, 0); |
630 tcp_data_->set_connect_data(MockConnect(ASYNC, ERR_FAILED)); | 630 tcp_data_->set_connect_data(MockConnect(ASYNC, ERR_FAILED)); |
631 | 631 |
632 HttpRequestInfo request_info; | 632 HttpRequestInfo request_info; |
633 request_info.method = "GET"; | 633 request_info.method = "GET"; |
634 request_info.url = GURL("https://www.google.com"); | 634 request_info.url = GURL("https://www.google.com"); |
635 | 635 |
636 Initialize(request_info); | 636 Initialize(request_info); |
637 url::SchemeHostPort server(request_info.url); | 637 url::SchemeHostPort server(request_info.url); |
638 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 638 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
639 SetAlternativeService(request_info, alternative_service); | 639 SetAlternativeService(request_info, alternative_service); |
640 | 640 |
641 request_.reset( | 641 request_ = |
642 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 642 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
643 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 643 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
644 EXPECT_TRUE(job_controller_->main_job()); | 644 EXPECT_TRUE(job_controller_->main_job()); |
645 EXPECT_TRUE(job_controller_->alternative_job()); | 645 EXPECT_TRUE(job_controller_->alternative_job()); |
646 | 646 |
647 // The failure of second Job should be reported to Request as there's no more | 647 // The failure of second Job should be reported to Request as there's no more |
648 // pending Job to serve the Request. | 648 // pending Job to serve the Request. |
649 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(1); | 649 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(1); |
650 base::RunLoop().RunUntilIdle(); | 650 base::RunLoop().RunUntilIdle(); |
651 VerifyBrokenAlternateProtocolMapping(request_info, false); | 651 VerifyBrokenAlternateProtocolMapping(request_info, false); |
652 request_.reset(); | 652 request_.reset(); |
653 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); | 653 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); |
(...skipping 13 matching lines...) Expand all Loading... |
667 | 667 |
668 HttpRequestInfo request_info; | 668 HttpRequestInfo request_info; |
669 request_info.method = "GET"; | 669 request_info.method = "GET"; |
670 request_info.url = GURL("https://www.google.com"); | 670 request_info.url = GURL("https://www.google.com"); |
671 | 671 |
672 Initialize(request_info); | 672 Initialize(request_info); |
673 url::SchemeHostPort server(request_info.url); | 673 url::SchemeHostPort server(request_info.url); |
674 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 674 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
675 SetAlternativeService(request_info, alternative_service); | 675 SetAlternativeService(request_info, alternative_service); |
676 | 676 |
677 request_.reset( | 677 request_ = |
678 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 678 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
679 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 679 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
680 EXPECT_TRUE(job_controller_->main_job()); | 680 EXPECT_TRUE(job_controller_->main_job()); |
681 EXPECT_TRUE(job_controller_->alternative_job()); | 681 EXPECT_TRUE(job_controller_->alternative_job()); |
682 | 682 |
683 // Main job succeeds, starts serving Request and it should report status | 683 // Main job succeeds, starts serving Request and it should report status |
684 // to Request. The alternative job will mark the main job complete and gets | 684 // to Request. The alternative job will mark the main job complete and gets |
685 // orphaned. | 685 // orphaned. |
686 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) | 686 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) |
687 .WillOnce(Invoke(DeleteHttpStreamPointer)); | 687 .WillOnce(Invoke(DeleteHttpStreamPointer)); |
688 // JobController shouldn't report the status of second job as request | 688 // JobController shouldn't report the status of second job as request |
689 // is already successfully served. | 689 // is already successfully served. |
(...skipping 18 matching lines...) Expand all Loading... |
708 | 708 |
709 HttpRequestInfo request_info; | 709 HttpRequestInfo request_info; |
710 request_info.method = "GET"; | 710 request_info.method = "GET"; |
711 request_info.url = GURL("https://www.google.com"); | 711 request_info.url = GURL("https://www.google.com"); |
712 | 712 |
713 Initialize(request_info); | 713 Initialize(request_info); |
714 | 714 |
715 url::SchemeHostPort server(request_info.url); | 715 url::SchemeHostPort server(request_info.url); |
716 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 716 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
717 SetAlternativeService(request_info, alternative_service); | 717 SetAlternativeService(request_info, alternative_service); |
718 request_.reset( | 718 request_ = |
719 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 719 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
720 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 720 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
721 EXPECT_TRUE(job_controller_->main_job()); | 721 EXPECT_TRUE(job_controller_->main_job()); |
722 EXPECT_TRUE(job_controller_->alternative_job()); | 722 EXPECT_TRUE(job_controller_->alternative_job()); |
723 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); | 723 EXPECT_TRUE(JobControllerPeer::main_job_is_blocked(job_controller_)); |
724 | 724 |
725 // |alternative_job| succeeds and should report status to |request_delegate_|. | 725 // |alternative_job| succeeds and should report status to |request_delegate_|. |
726 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) | 726 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) |
727 .WillOnce(Invoke(DeleteHttpStreamPointer)); | 727 .WillOnce(Invoke(DeleteHttpStreamPointer)); |
728 | 728 |
729 base::RunLoop().RunUntilIdle(); | 729 base::RunLoop().RunUntilIdle(); |
730 | 730 |
(...skipping 21 matching lines...) Expand all Loading... |
752 request_info.method = "GET"; | 752 request_info.method = "GET"; |
753 request_info.url = | 753 request_info.url = |
754 GURL(base::StringPrintf("https://%s:%u", origin_host, origin_port)); | 754 GURL(base::StringPrintf("https://%s:%u", origin_host, origin_port)); |
755 Initialize(request_info); | 755 Initialize(request_info); |
756 | 756 |
757 url::SchemeHostPort server(request_info.url); | 757 url::SchemeHostPort server(request_info.url); |
758 AlternativeService alternative_service(kProtoHTTP2, alternative_host, | 758 AlternativeService alternative_service(kProtoHTTP2, alternative_host, |
759 alternative_port); | 759 alternative_port); |
760 SetAlternativeService(request_info, alternative_service); | 760 SetAlternativeService(request_info, alternative_service); |
761 | 761 |
762 request_.reset( | 762 request_ = |
763 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 763 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
764 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 764 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
765 | 765 |
766 HostPortPair main_host_port_pair = | 766 HostPortPair main_host_port_pair = |
767 HttpStreamFactoryImplJobPeer::GetSpdySessionKey( | 767 HttpStreamFactoryImplJobPeer::GetSpdySessionKey( |
768 job_controller_->main_job()) | 768 job_controller_->main_job()) |
769 .host_port_pair(); | 769 .host_port_pair(); |
770 EXPECT_EQ(origin_host, main_host_port_pair.host()); | 770 EXPECT_EQ(origin_host, main_host_port_pair.host()); |
771 EXPECT_EQ(origin_port, main_host_port_pair.port()); | 771 EXPECT_EQ(origin_port, main_host_port_pair.port()); |
772 | 772 |
773 HostPortPair alternative_host_port_pair = | 773 HostPortPair alternative_host_port_pair = |
774 HttpStreamFactoryImplJobPeer::GetSpdySessionKey( | 774 HttpStreamFactoryImplJobPeer::GetSpdySessionKey( |
(...skipping 21 matching lines...) Expand all Loading... |
796 HttpRequestInfo request_info; | 796 HttpRequestInfo request_info; |
797 request_info.method = "GET"; | 797 request_info.method = "GET"; |
798 request_info.url = GURL("https://www.google.com"); | 798 request_info.url = GURL("https://www.google.com"); |
799 | 799 |
800 Initialize(request_info); | 800 Initialize(request_info); |
801 | 801 |
802 url::SchemeHostPort server(request_info.url); | 802 url::SchemeHostPort server(request_info.url); |
803 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 803 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
804 SetAlternativeService(request_info, alternative_service); | 804 SetAlternativeService(request_info, alternative_service); |
805 | 805 |
806 request_.reset( | 806 request_ = |
807 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 807 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
808 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 808 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
809 EXPECT_TRUE(job_controller_->main_job()); | 809 EXPECT_TRUE(job_controller_->main_job()); |
810 EXPECT_TRUE(job_controller_->alternative_job()); | 810 EXPECT_TRUE(job_controller_->alternative_job()); |
811 // main job should not be blocked because alt job returned ERR_IO_PENDING. | 811 // main job should not be blocked because alt job returned ERR_IO_PENDING. |
812 EXPECT_FALSE(JobControllerPeer::main_job_is_blocked(job_controller_)); | 812 EXPECT_FALSE(JobControllerPeer::main_job_is_blocked(job_controller_)); |
813 | 813 |
814 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) | 814 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) |
815 .WillOnce(Invoke(DeleteHttpStreamPointer)); | 815 .WillOnce(Invoke(DeleteHttpStreamPointer)); |
816 | 816 |
817 // Complete main job now. | 817 // Complete main job now. |
818 base::RunLoop().RunUntilIdle(); | 818 base::RunLoop().RunUntilIdle(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
852 | 852 |
853 Initialize(request_info); | 853 Initialize(request_info); |
854 | 854 |
855 url::SchemeHostPort server(request_info.url); | 855 url::SchemeHostPort server(request_info.url); |
856 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 856 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
857 SetAlternativeService(request_info, alternative_service); | 857 SetAlternativeService(request_info, alternative_service); |
858 | 858 |
859 // |main_job| fails but should not report status to Request. | 859 // |main_job| fails but should not report status to Request. |
860 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); | 860 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); |
861 | 861 |
862 request_.reset( | 862 request_ = |
863 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 863 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
864 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 864 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
865 EXPECT_TRUE(job_controller_->main_job()); | 865 EXPECT_TRUE(job_controller_->main_job()); |
866 EXPECT_TRUE(job_controller_->alternative_job()); | 866 EXPECT_TRUE(job_controller_->alternative_job()); |
867 | 867 |
868 base::RunLoop().RunUntilIdle(); | 868 base::RunLoop().RunUntilIdle(); |
869 | 869 |
870 // Make |alternative_job| succeed. | 870 // Make |alternative_job| succeed. |
871 HttpStream* http_stream = | 871 HttpStream* http_stream = |
872 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); | 872 new HttpBasicStream(base::MakeUnique<ClientSocketHandle>(), false, false); |
873 | 873 |
874 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream)) | 874 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, http_stream)) |
(...skipping 22 matching lines...) Expand all Loading... |
897 HttpRequestInfo request_info; | 897 HttpRequestInfo request_info; |
898 request_info.method = "GET"; | 898 request_info.method = "GET"; |
899 request_info.url = GURL("https://www.google.com"); | 899 request_info.url = GURL("https://www.google.com"); |
900 | 900 |
901 Initialize(request_info); | 901 Initialize(request_info); |
902 | 902 |
903 url::SchemeHostPort server(request_info.url); | 903 url::SchemeHostPort server(request_info.url); |
904 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 904 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
905 SetAlternativeService(request_info, alternative_service); | 905 SetAlternativeService(request_info, alternative_service); |
906 | 906 |
907 request_.reset( | 907 request_ = |
908 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 908 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
909 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 909 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
910 EXPECT_TRUE(job_controller_->main_job()); | 910 EXPECT_TRUE(job_controller_->main_job()); |
911 EXPECT_TRUE(job_controller_->alternative_job()); | 911 EXPECT_TRUE(job_controller_->alternative_job()); |
912 | 912 |
913 // |alternative_job| fails but should not report status to Request. | 913 // |alternative_job| fails but should not report status to Request. |
914 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); | 914 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); |
915 // |main_job| succeeds and should report status to Request. | 915 // |main_job| succeeds and should report status to Request. |
916 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) | 916 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) |
917 .WillOnce(Invoke(DeleteHttpStreamPointer)); | 917 .WillOnce(Invoke(DeleteHttpStreamPointer)); |
918 | 918 |
919 base::RunLoop().RunUntilIdle(); | 919 base::RunLoop().RunUntilIdle(); |
(...skipping 21 matching lines...) Expand all Loading... |
941 | 941 |
942 HttpRequestInfo request_info; | 942 HttpRequestInfo request_info; |
943 request_info.method = "GET"; | 943 request_info.method = "GET"; |
944 request_info.url = GURL("https://www.google.com"); | 944 request_info.url = GURL("https://www.google.com"); |
945 Initialize(request_info); | 945 Initialize(request_info); |
946 | 946 |
947 url::SchemeHostPort server(request_info.url); | 947 url::SchemeHostPort server(request_info.url); |
948 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 948 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
949 SetAlternativeService(request_info, alternative_service); | 949 SetAlternativeService(request_info, alternative_service); |
950 | 950 |
951 request_.reset( | 951 request_ = |
952 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 952 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
953 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 953 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
954 EXPECT_TRUE(job_controller_->main_job()); | 954 EXPECT_TRUE(job_controller_->main_job()); |
955 EXPECT_TRUE(job_controller_->alternative_job()); | 955 EXPECT_TRUE(job_controller_->alternative_job()); |
956 | 956 |
957 // |alternative_job| fails but should not report status to Request. | 957 // |alternative_job| fails but should not report status to Request. |
958 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); | 958 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); |
959 // |main_job| succeeds and should report status to Request. | 959 // |main_job| succeeds and should report status to Request. |
960 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) | 960 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) |
961 .WillOnce(Invoke(DeleteHttpStreamPointer)); | 961 .WillOnce(Invoke(DeleteHttpStreamPointer)); |
962 base::RunLoop().RunUntilIdle(); | 962 base::RunLoop().RunUntilIdle(); |
963 | 963 |
(...skipping 19 matching lines...) Expand all Loading... |
983 | 983 |
984 HttpRequestInfo request_info; | 984 HttpRequestInfo request_info; |
985 request_info.method = "GET"; | 985 request_info.method = "GET"; |
986 request_info.url = GURL("https://www.google.com"); | 986 request_info.url = GURL("https://www.google.com"); |
987 | 987 |
988 Initialize(request_info); | 988 Initialize(request_info); |
989 url::SchemeHostPort server(request_info.url); | 989 url::SchemeHostPort server(request_info.url); |
990 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 990 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
991 SetAlternativeService(request_info, alternative_service); | 991 SetAlternativeService(request_info, alternative_service); |
992 | 992 |
993 request_.reset( | 993 request_ = |
994 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 994 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
995 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 995 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
996 EXPECT_TRUE(job_controller_->main_job()); | 996 EXPECT_TRUE(job_controller_->main_job()); |
997 EXPECT_TRUE(job_controller_->alternative_job()); | 997 EXPECT_TRUE(job_controller_->alternative_job()); |
998 | 998 |
999 // |main_job| fails but should not report status to Request. | 999 // |main_job| fails but should not report status to Request. |
1000 // The alternative job will mark the main job complete. | 1000 // The alternative job will mark the main job complete. |
1001 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); | 1001 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); |
1002 | 1002 |
1003 base::RunLoop().RunUntilIdle(); | 1003 base::RunLoop().RunUntilIdle(); |
1004 | 1004 |
1005 // Controller should use alternative job to get load state. | 1005 // Controller should use alternative job to get load state. |
(...skipping 25 matching lines...) Expand all Loading... |
1031 | 1031 |
1032 HttpRequestInfo request_info; | 1032 HttpRequestInfo request_info; |
1033 request_info.method = "GET"; | 1033 request_info.method = "GET"; |
1034 request_info.url = GURL("https://www.google.com"); | 1034 request_info.url = GURL("https://www.google.com"); |
1035 | 1035 |
1036 Initialize(request_info); | 1036 Initialize(request_info); |
1037 url::SchemeHostPort server(request_info.url); | 1037 url::SchemeHostPort server(request_info.url); |
1038 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 1038 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
1039 SetAlternativeService(request_info, alternative_service); | 1039 SetAlternativeService(request_info, alternative_service); |
1040 | 1040 |
1041 request_.reset( | 1041 request_ = |
1042 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 1042 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
1043 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 1043 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
1044 EXPECT_TRUE(job_controller_->main_job()); | 1044 EXPECT_TRUE(job_controller_->main_job()); |
1045 EXPECT_TRUE(job_controller_->alternative_job()); | 1045 EXPECT_TRUE(job_controller_->alternative_job()); |
1046 | 1046 |
1047 // Alt job is stalled and main job should complete successfully. | 1047 // Alt job is stalled and main job should complete successfully. |
1048 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) | 1048 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) |
1049 .WillOnce(Invoke(DeleteHttpStreamPointer)); | 1049 .WillOnce(Invoke(DeleteHttpStreamPointer)); |
1050 | 1050 |
1051 base::RunLoop().RunUntilIdle(); | 1051 base::RunLoop().RunUntilIdle(); |
1052 } | 1052 } |
1053 | 1053 |
1054 TEST_F(HttpStreamFactoryImplJobControllerTest, InvalidPortForQuic) { | 1054 TEST_F(HttpStreamFactoryImplJobControllerTest, InvalidPortForQuic) { |
1055 HttpRequestInfo request_info; | 1055 HttpRequestInfo request_info; |
1056 request_info.method = "GET"; | 1056 request_info.method = "GET"; |
1057 request_info.url = GURL("https://www.google.com"); | 1057 request_info.url = GURL("https://www.google.com"); |
1058 | 1058 |
1059 // Using a restricted port 101 for QUIC should fail and the alternative job | 1059 // Using a restricted port 101 for QUIC should fail and the alternative job |
1060 // should post OnStreamFailedCall on the controller to resume the main job. | 1060 // should post OnStreamFailedCall on the controller to resume the main job. |
1061 Initialize(request_info); | 1061 Initialize(request_info); |
1062 | 1062 |
1063 url::SchemeHostPort server(request_info.url); | 1063 url::SchemeHostPort server(request_info.url); |
1064 AlternativeService alternative_service(kProtoQUIC, server.host(), 101); | 1064 AlternativeService alternative_service(kProtoQUIC, server.host(), 101); |
1065 SetAlternativeService(request_info, alternative_service); | 1065 SetAlternativeService(request_info, alternative_service); |
1066 | 1066 |
1067 request_.reset( | 1067 request_ = |
1068 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 1068 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
1069 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 1069 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
1070 | 1070 |
1071 EXPECT_TRUE(job_factory_.main_job()->is_waiting()); | 1071 EXPECT_TRUE(job_factory_.main_job()->is_waiting()); |
1072 | 1072 |
1073 // Wait until OnStreamFailedCallback is executed on the alternative job. | 1073 // Wait until OnStreamFailedCallback is executed on the alternative job. |
1074 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(1); | 1074 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(1); |
1075 base::RunLoop().RunUntilIdle(); | 1075 base::RunLoop().RunUntilIdle(); |
1076 } | 1076 } |
1077 | 1077 |
1078 TEST_F(HttpStreamFactoryImplJobControllerTest, DelayedTCP) { | 1078 TEST_F(HttpStreamFactoryImplJobControllerTest, DelayedTCP) { |
1079 base::ScopedMockTimeMessageLoopTaskRunner test_task_runner; | 1079 base::ScopedMockTimeMessageLoopTaskRunner test_task_runner; |
(...skipping 13 matching lines...) Expand all Loading... |
1093 quic_stream_factory->set_require_confirmation(false); | 1093 quic_stream_factory->set_require_confirmation(false); |
1094 ServerNetworkStats stats1; | 1094 ServerNetworkStats stats1; |
1095 stats1.srtt = base::TimeDelta::FromMicroseconds(10); | 1095 stats1.srtt = base::TimeDelta::FromMicroseconds(10); |
1096 session_->http_server_properties()->SetServerNetworkStats( | 1096 session_->http_server_properties()->SetServerNetworkStats( |
1097 url::SchemeHostPort(GURL("https://www.google.com")), stats1); | 1097 url::SchemeHostPort(GURL("https://www.google.com")), stats1); |
1098 | 1098 |
1099 url::SchemeHostPort server(request_info.url); | 1099 url::SchemeHostPort server(request_info.url); |
1100 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 1100 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
1101 SetAlternativeService(request_info, alternative_service); | 1101 SetAlternativeService(request_info, alternative_service); |
1102 | 1102 |
1103 request_.reset( | 1103 request_ = |
1104 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 1104 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
1105 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 1105 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
1106 EXPECT_TRUE(job_controller_->main_job()); | 1106 EXPECT_TRUE(job_controller_->main_job()); |
1107 EXPECT_TRUE(job_controller_->alternative_job()); | 1107 EXPECT_TRUE(job_controller_->alternative_job()); |
1108 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); | 1108 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); |
1109 | 1109 |
1110 // The alternative job stalls as host resolution hangs when creating the QUIC | 1110 // The alternative job stalls as host resolution hangs when creating the QUIC |
1111 // request and controller should resume the main job after delay. | 1111 // request and controller should resume the main job after delay. |
1112 EXPECT_TRUE(test_task_runner->HasPendingTask()); | 1112 EXPECT_TRUE(test_task_runner->HasPendingTask()); |
1113 EXPECT_EQ(1u, test_task_runner->GetPendingTaskCount()); | 1113 EXPECT_EQ(1u, test_task_runner->GetPendingTaskCount()); |
1114 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(1); | 1114 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(1); |
1115 test_task_runner->FastForwardBy(base::TimeDelta::FromMicroseconds(15)); | 1115 test_task_runner->FastForwardBy(base::TimeDelta::FromMicroseconds(15)); |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1160 ServerNetworkStats stats1; | 1160 ServerNetworkStats stats1; |
1161 stats1.srtt = base::TimeDelta::FromSeconds(100); | 1161 stats1.srtt = base::TimeDelta::FromSeconds(100); |
1162 session_->http_server_properties()->SetServerNetworkStats( | 1162 session_->http_server_properties()->SetServerNetworkStats( |
1163 url::SchemeHostPort(GURL("https://www.google.com")), stats1); | 1163 url::SchemeHostPort(GURL("https://www.google.com")), stats1); |
1164 | 1164 |
1165 // Set a SPDY alternative service for the server. | 1165 // Set a SPDY alternative service for the server. |
1166 url::SchemeHostPort server(request_info.url); | 1166 url::SchemeHostPort server(request_info.url); |
1167 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 1167 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
1168 SetAlternativeService(request_info, alternative_service); | 1168 SetAlternativeService(request_info, alternative_service); |
1169 | 1169 |
1170 request_.reset( | 1170 request_ = |
1171 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 1171 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
1172 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 1172 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
1173 EXPECT_TRUE(job_controller_->main_job()); | 1173 EXPECT_TRUE(job_controller_->main_job()); |
1174 EXPECT_TRUE(job_controller_->alternative_job()); | 1174 EXPECT_TRUE(job_controller_->alternative_job()); |
1175 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); | 1175 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); |
1176 | 1176 |
1177 // The alternative job stalls as host resolution hangs when creating the QUIC | 1177 // The alternative job stalls as host resolution hangs when creating the QUIC |
1178 // request and controller should resume the main job after delay. | 1178 // request and controller should resume the main job after delay. |
1179 EXPECT_TRUE(test_task_runner->HasPendingTask()); | 1179 EXPECT_TRUE(test_task_runner->HasPendingTask()); |
1180 EXPECT_EQ(1u, test_task_runner->GetPendingTaskCount()); | 1180 EXPECT_EQ(1u, test_task_runner->GetPendingTaskCount()); |
1181 | 1181 |
1182 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(1); | 1182 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(1); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1219 url::SchemeHostPort(GURL("https://www.google.com")), stats1); | 1219 url::SchemeHostPort(GURL("https://www.google.com")), stats1); |
1220 | 1220 |
1221 // Set a SPDY alternative service for the server. | 1221 // Set a SPDY alternative service for the server. |
1222 url::SchemeHostPort server(request_info.url); | 1222 url::SchemeHostPort server(request_info.url); |
1223 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 1223 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
1224 SetAlternativeService(request_info, alternative_service); | 1224 SetAlternativeService(request_info, alternative_service); |
1225 | 1225 |
1226 // The alternative job stalls as host resolution hangs when creating the QUIC | 1226 // The alternative job stalls as host resolution hangs when creating the QUIC |
1227 // request and controller should resume the main job with delay. | 1227 // request and controller should resume the main job with delay. |
1228 // OnStreamFailed should resume the main job immediately. | 1228 // OnStreamFailed should resume the main job immediately. |
1229 request_.reset( | 1229 request_ = |
1230 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 1230 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
1231 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 1231 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
1232 EXPECT_TRUE(job_controller_->main_job()); | 1232 EXPECT_TRUE(job_controller_->main_job()); |
1233 EXPECT_TRUE(job_controller_->alternative_job()); | 1233 EXPECT_TRUE(job_controller_->alternative_job()); |
1234 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); | 1234 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); |
1235 | 1235 |
1236 EXPECT_TRUE(test_task_runner->HasPendingTask()); | 1236 EXPECT_TRUE(test_task_runner->HasPendingTask()); |
1237 EXPECT_EQ(1u, test_task_runner->GetPendingTaskCount()); | 1237 EXPECT_EQ(1u, test_task_runner->GetPendingTaskCount()); |
1238 | 1238 |
1239 // |alternative_job| fails but should not report status to Request. | 1239 // |alternative_job| fails but should not report status to Request. |
1240 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); | 1240 EXPECT_CALL(request_delegate_, OnStreamFailed(_, _)).Times(0); |
1241 // Now unblock Resolver to fail the alternate job. | 1241 // Now unblock Resolver to fail the alternate job. |
(...skipping 22 matching lines...) Expand all Loading... |
1264 // Using hanging resolver will cause the alternative job to hang indefinitely. | 1264 // Using hanging resolver will cause the alternative job to hang indefinitely. |
1265 HangingResolver* resolver = new HangingResolver(); | 1265 HangingResolver* resolver = new HangingResolver(); |
1266 session_deps_.host_resolver.reset(resolver); | 1266 session_deps_.host_resolver.reset(resolver); |
1267 | 1267 |
1268 HttpRequestInfo request_info; | 1268 HttpRequestInfo request_info; |
1269 request_info.method = "GET"; | 1269 request_info.method = "GET"; |
1270 request_info.url = GURL("https://mail.example.org/"); | 1270 request_info.url = GURL("https://mail.example.org/"); |
1271 Initialize(request_info); | 1271 Initialize(request_info); |
1272 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); | 1272 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); |
1273 | 1273 |
1274 request_.reset( | 1274 request_ = |
1275 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 1275 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
1276 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 1276 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
1277 EXPECT_TRUE(job_controller_->main_job()); | 1277 EXPECT_TRUE(job_controller_->main_job()); |
1278 EXPECT_FALSE(job_controller_->main_job()->is_waiting()); | 1278 EXPECT_FALSE(job_controller_->main_job()->is_waiting()); |
1279 EXPECT_FALSE(job_controller_->alternative_job()); | 1279 EXPECT_FALSE(job_controller_->alternative_job()); |
1280 | 1280 |
1281 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); | 1281 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); |
1282 base::RunLoop().RunUntilIdle(); | 1282 base::RunLoop().RunUntilIdle(); |
1283 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations()); | 1283 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations()); |
1284 } | 1284 } |
1285 | 1285 |
1286 // Verifies that the alternative proxy server job is not created if the main job | 1286 // Verifies that the alternative proxy server job is not created if the main job |
1287 // does not fetch the resource through a proxy. | 1287 // does not fetch the resource through a proxy. |
1288 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpURLWithNoProxy) { | 1288 TEST_F(HttpStreamFactoryImplJobControllerTest, HttpURLWithNoProxy) { |
1289 // Using hanging resolver will cause the alternative job to hang indefinitely. | 1289 // Using hanging resolver will cause the alternative job to hang indefinitely. |
1290 HangingResolver* resolver = new HangingResolver(); | 1290 HangingResolver* resolver = new HangingResolver(); |
1291 session_deps_.host_resolver.reset(resolver); | 1291 session_deps_.host_resolver.reset(resolver); |
1292 | 1292 |
1293 HttpRequestInfo request_info; | 1293 HttpRequestInfo request_info; |
1294 request_info.method = "GET"; | 1294 request_info.method = "GET"; |
1295 request_info.url = GURL("http://mail.example.org/"); | 1295 request_info.url = GURL("http://mail.example.org/"); |
1296 | 1296 |
1297 Initialize(request_info); | 1297 Initialize(request_info); |
1298 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); | 1298 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); |
1299 | 1299 |
1300 request_.reset( | 1300 request_ = |
1301 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 1301 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
1302 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 1302 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
1303 EXPECT_TRUE(job_controller_->main_job()); | 1303 EXPECT_TRUE(job_controller_->main_job()); |
1304 EXPECT_FALSE(job_controller_->main_job()->is_waiting()); | 1304 EXPECT_FALSE(job_controller_->main_job()->is_waiting()); |
1305 EXPECT_FALSE(job_controller_->alternative_job()); | 1305 EXPECT_FALSE(job_controller_->alternative_job()); |
1306 | 1306 |
1307 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); | 1307 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(0); |
1308 base::RunLoop().RunUntilIdle(); | 1308 base::RunLoop().RunUntilIdle(); |
1309 | 1309 |
1310 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations()); | 1310 EXPECT_EQ(0, test_proxy_delegate()->get_alternative_proxy_invocations()); |
1311 } | 1311 } |
1312 | 1312 |
(...skipping 19 matching lines...) Expand all Loading... |
1332 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); | 1332 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); |
1333 | 1333 |
1334 // Enable delayed TCP and set time delay for waiting job. | 1334 // Enable delayed TCP and set time delay for waiting job. |
1335 QuicStreamFactory* quic_stream_factory = session_->quic_stream_factory(); | 1335 QuicStreamFactory* quic_stream_factory = session_->quic_stream_factory(); |
1336 quic_stream_factory->set_require_confirmation(false); | 1336 quic_stream_factory->set_require_confirmation(false); |
1337 ServerNetworkStats stats1; | 1337 ServerNetworkStats stats1; |
1338 stats1.srtt = base::TimeDelta::FromMicroseconds(10); | 1338 stats1.srtt = base::TimeDelta::FromMicroseconds(10); |
1339 session_->http_server_properties()->SetServerNetworkStats( | 1339 session_->http_server_properties()->SetServerNetworkStats( |
1340 url::SchemeHostPort(GURL("https://myproxy.org")), stats1); | 1340 url::SchemeHostPort(GURL("https://myproxy.org")), stats1); |
1341 | 1341 |
1342 request_.reset( | 1342 request_ = |
1343 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 1343 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
1344 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 1344 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
1345 EXPECT_TRUE(job_controller_->main_job()); | 1345 EXPECT_TRUE(job_controller_->main_job()); |
1346 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); | 1346 EXPECT_TRUE(job_controller_->main_job()->is_waiting()); |
1347 EXPECT_TRUE(job_controller_->alternative_job()); | 1347 EXPECT_TRUE(job_controller_->alternative_job()); |
1348 // The main job is unblocked but is resumed one message loop iteration later. | 1348 // The main job is unblocked but is resumed one message loop iteration later. |
1349 EXPECT_FALSE(JobControllerPeer::main_job_is_blocked(job_controller_)); | 1349 EXPECT_FALSE(JobControllerPeer::main_job_is_blocked(job_controller_)); |
1350 EXPECT_FALSE(JobControllerPeer::main_job_is_resumed(job_controller_)); | 1350 EXPECT_FALSE(JobControllerPeer::main_job_is_resumed(job_controller_)); |
1351 EXPECT_EQ(1u, test_task_runner->GetPendingTaskCount()); | 1351 EXPECT_EQ(1u, test_task_runner->GetPendingTaskCount()); |
1352 | 1352 |
1353 // Move forward the delay and verify the main job is resumed. | 1353 // Move forward the delay and verify the main job is resumed. |
1354 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(1); | 1354 EXPECT_CALL(*job_factory_.main_job(), Resume()).Times(1); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); | 1388 EXPECT_TRUE(test_proxy_delegate()->alternative_proxy_server().is_quic()); |
1389 | 1389 |
1390 // Enable delayed TCP and set time delay for waiting job. | 1390 // Enable delayed TCP and set time delay for waiting job. |
1391 QuicStreamFactory* quic_stream_factory = session_->quic_stream_factory(); | 1391 QuicStreamFactory* quic_stream_factory = session_->quic_stream_factory(); |
1392 quic_stream_factory->set_require_confirmation(false); | 1392 quic_stream_factory->set_require_confirmation(false); |
1393 ServerNetworkStats stats1; | 1393 ServerNetworkStats stats1; |
1394 stats1.srtt = base::TimeDelta::FromMicroseconds(300 * 1000); | 1394 stats1.srtt = base::TimeDelta::FromMicroseconds(300 * 1000); |
1395 session_->http_server_properties()->SetServerNetworkStats( | 1395 session_->http_server_properties()->SetServerNetworkStats( |
1396 url::SchemeHostPort(GURL("https://myproxy.org")), stats1); | 1396 url::SchemeHostPort(GURL("https://myproxy.org")), stats1); |
1397 | 1397 |
1398 request_.reset( | 1398 request_ = |
1399 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 1399 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
1400 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 1400 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
1401 EXPECT_TRUE(job_controller_->main_job()); | 1401 EXPECT_TRUE(job_controller_->main_job()); |
1402 EXPECT_TRUE(job_controller_->alternative_job()); | 1402 EXPECT_TRUE(job_controller_->alternative_job()); |
1403 | 1403 |
1404 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) | 1404 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) |
1405 .WillOnce(Invoke(DeleteHttpStreamPointer)); | 1405 .WillOnce(Invoke(DeleteHttpStreamPointer)); |
1406 | 1406 |
1407 base::RunLoop().RunUntilIdle(); | 1407 base::RunLoop().RunUntilIdle(); |
1408 | 1408 |
1409 EXPECT_FALSE(job_controller_->alternative_job()); | 1409 EXPECT_FALSE(job_controller_->alternative_job()); |
1410 EXPECT_TRUE(job_controller_->main_job()); | 1410 EXPECT_TRUE(job_controller_->main_job()); |
(...skipping 21 matching lines...) Expand all Loading... |
1432 | 1432 |
1433 UseAlternativeProxy(); | 1433 UseAlternativeProxy(); |
1434 | 1434 |
1435 HttpRequestInfo request_info; | 1435 HttpRequestInfo request_info; |
1436 request_info.method = "GET"; | 1436 request_info.method = "GET"; |
1437 request_info.url = GURL("http://www.google.com"); | 1437 request_info.url = GURL("http://www.google.com"); |
1438 Initialize(request_info); | 1438 Initialize(request_info); |
1439 | 1439 |
1440 url::SchemeHostPort server(request_info.url); | 1440 url::SchemeHostPort server(request_info.url); |
1441 | 1441 |
1442 request_.reset( | 1442 request_ = |
1443 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 1443 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
1444 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 1444 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
1445 EXPECT_TRUE(job_controller_->main_job()); | 1445 EXPECT_TRUE(job_controller_->main_job()); |
1446 EXPECT_TRUE(job_controller_->alternative_job()); | 1446 EXPECT_TRUE(job_controller_->alternative_job()); |
1447 | 1447 |
1448 // Main job succeeds, starts serving Request and it should report status | 1448 // Main job succeeds, starts serving Request and it should report status |
1449 // to Request. The alternative job will mark the main job complete and gets | 1449 // to Request. The alternative job will mark the main job complete and gets |
1450 // orphaned. | 1450 // orphaned. |
1451 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) | 1451 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) |
1452 .WillOnce(Invoke(DeleteHttpStreamPointer)); | 1452 .WillOnce(Invoke(DeleteHttpStreamPointer)); |
1453 | 1453 |
1454 base::RunLoop().RunUntilIdle(); | 1454 base::RunLoop().RunUntilIdle(); |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1532 DisableIPBasedPooling(); | 1532 DisableIPBasedPooling(); |
1533 if (!enable_alternative_services) | 1533 if (!enable_alternative_services) |
1534 DisableAlternativeServices(); | 1534 DisableAlternativeServices(); |
1535 | 1535 |
1536 Initialize(request_info); | 1536 Initialize(request_info); |
1537 | 1537 |
1538 url::SchemeHostPort server(request_info.url); | 1538 url::SchemeHostPort server(request_info.url); |
1539 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); | 1539 AlternativeService alternative_service(kProtoQUIC, server.host(), 443); |
1540 SetAlternativeService(request_info, alternative_service); | 1540 SetAlternativeService(request_info, alternative_service); |
1541 | 1541 |
1542 request_.reset( | 1542 request_ = |
1543 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), | 1543 job_controller_->Start(&request_delegate_, nullptr, NetLogWithSource(), |
1544 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY)); | 1544 HttpStreamRequest::HTTP_STREAM, DEFAULT_PRIORITY); |
1545 EXPECT_TRUE(job_controller_->main_job()); | 1545 EXPECT_TRUE(job_controller_->main_job()); |
1546 if (enable_alternative_services) { | 1546 if (enable_alternative_services) { |
1547 EXPECT_TRUE(job_controller_->alternative_job()); | 1547 EXPECT_TRUE(job_controller_->alternative_job()); |
1548 } else { | 1548 } else { |
1549 EXPECT_FALSE(job_controller_->alternative_job()); | 1549 EXPECT_FALSE(job_controller_->alternative_job()); |
1550 } | 1550 } |
1551 | 1551 |
1552 // |main_job| succeeds and should report status to Request. | 1552 // |main_job| succeeds and should report status to Request. |
1553 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) | 1553 EXPECT_CALL(request_delegate_, OnStreamReady(_, _, _)) |
1554 .WillOnce(Invoke(DeleteHttpStreamPointer)); | 1554 .WillOnce(Invoke(DeleteHttpStreamPointer)); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1621 Preconnect(kNumPreconects); | 1621 Preconnect(kNumPreconects); |
1622 // If experiment is enabled, only 1 stream is requested. | 1622 // If experiment is enabled, only 1 stream is requested. |
1623 EXPECT_EQ( | 1623 EXPECT_EQ( |
1624 (int)actual_num_connects, | 1624 (int)actual_num_connects, |
1625 HttpStreamFactoryImplJobPeer::GetNumStreams(job_controller_->main_job())); | 1625 HttpStreamFactoryImplJobPeer::GetNumStreams(job_controller_->main_job())); |
1626 base::RunLoop().RunUntilIdle(); | 1626 base::RunLoop().RunUntilIdle(); |
1627 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); | 1627 EXPECT_TRUE(HttpStreamFactoryImplPeer::IsJobControllerDeleted(factory_)); |
1628 } | 1628 } |
1629 | 1629 |
1630 } // namespace net | 1630 } // namespace net |
OLD | NEW |