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

Side by Side Diff: content/browser/loader/resource_dispatcher_host_unittest.cc

Issue 2005273002: Move MimeTypeResourceHandler before ThrottlingResourceHandler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 response_data, 423 response_data,
424 auto_advance) {} 424 auto_advance) {}
425 425
426 protected: 426 protected:
427 ~URLRequestTestDelayedCompletionJob() override {} 427 ~URLRequestTestDelayedCompletionJob() override {}
428 428
429 private: 429 private:
430 bool NextReadAsync() override { return true; } 430 bool NextReadAsync() override { return true; }
431 }; 431 };
432 432
433 // This class is a variation on URLRequestTestJob that ensures that no read is
434 // asked of this job.
435 class URLRequestMustNotReadTestJob : public net::URLRequestTestJob {
436 public:
437 URLRequestMustNotReadTestJob(net::URLRequest* request,
438 net::NetworkDelegate* network_delegate,
439 const std::string& response_headers,
440 const std::string& response_data)
441 : net::URLRequestTestJob(request,
442 network_delegate,
443 response_headers,
444 response_data,
445 false) {}
446
447 int ReadRawData(net::IOBuffer* buf, int buf_size) override {
448 EXPECT_TRUE(false) << "The job should have been cancelled before trying to "
449 "read the response body.";
450 return 0;
451 }
452 };
453
433 class URLRequestBigJob : public net::URLRequestSimpleJob { 454 class URLRequestBigJob : public net::URLRequestSimpleJob {
434 public: 455 public:
435 URLRequestBigJob(net::URLRequest* request, 456 URLRequestBigJob(net::URLRequest* request,
436 net::NetworkDelegate* network_delegate) 457 net::NetworkDelegate* network_delegate)
437 : net::URLRequestSimpleJob(request, network_delegate) { 458 : net::URLRequestSimpleJob(request, network_delegate) {
438 } 459 }
439 460
440 // URLRequestSimpleJob implementation: 461 // URLRequestSimpleJob implementation:
441 int GetData(std::string* mime_type, 462 int GetData(std::string* mime_type,
442 std::string* charset, 463 std::string* charset,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
518 539
519 class ResourceDispatcherHostTest; 540 class ResourceDispatcherHostTest;
520 541
521 class TestURLRequestJobFactory : public net::URLRequestJobFactory { 542 class TestURLRequestJobFactory : public net::URLRequestJobFactory {
522 public: 543 public:
523 explicit TestURLRequestJobFactory(ResourceDispatcherHostTest* test_fixture) 544 explicit TestURLRequestJobFactory(ResourceDispatcherHostTest* test_fixture)
524 : test_fixture_(test_fixture), 545 : test_fixture_(test_fixture),
525 hang_after_start_(false), 546 hang_after_start_(false),
526 delay_start_(false), 547 delay_start_(false),
527 delay_complete_(false), 548 delay_complete_(false),
528 url_request_jobs_created_count_(0) { 549 must_not_read_(false),
529 } 550 url_request_jobs_created_count_(0) {}
530 551
531 void HandleScheme(const std::string& scheme) { 552 void HandleScheme(const std::string& scheme) {
532 supported_schemes_.insert(scheme); 553 supported_schemes_.insert(scheme);
533 } 554 }
534 555
535 int url_request_jobs_created_count() const { 556 int url_request_jobs_created_count() const {
536 return url_request_jobs_created_count_; 557 return url_request_jobs_created_count_;
537 } 558 }
538 559
539 // When set, jobs will hang eternally once started. 560 // When set, jobs will hang eternally once started.
540 void SetHangAfterStartJobGeneration(bool hang_after_start) { 561 void SetHangAfterStartJobGeneration(bool hang_after_start) {
541 hang_after_start_ = hang_after_start; 562 hang_after_start_ = hang_after_start;
542 } 563 }
543 564
544 void SetDelayedStartJobGeneration(bool delay_job_start) { 565 void SetDelayedStartJobGeneration(bool delay_job_start) {
545 delay_start_ = delay_job_start; 566 delay_start_ = delay_job_start;
546 } 567 }
547 568
548 void SetDelayedCompleteJobGeneration(bool delay_job_complete) { 569 void SetDelayedCompleteJobGeneration(bool delay_job_complete) {
549 delay_complete_ = delay_job_complete; 570 delay_complete_ = delay_job_complete;
550 } 571 }
551 572
573 void SetMustNotReadJobGeneration(bool must_not_read) {
574 must_not_read_ = must_not_read;
575 }
576
552 net::URLRequestJob* MaybeCreateJobWithProtocolHandler( 577 net::URLRequestJob* MaybeCreateJobWithProtocolHandler(
553 const std::string& scheme, 578 const std::string& scheme,
554 net::URLRequest* request, 579 net::URLRequest* request,
555 net::NetworkDelegate* network_delegate) const override; 580 net::NetworkDelegate* network_delegate) const override;
556 581
557 net::URLRequestJob* MaybeInterceptRedirect( 582 net::URLRequestJob* MaybeInterceptRedirect(
558 net::URLRequest* request, 583 net::URLRequest* request,
559 net::NetworkDelegate* network_delegate, 584 net::NetworkDelegate* network_delegate,
560 const GURL& location) const override; 585 const GURL& location) const override;
561 586
(...skipping 11 matching lines...) Expand all
573 598
574 bool IsSafeRedirectTarget(const GURL& location) const override { 599 bool IsSafeRedirectTarget(const GURL& location) const override {
575 return false; 600 return false;
576 } 601 }
577 602
578 private: 603 private:
579 ResourceDispatcherHostTest* test_fixture_; 604 ResourceDispatcherHostTest* test_fixture_;
580 bool hang_after_start_; 605 bool hang_after_start_;
581 bool delay_start_; 606 bool delay_start_;
582 bool delay_complete_; 607 bool delay_complete_;
608 bool must_not_read_;
583 mutable int url_request_jobs_created_count_; 609 mutable int url_request_jobs_created_count_;
584 std::set<std::string> supported_schemes_; 610 std::set<std::string> supported_schemes_;
585 611
586 DISALLOW_COPY_AND_ASSIGN(TestURLRequestJobFactory); 612 DISALLOW_COPY_AND_ASSIGN(TestURLRequestJobFactory);
587 }; 613 };
588 614
589 // Associated with an URLRequest to determine if the URLRequest gets deleted. 615 // Associated with an URLRequest to determine if the URLRequest gets deleted.
590 class TestUserData : public base::SupportsUserData::Data { 616 class TestUserData : public base::SupportsUserData::Data {
591 public: 617 public:
592 explicit TestUserData(bool* was_deleted) 618 explicit TestUserData(bool* was_deleted)
(...skipping 10 matching lines...) Expand all
603 : public TestContentBrowserClient { 629 : public TestContentBrowserClient {
604 public: 630 public:
605 bool ShouldSwapProcessesForRedirect(ResourceContext* resource_context, 631 bool ShouldSwapProcessesForRedirect(ResourceContext* resource_context,
606 const GURL& current_url, 632 const GURL& current_url,
607 const GURL& new_url) override { 633 const GURL& new_url) override {
608 return true; 634 return true;
609 } 635 }
610 }; 636 };
611 637
612 enum GenericResourceThrottleFlags { 638 enum GenericResourceThrottleFlags {
613 NONE = 0, 639 NONE = 0,
614 DEFER_STARTING_REQUEST = 1 << 0, 640 DEFER_STARTING_REQUEST = 1 << 0,
615 DEFER_PROCESSING_RESPONSE = 1 << 1, 641 DEFER_PROCESSING_RESPONSE = 1 << 1,
616 CANCEL_BEFORE_START = 1 << 2 642 CANCEL_BEFORE_START = 1 << 2,
643 CANCEL_PROCESSING_RESPONSE = 1 << 3,
644 MUST_NOT_CACHE_BODY = 1 << 4,
617 }; 645 };
618 646
619 // Throttle that tracks the current throttle blocking a request. Only one 647 // Throttle that tracks the current throttle blocking a request. Only one
620 // can throttle any request at a time. 648 // can throttle any request at a time.
621 class GenericResourceThrottle : public ResourceThrottle { 649 class GenericResourceThrottle : public ResourceThrottle {
622 public: 650 public:
623 // The value is used to indicate that the throttle should not provide 651 // The value is used to indicate that the throttle should not provide
624 // a error code when cancelling a request. net::OK is used, because this 652 // a error code when cancelling a request. net::OK is used, because this
625 // is not an error code. 653 // is not an error code.
626 static const int USE_DEFAULT_CANCEL_ERROR_CODE = net::OK; 654 static const int USE_DEFAULT_CANCEL_ERROR_CODE = net::OK;
(...skipping 24 matching lines...) Expand all
651 } 679 }
652 } 680 }
653 } 681 }
654 682
655 void WillProcessResponse(bool* defer) override { 683 void WillProcessResponse(bool* defer) override {
656 ASSERT_EQ(NULL, active_throttle_); 684 ASSERT_EQ(NULL, active_throttle_);
657 if (flags_ & DEFER_PROCESSING_RESPONSE) { 685 if (flags_ & DEFER_PROCESSING_RESPONSE) {
658 active_throttle_ = this; 686 active_throttle_ = this;
659 *defer = true; 687 *defer = true;
660 } 688 }
689
690 if (flags_ & CANCEL_PROCESSING_RESPONSE) {
691 if (error_code_for_cancellation_ == USE_DEFAULT_CANCEL_ERROR_CODE) {
692 controller()->Cancel();
693 } else {
694 controller()->CancelWithError(error_code_for_cancellation_);
695 }
696 }
661 } 697 }
662 698
663 const char* GetNameForLogging() const override { 699 const char* GetNameForLogging() const override {
664 return "GenericResourceThrottle"; 700 return "GenericResourceThrottle";
665 } 701 }
666 702
667 void Resume() { 703 void Resume() {
668 ASSERT_TRUE(this == active_throttle_); 704 ASSERT_TRUE(this == active_throttle_);
669 active_throttle_ = NULL; 705 active_throttle_ = NULL;
670 controller()->Resume(); 706 controller()->Resume();
671 } 707 }
672 708
673 static GenericResourceThrottle* active_throttle() { 709 static GenericResourceThrottle* active_throttle() {
674 return active_throttle_; 710 return active_throttle_;
675 } 711 }
676 712
713 bool MustProcessResponseBeforeReadingBody() override {
714 return flags_ & MUST_NOT_CACHE_BODY;
715 }
716
677 private: 717 private:
678 int flags_; // bit-wise union of GenericResourceThrottleFlags. 718 int flags_; // bit-wise union of GenericResourceThrottleFlags.
679 int error_code_for_cancellation_; 719 int error_code_for_cancellation_;
680 720
681 // The currently active throttle, if any. 721 // The currently active throttle, if any.
682 static GenericResourceThrottle* active_throttle_; 722 static GenericResourceThrottle* active_throttle_;
683 }; 723 };
684 // static 724 // static
685 GenericResourceThrottle* GenericResourceThrottle::active_throttle_ = NULL; 725 GenericResourceThrottle* GenericResourceThrottle::active_throttle_ = NULL;
686 726
(...skipping 1811 matching lines...) Expand 10 before | Expand all | Expand 10 after
2498 SetResponse(raw_headers, response_data); 2538 SetResponse(raw_headers, response_data);
2499 job_factory_->SetDelayedCompleteJobGeneration(true); 2539 job_factory_->SetDelayedCompleteJobGeneration(true);
2500 HandleScheme("http"); 2540 HandleScheme("http");
2501 2541
2502 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 2542 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
2503 GURL("http://example.com/blah"), 2543 GURL("http://example.com/blah"),
2504 RESOURCE_TYPE_MAIN_FRAME); 2544 RESOURCE_TYPE_MAIN_FRAME);
2505 // Return some data so that the request is identified as a download 2545 // Return some data so that the request is identified as a download
2506 // and the proper resource handlers are created. 2546 // and the proper resource handlers are created.
2507 EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage()); 2547 EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage());
2548 base::RunLoop().RunUntilIdle();
2508 2549
2509 // And now simulate a cancellation coming from the renderer. 2550 // And now simulate a cancellation coming from the renderer.
2510 ResourceHostMsg_CancelRequest msg(request_id); 2551 ResourceHostMsg_CancelRequest msg(request_id);
2511 host_.OnMessageReceived(msg, filter_.get()); 2552 host_.OnMessageReceived(msg, filter_.get());
2512 2553
2513 // Since the request had already started processing as a download, 2554 // Since the request had already started processing as a download,
2514 // the cancellation above should have been ignored and the request 2555 // the cancellation above should have been ignored and the request
2515 // should still be alive. 2556 // should still be alive.
2516 EXPECT_EQ(1, host_.pending_requests()); 2557 EXPECT_EQ(1, host_.pending_requests());
2517 2558
2518 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2559 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2560 base::RunLoop().RunUntilIdle();
2519 } 2561 }
2520 2562
2521 TEST_P(ResourceDispatcherHostTest, CancelRequestsForContext) { 2563 TEST_P(ResourceDispatcherHostTest, CancelRequestsForContext) {
2522 EXPECT_EQ(0, host_.pending_requests()); 2564 EXPECT_EQ(0, host_.pending_requests());
2523 2565
2524 int render_view_id = 0; 2566 int render_view_id = 0;
2525 int request_id = 1; 2567 int request_id = 1;
2526 2568
2527 std::string raw_headers("HTTP\n" 2569 std::string raw_headers("HTTP\n"
2528 "Content-disposition: attachment; filename=foo\n\n"); 2570 "Content-disposition: attachment; filename=foo\n\n");
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
2569 EXPECT_EQ(0, host_.pending_requests()); 2611 EXPECT_EQ(0, host_.pending_requests());
2570 2612
2571 base::RunLoop().RunUntilIdle(); 2613 base::RunLoop().RunUntilIdle();
2572 } else { 2614 } else {
2573 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 2615 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
2574 download_url, RESOURCE_TYPE_MAIN_FRAME); 2616 download_url, RESOURCE_TYPE_MAIN_FRAME);
2575 2617
2576 // Return some data so that the request is identified as a download 2618 // Return some data so that the request is identified as a download
2577 // and the proper resource handlers are created. 2619 // and the proper resource handlers are created.
2578 EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage()); 2620 EXPECT_TRUE(net::URLRequestTestJob::ProcessOnePendingMessage());
2621 base::RunLoop().RunUntilIdle();
2579 2622
2580 // And now simulate a cancellation coming from the renderer. 2623 // And now simulate a cancellation coming from the renderer.
2581 ResourceHostMsg_CancelRequest msg(request_id); 2624 ResourceHostMsg_CancelRequest msg(request_id);
2582 host_.OnMessageReceived(msg, filter_.get()); 2625 host_.OnMessageReceived(msg, filter_.get());
2583 2626
2584 // Since the request had already started processing as a download, 2627 // Since the request had already started processing as a download,
2585 // the cancellation above should have been ignored and the request 2628 // the cancellation above should have been ignored and the request
2586 // should still be alive. 2629 // should still be alive.
2587 EXPECT_EQ(1, host_.pending_requests()); 2630 EXPECT_EQ(1, host_.pending_requests());
2588 2631
2589 // Cancelling by other methods shouldn't work either. 2632 // Cancelling by other methods shouldn't work either.
2590 host_.CancelRequestsForProcess(render_view_id); 2633 host_.CancelRequestsForProcess(render_view_id);
2591 EXPECT_EQ(1, host_.pending_requests()); 2634 EXPECT_EQ(1, host_.pending_requests());
2592 2635
2593 // Cancelling by context should work. 2636 // Cancelling by context should work.
2594 host_.CancelRequestsForContext(filter_->resource_context()); 2637 host_.CancelRequestsForContext(filter_->resource_context());
2595 EXPECT_EQ(0, host_.pending_requests()); 2638 EXPECT_EQ(0, host_.pending_requests());
2639
2640 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {
2641 }
2642 base::RunLoop().RunUntilIdle();
2596 } 2643 }
2597 } 2644 }
2598 2645
2599 TEST_P(ResourceDispatcherHostTest, CancelRequestsForContextDetached) { 2646 TEST_P(ResourceDispatcherHostTest, CancelRequestsForContextDetached) {
2600 EXPECT_EQ(0, host_.pending_requests()); 2647 EXPECT_EQ(0, host_.pending_requests());
2601 2648
2602 int render_view_id = 0; 2649 int render_view_id = 0;
2603 int request_id = 1; 2650 int request_id = 1;
2604 2651
2605 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 2652 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
2957 SetResponse("HTTP/1.1 200 OK\n" 3004 SetResponse("HTTP/1.1 200 OK\n"
2958 "Content-Type: text/plain\n\n", 3005 "Content-Type: text/plain\n\n",
2959 kResponseBody); 3006 kResponseBody);
2960 ResourceHostMsg_FollowRedirect redirect_msg(request_id); 3007 ResourceHostMsg_FollowRedirect redirect_msg(request_id);
2961 host_.OnMessageReceived(redirect_msg, filter_.get()); 3008 host_.OnMessageReceived(redirect_msg, filter_.get());
2962 base::RunLoop().RunUntilIdle(); 3009 base::RunLoop().RunUntilIdle();
2963 3010
2964 // Flush all the pending requests to get the response through the 3011 // Flush all the pending requests to get the response through the
2965 // MimeTypeResourceHandler. 3012 // MimeTypeResourceHandler.
2966 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 3013 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
3014 base::RunLoop().RunUntilIdle();
2967 3015
2968 // Restore, now that we've set up a transfer. 3016 // Restore, now that we've set up a transfer.
2969 SetBrowserClientForTesting(old_client); 3017 SetBrowserClientForTesting(old_client);
2970 3018
2971 // This second filter is used to emulate a second process. 3019 // This second filter is used to emulate a second process.
2972 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 3020 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2973 3021
2974 int new_render_view_id = 1; 3022 int new_render_view_id = 1;
2975 int new_request_id = 2; 3023 int new_request_id = 2;
2976 3024
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
3125 SetResponse("HTTP/1.1 200 OK\n" 3173 SetResponse("HTTP/1.1 200 OK\n"
3126 "Content-Type: text/plain\n\n", 3174 "Content-Type: text/plain\n\n",
3127 kResponseBody); 3175 kResponseBody);
3128 ResourceHostMsg_FollowRedirect redirect_msg2(request_id); 3176 ResourceHostMsg_FollowRedirect redirect_msg2(request_id);
3129 host_.OnMessageReceived(redirect_msg2, filter_.get()); 3177 host_.OnMessageReceived(redirect_msg2, filter_.get());
3130 base::RunLoop().RunUntilIdle(); 3178 base::RunLoop().RunUntilIdle();
3131 3179
3132 // Flush all the pending requests to get the response through the 3180 // Flush all the pending requests to get the response through the
3133 // MimeTypeResourceHandler. 3181 // MimeTypeResourceHandler.
3134 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 3182 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
3183 base::RunLoop().RunUntilIdle();
3135 3184
3136 // Restore. 3185 // Restore.
3137 SetBrowserClientForTesting(old_client); 3186 SetBrowserClientForTesting(old_client);
3138 3187
3139 // This second filter is used to emulate a second process. 3188 // This second filter is used to emulate a second process.
3140 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 3189 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
3141 3190
3142 int new_render_view_id = 1; 3191 int new_render_view_id = 1;
3143 int new_request_id = 2; 3192 int new_request_id = 2;
3144 3193
(...skipping 586 matching lines...) Expand 10 before | Expand all | Expand 10 after
3731 TEST_P(ResourceDispatcherHostTest, TransferRequestRedirectedDownload) { 3780 TEST_P(ResourceDispatcherHostTest, TransferRequestRedirectedDownload) {
3732 int initial_count(web_contents_observer_->resource_request_redirect_count()); 3781 int initial_count(web_contents_observer_->resource_request_redirect_count());
3733 3782
3734 MakeWebContentsAssociatedDownloadRequest( 3783 MakeWebContentsAssociatedDownloadRequest(
3735 1, net::URLRequestTestJob::test_url_redirect_to_url_2()); 3784 1, net::URLRequestTestJob::test_url_redirect_to_url_2());
3736 base::RunLoop().RunUntilIdle(); 3785 base::RunLoop().RunUntilIdle();
3737 EXPECT_EQ(initial_count, 3786 EXPECT_EQ(initial_count,
3738 web_contents_observer_->resource_request_redirect_count()); 3787 web_contents_observer_->resource_request_redirect_count());
3739 } 3788 }
3740 3789
3790 // Tests that a ResourceThrottle that needs to process the response before any
3791 // part of the body is read can do so.
3792 TEST_P(ResourceDispatcherHostTest, ThrottleMustProcessResponseBeforeRead) {
3793 // Ensure all jobs will check that no read operation is called.
3794 job_factory_->SetMustNotReadJobGeneration(true);
3795 HandleScheme("http");
3796
3797 // Create a ResourceThrottle that must process the response before any part of
3798 // the body is read. This throttle will also cancel the request in
3799 // WillProcessResponse.
3800 TestResourceDispatcherHostDelegate delegate;
3801 int throttle_flags = CANCEL_PROCESSING_RESPONSE | MUST_NOT_CACHE_BODY;
3802 delegate.set_flags(throttle_flags);
3803 host_.SetDelegate(&delegate);
3804
3805 // This response should normally result in the MIME type being sniffed, which
3806 // requires reading the body.
3807 std::string raw_headers(
3808 "HTTP/1.1 200 OK\n"
3809 "Content-Type: text/plain; charset=utf-8\n\n");
3810 std::string response_data("p { text-align: center; }");
3811 SetResponse(raw_headers, response_data);
3812
3813 MakeTestRequestWithResourceType(filter_.get(), filter_->child_id(), 1,
3814 GURL("http://example.com/blah"),
3815 RESOURCE_TYPE_STYLESHEET);
3816
3817 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {
3818 }
3819 base::RunLoop().RunUntilIdle();
3820 }
3821
3741 // A URLRequestTestJob that sets a test certificate on the |ssl_info| 3822 // A URLRequestTestJob that sets a test certificate on the |ssl_info|
3742 // field of the response. 3823 // field of the response.
3743 class TestHTTPSURLRequestJob : public net::URLRequestTestJob { 3824 class TestHTTPSURLRequestJob : public net::URLRequestTestJob {
3744 public: 3825 public:
3745 TestHTTPSURLRequestJob(net::URLRequest* request, 3826 TestHTTPSURLRequestJob(net::URLRequest* request,
3746 net::NetworkDelegate* network_delegate, 3827 net::NetworkDelegate* network_delegate,
3747 const std::string& response_headers, 3828 const std::string& response_headers,
3748 const std::string& response_data, 3829 const std::string& response_data,
3749 bool auto_advance) 3830 bool auto_advance)
3750 : net::URLRequestTestJob(request, 3831 : net::URLRequestTestJob(request,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3794 if (delay_start_) { 3875 if (delay_start_) {
3795 return new URLRequestTestDelayedStartJob( 3876 return new URLRequestTestDelayedStartJob(
3796 request, network_delegate, 3877 request, network_delegate,
3797 test_fixture_->response_headers_, test_fixture_->response_data_, 3878 test_fixture_->response_headers_, test_fixture_->response_data_,
3798 false); 3879 false);
3799 } else if (delay_complete_) { 3880 } else if (delay_complete_) {
3800 return new URLRequestTestDelayedCompletionJob( 3881 return new URLRequestTestDelayedCompletionJob(
3801 request, network_delegate, 3882 request, network_delegate,
3802 test_fixture_->response_headers_, test_fixture_->response_data_, 3883 test_fixture_->response_headers_, test_fixture_->response_data_,
3803 false); 3884 false);
3885 } else if (must_not_read_) {
3886 return new URLRequestMustNotReadTestJob(request, network_delegate,
3887 test_fixture_->response_headers_,
3888 test_fixture_->response_data_);
3804 } else if (test_fixture_->use_test_ssl_certificate_) { 3889 } else if (test_fixture_->use_test_ssl_certificate_) {
3805 return new TestHTTPSURLRequestJob(request, network_delegate, 3890 return new TestHTTPSURLRequestJob(request, network_delegate,
3806 test_fixture_->response_headers_, 3891 test_fixture_->response_headers_,
3807 test_fixture_->response_data_, false); 3892 test_fixture_->response_data_, false);
3808 } else { 3893 } else {
3809 return new net::URLRequestTestJob( 3894 return new net::URLRequestTestJob(
3810 request, network_delegate, test_fixture_->response_headers_, 3895 request, network_delegate, test_fixture_->response_headers_,
3811 test_fixture_->response_data_, test_fixture_->auto_advance_); 3896 test_fixture_->response_data_, test_fixture_->auto_advance_);
3812 } 3897 }
3813 } 3898 }
(...skipping 12 matching lines...) Expand all
3826 return nullptr; 3911 return nullptr;
3827 } 3912 }
3828 3913
3829 INSTANTIATE_TEST_CASE_P( 3914 INSTANTIATE_TEST_CASE_P(
3830 ResourceDispatcherHostTests, 3915 ResourceDispatcherHostTests,
3831 ResourceDispatcherHostTest, 3916 ResourceDispatcherHostTest,
3832 testing::Values(TestConfig::kDefault, 3917 testing::Values(TestConfig::kDefault,
3833 TestConfig::kOptimizeIPCForSmallResourceEnabled)); 3918 TestConfig::kOptimizeIPCForSmallResourceEnabled));
3834 3919
3835 } // namespace content 3920 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.cc ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698