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

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

Issue 2469673002: Invalidate WeakPtrs of ResourceMessageFilter on channel shutdown (Closed)
Patch Set: rebase Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 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 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
853 base::RunLoop().RunUntilIdle(); 853 base::RunLoop().RunUntilIdle();
854 filter_ = MakeForwardingFilter(); 854 filter_ = MakeForwardingFilter();
855 // TODO(cbentzel): Better way to get URLRequestContext? 855 // TODO(cbentzel): Better way to get URLRequestContext?
856 net::URLRequestContext* request_context = 856 net::URLRequestContext* request_context =
857 browser_context_->GetResourceContext()->GetRequestContext(); 857 browser_context_->GetResourceContext()->GetRequestContext();
858 job_factory_.reset(new TestURLRequestJobFactory(this)); 858 job_factory_.reset(new TestURLRequestJobFactory(this));
859 request_context->set_job_factory(job_factory_.get()); 859 request_context->set_job_factory(job_factory_.get());
860 request_context->set_network_delegate(&network_delegate_); 860 request_context->set_network_delegate(&network_delegate_);
861 } 861 }
862 862
863 ~ResourceDispatcherHostTest() {
mmenke 2016/11/09 18:34:19 override?
tzik 2016/11/10 06:08:14 Done.
864 filter_->OnChannelClosing();
865 }
866
863 // IPC::Sender implementation 867 // IPC::Sender implementation
864 bool Send(IPC::Message* msg) override { 868 bool Send(IPC::Message* msg) override {
865 accum_.AddMessage(*msg); 869 accum_.AddMessage(*msg);
866 870
867 if (send_data_received_acks_ && 871 if (send_data_received_acks_ &&
868 msg->type() == ResourceMsg_DataReceived::ID) { 872 msg->type() == ResourceMsg_DataReceived::ID) {
869 GenerateDataReceivedACK(*msg); 873 GenerateDataReceivedACK(*msg);
870 } 874 }
871 875
872 if (wait_for_request_complete_loop_ && 876 if (wait_for_request_complete_loop_ &&
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 features::kOptimizeLoadingIPCForSmallResources.name, std::string()); 912 features::kOptimizeLoadingIPCForSmallResources.name, std::string());
909 base::FeatureList::SetInstance(std::move(feature_list)); 913 base::FeatureList::SetInstance(std::move(feature_list));
910 ASSERT_TRUE(base::FeatureList::IsEnabled( 914 ASSERT_TRUE(base::FeatureList::IsEnabled(
911 features::kOptimizeLoadingIPCForSmallResources)); 915 features::kOptimizeLoadingIPCForSmallResources));
912 break; 916 break;
913 } 917 }
914 } 918 }
915 } 919 }
916 920
917 void TearDown() override { 921 void TearDown() override {
922 web_contents_filter_->OnChannelClosing();
918 web_contents_observer_.reset(); 923 web_contents_observer_.reset();
919 web_contents_.reset(); 924 web_contents_.reset();
920 925
921 EXPECT_TRUE(URLRequestTestDelayedStartJob::DelayedStartQueueEmpty()); 926 EXPECT_TRUE(URLRequestTestDelayedStartJob::DelayedStartQueueEmpty());
922 URLRequestTestDelayedStartJob::ClearQueue(); 927 URLRequestTestDelayedStartJob::ClearQueue();
923 928
924 for (std::set<int>::iterator it = child_ids_.begin(); 929 for (std::set<int>::iterator it = child_ids_.begin();
925 it != child_ids_.end(); ++it) { 930 it != child_ids_.end(); ++it) {
926 host_.CancelRequestsForProcess(*it); 931 host_.CancelRequestsForProcess(*it);
927 } 932 }
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
1887 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_2()); 1892 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_2());
1888 // The detachable request was cancelled by the renderer before it 1893 // The detachable request was cancelled by the renderer before it
1889 // finished. From the perspective of the renderer, it should have cancelled. 1894 // finished. From the perspective of the renderer, it should have cancelled.
1890 ASSERT_EQ(2U, msgs[1].size()); 1895 ASSERT_EQ(2U, msgs[1].size());
1891 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[1][0].type()); 1896 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[1][0].type());
1892 CheckRequestCompleteErrorCode(msgs[1][1], net::ERR_ABORTED); 1897 CheckRequestCompleteErrorCode(msgs[1][1], net::ERR_ABORTED);
1893 // But it completed anyway. For the network stack, no requests were canceled. 1898 // But it completed anyway. For the network stack, no requests were canceled.
1894 EXPECT_EQ(4, network_delegate()->completed_requests()); 1899 EXPECT_EQ(4, network_delegate()->completed_requests());
1895 EXPECT_EQ(0, network_delegate()->canceled_requests()); 1900 EXPECT_EQ(0, network_delegate()->canceled_requests());
1896 EXPECT_EQ(0, network_delegate()->error_count()); 1901 EXPECT_EQ(0, network_delegate()->error_count());
1902
1903 test_filter->OnChannelClosing();
1897 } 1904 }
1898 1905
1899 // Tests whether the correct requests get canceled when a RenderViewHost is 1906 // Tests whether the correct requests get canceled when a RenderViewHost is
1900 // deleted. 1907 // deleted.
1901 TEST_P(ResourceDispatcherHostTest, CancelRequestsOnRenderFrameDeleted) { 1908 TEST_P(ResourceDispatcherHostTest, CancelRequestsOnRenderFrameDeleted) {
1902 // Requests all hang once started. This prevents requests from being 1909 // Requests all hang once started. This prevents requests from being
1903 // destroyed due to completion. 1910 // destroyed due to completion.
1904 job_factory_->SetHangAfterStartJobGeneration(true); 1911 job_factory_->SetHangAfterStartJobGeneration(true);
1905 HandleScheme("http"); 1912 HandleScheme("http");
1906 1913
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
2137 accum_.GetClassifiedMessages(&msgs); 2144 accum_.GetClassifiedMessages(&msgs);
2138 2145
2139 // The 2 requests for the RVH 0 should have been processed. Note that 2146 // The 2 requests for the RVH 0 should have been processed. Note that
2140 // blocked detachable requests are canceled without delay. 2147 // blocked detachable requests are canceled without delay.
2141 ASSERT_EQ(2U, msgs.size()); 2148 ASSERT_EQ(2U, msgs.size());
2142 2149
2143 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); 2150 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1());
2144 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3()); 2151 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3());
2145 2152
2146 EXPECT_TRUE(host_.blocked_loaders_map_.empty()); 2153 EXPECT_TRUE(host_.blocked_loaders_map_.empty());
2154 second_filter->OnChannelClosing();
2147 } 2155 }
2148 2156
2149 // Tests that blocked requests don't leak when the ResourceDispatcherHost goes 2157 // Tests that blocked requests don't leak when the ResourceDispatcherHost goes
2150 // away. Note that we rely on Purify for finding the leaks if any. 2158 // away. Note that we rely on Purify for finding the leaks if any.
2151 // If this test turns the Purify bot red, check the ResourceDispatcherHost 2159 // If this test turns the Purify bot red, check the ResourceDispatcherHost
2152 // destructor to make sure the blocked requests are deleted. 2160 // destructor to make sure the blocked requests are deleted.
2153 TEST_P(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) { 2161 TEST_P(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) {
2154 // This second filter is used to emulate a second process. 2162 // This second filter is used to emulate a second process.
2155 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2163 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2156 2164
(...skipping 25 matching lines...) Expand all
2182 RESOURCE_TYPE_PREFETCH); // detachable type 2190 RESOURCE_TYPE_PREFETCH); // detachable type
2183 MakeTestRequestWithResourceType(second_filter.get(), 1, 8, 2191 MakeTestRequestWithResourceType(second_filter.get(), 1, 8,
2184 net::URLRequestTestJob::test_url_4(), 2192 net::URLRequestTestJob::test_url_4(),
2185 RESOURCE_TYPE_PREFETCH); // detachable type 2193 RESOURCE_TYPE_PREFETCH); // detachable type
2186 2194
2187 host_.CancelRequestsForProcess(filter_->child_id()); 2195 host_.CancelRequestsForProcess(filter_->child_id());
2188 host_.CancelRequestsForProcess(second_filter->child_id()); 2196 host_.CancelRequestsForProcess(second_filter->child_id());
2189 2197
2190 // Flush all the pending requests. 2198 // Flush all the pending requests.
2191 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2199 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2200
2201 second_filter->OnChannelClosing();
2192 } 2202 }
2193 2203
2194 // Test the private helper method "CalculateApproximateMemoryCost()". 2204 // Test the private helper method "CalculateApproximateMemoryCost()".
2195 TEST_P(ResourceDispatcherHostTest, CalculateApproximateMemoryCost) { 2205 TEST_P(ResourceDispatcherHostTest, CalculateApproximateMemoryCost) {
2196 net::URLRequestContext context; 2206 net::URLRequestContext context;
2197 std::unique_ptr<net::URLRequest> req(context.CreateRequest( 2207 std::unique_ptr<net::URLRequest> req(context.CreateRequest(
2198 GURL("http://www.google.com"), net::DEFAULT_PRIORITY, NULL)); 2208 GURL("http://www.google.com"), net::DEFAULT_PRIORITY, NULL));
2199 EXPECT_EQ( 2209 EXPECT_EQ(
2200 4427, 2210 4427,
2201 ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(req.get())); 2211 ResourceDispatcherHostImpl::CalculateApproximateMemoryCost(req.get()));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
2288 int index = kMaxRequests + i; 2298 int index = kMaxRequests + i;
2289 CheckFailedRequest(msgs[index], net::URLRequestTestJob::test_data_2(), 2299 CheckFailedRequest(msgs[index], net::URLRequestTestJob::test_data_2(),
2290 net::ERR_INSUFFICIENT_RESOURCES); 2300 net::ERR_INSUFFICIENT_RESOURCES);
2291 } 2301 }
2292 2302
2293 // The final 2 requests should have succeeded. 2303 // The final 2 requests should have succeeded.
2294 CheckSuccessfulRequest(msgs[kMaxRequests + 2], 2304 CheckSuccessfulRequest(msgs[kMaxRequests + 2],
2295 net::URLRequestTestJob::test_data_2()); 2305 net::URLRequestTestJob::test_data_2());
2296 CheckSuccessfulRequest(msgs[kMaxRequests + 3], 2306 CheckSuccessfulRequest(msgs[kMaxRequests + 3],
2297 net::URLRequestTestJob::test_data_2()); 2307 net::URLRequestTestJob::test_data_2());
2308
2309 second_filter->OnChannelClosing();
2298 } 2310 }
2299 2311
2300 // Test that when too many requests are outstanding for a particular 2312 // Test that when too many requests are outstanding for a particular
2301 // render_process_host_id, any subsequent request from it fails. Also verify 2313 // render_process_host_id, any subsequent request from it fails. Also verify
2302 // that the global limit is honored. 2314 // that the global limit is honored.
2303 TEST_P(ResourceDispatcherHostTest, TooManyOutstandingRequests) { 2315 TEST_P(ResourceDispatcherHostTest, TooManyOutstandingRequests) {
2304 // Tighten the bound on the ResourceDispatcherHost, to speed things up. 2316 // Tighten the bound on the ResourceDispatcherHost, to speed things up.
2305 const size_t kMaxRequestsPerProcess = 2; 2317 const size_t kMaxRequestsPerProcess = 2;
2306 host_.set_max_num_in_flight_requests_per_process(kMaxRequestsPerProcess); 2318 host_.set_max_num_in_flight_requests_per_process(kMaxRequestsPerProcess);
2307 const size_t kMaxRequests = 3; 2319 const size_t kMaxRequests = 3;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
2353 CheckSuccessfulRequest(msgs[i], net::URLRequestTestJob::test_data_2()); 2365 CheckSuccessfulRequest(msgs[i], net::URLRequestTestJob::test_data_2());
2354 2366
2355 CheckFailedRequest(msgs[kMaxRequestsPerProcess + 0], 2367 CheckFailedRequest(msgs[kMaxRequestsPerProcess + 0],
2356 net::URLRequestTestJob::test_data_2(), 2368 net::URLRequestTestJob::test_data_2(),
2357 net::ERR_INSUFFICIENT_RESOURCES); 2369 net::ERR_INSUFFICIENT_RESOURCES);
2358 CheckSuccessfulRequest(msgs[kMaxRequestsPerProcess + 1], 2370 CheckSuccessfulRequest(msgs[kMaxRequestsPerProcess + 1],
2359 net::URLRequestTestJob::test_data_2()); 2371 net::URLRequestTestJob::test_data_2());
2360 CheckFailedRequest(msgs[kMaxRequestsPerProcess + 2], 2372 CheckFailedRequest(msgs[kMaxRequestsPerProcess + 2],
2361 net::URLRequestTestJob::test_data_2(), 2373 net::URLRequestTestJob::test_data_2(),
2362 net::ERR_INSUFFICIENT_RESOURCES); 2374 net::ERR_INSUFFICIENT_RESOURCES);
2375
2376 second_filter->OnChannelClosing();
2377 third_filter->OnChannelClosing();
2363 } 2378 }
2364 2379
2365 // Tests that we sniff the mime type for a simple request. 2380 // Tests that we sniff the mime type for a simple request.
2366 TEST_P(ResourceDispatcherHostTest, MimeSniffed) { 2381 TEST_P(ResourceDispatcherHostTest, MimeSniffed) {
2367 std::string raw_headers("HTTP/1.1 200 OK\n\n"); 2382 std::string raw_headers("HTTP/1.1 200 OK\n\n");
2368 std::string response_data("<html><title>Test One</title></html>"); 2383 std::string response_data("<html><title>Test One</title></html>");
2369 SetResponse(raw_headers, response_data); 2384 SetResponse(raw_headers, response_data);
2370 2385
2371 HandleScheme("http"); 2386 HandleScheme("http");
2372 MakeTestRequest(0, 1, GURL("http:bla")); 2387 MakeTestRequest(0, 1, GURL("http:bla"));
(...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after
2752 host_.OnMessageReceived(transfer_request_msg, second_filter.get()); 2767 host_.OnMessageReceived(transfer_request_msg, second_filter.get());
2753 base::RunLoop().RunUntilIdle(); 2768 base::RunLoop().RunUntilIdle();
2754 2769
2755 // Check generated messages. 2770 // Check generated messages.
2756 ResourceIPCAccumulator::ClassifiedMessages msgs; 2771 ResourceIPCAccumulator::ClassifiedMessages msgs;
2757 accum_.GetClassifiedMessages(&msgs); 2772 accum_.GetClassifiedMessages(&msgs);
2758 2773
2759 ASSERT_EQ(2U, msgs.size()); 2774 ASSERT_EQ(2U, msgs.size());
2760 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 2775 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
2761 CheckSuccessfulRequest(msgs[1], kResponseBody); 2776 CheckSuccessfulRequest(msgs[1], kResponseBody);
2777
2778 second_filter->OnChannelClosing();
2762 } 2779 }
2763 2780
2764 // Test transferring two navigations with text/html, to ensure the resource 2781 // Test transferring two navigations with text/html, to ensure the resource
2765 // accounting works. 2782 // accounting works.
2766 TEST_P(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) { 2783 TEST_P(ResourceDispatcherHostTest, TransferTwoNavigationsHtml) {
2767 if (IsBrowserSideNavigationEnabled()) { 2784 if (IsBrowserSideNavigationEnabled()) {
2768 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2785 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2769 return; 2786 return;
2770 } 2787 }
2771 2788
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
2830 new_render_view_id, new_second_request_id, second_request); 2847 new_render_view_id, new_second_request_id, second_request);
2831 host_.OnMessageReceived(second_transfer_request_msg, second_filter.get()); 2848 host_.OnMessageReceived(second_transfer_request_msg, second_filter.get());
2832 base::RunLoop().RunUntilIdle(); 2849 base::RunLoop().RunUntilIdle();
2833 2850
2834 // Check generated messages. 2851 // Check generated messages.
2835 ResourceIPCAccumulator::ClassifiedMessages msgs; 2852 ResourceIPCAccumulator::ClassifiedMessages msgs;
2836 accum_.GetClassifiedMessages(&msgs); 2853 accum_.GetClassifiedMessages(&msgs);
2837 2854
2838 ASSERT_EQ(2U, msgs.size()); 2855 ASSERT_EQ(2U, msgs.size());
2839 CheckSuccessfulRequest(msgs[0], kResponseBody); 2856 CheckSuccessfulRequest(msgs[0], kResponseBody);
2857
2858 second_filter->OnChannelClosing();
2840 } 2859 }
2841 2860
2842 // Test transferred navigations with text/plain, which causes 2861 // Test transferred navigations with text/plain, which causes
2843 // MimeTypeResourceHandler to buffer the response to sniff the content before 2862 // MimeTypeResourceHandler to buffer the response to sniff the content before
2844 // the transfer occurs. 2863 // the transfer occurs.
2845 TEST_P(ResourceDispatcherHostTest, TransferNavigationText) { 2864 TEST_P(ResourceDispatcherHostTest, TransferNavigationText) {
2846 if (IsBrowserSideNavigationEnabled()) { 2865 if (IsBrowserSideNavigationEnabled()) {
2847 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2866 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2848 return; 2867 return;
2849 } 2868 }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2899 host_.OnMessageReceived(transfer_request_msg, second_filter.get()); 2918 host_.OnMessageReceived(transfer_request_msg, second_filter.get());
2900 base::RunLoop().RunUntilIdle(); 2919 base::RunLoop().RunUntilIdle();
2901 2920
2902 // Check generated messages. 2921 // Check generated messages.
2903 ResourceIPCAccumulator::ClassifiedMessages msgs; 2922 ResourceIPCAccumulator::ClassifiedMessages msgs;
2904 accum_.GetClassifiedMessages(&msgs); 2923 accum_.GetClassifiedMessages(&msgs);
2905 2924
2906 ASSERT_EQ(2U, msgs.size()); 2925 ASSERT_EQ(2U, msgs.size());
2907 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 2926 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
2908 CheckSuccessfulRequest(msgs[1], kResponseBody); 2927 CheckSuccessfulRequest(msgs[1], kResponseBody);
2928
2929 second_filter->OnChannelClosing();
2909 } 2930 }
2910 2931
2911 TEST_P(ResourceDispatcherHostTest, TransferNavigationWithProcessCrash) { 2932 TEST_P(ResourceDispatcherHostTest, TransferNavigationWithProcessCrash) {
2912 if (IsBrowserSideNavigationEnabled()) { 2933 if (IsBrowserSideNavigationEnabled()) {
2913 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 2934 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2914 return; 2935 return;
2915 } 2936 }
2916 2937
2917 NavigationResourceThrottle::set_force_transfer_for_testing(true); 2938 NavigationResourceThrottle::set_force_transfer_for_testing(true);
2918 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 2939 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
(...skipping 29 matching lines...) Expand all
2948 SetResponse("HTTP/1.1 200 OK\n" 2969 SetResponse("HTTP/1.1 200 OK\n"
2949 "Content-Type: text/html\n\n", 2970 "Content-Type: text/html\n\n",
2950 kResponseBody); 2971 kResponseBody);
2951 ResourceHostMsg_FollowRedirect redirect_msg(request_id); 2972 ResourceHostMsg_FollowRedirect redirect_msg(request_id);
2952 host_.OnMessageReceived(redirect_msg, first_filter.get()); 2973 host_.OnMessageReceived(redirect_msg, first_filter.get());
2953 base::RunLoop().RunUntilIdle(); 2974 base::RunLoop().RunUntilIdle();
2954 2975
2955 // Flush all the pending requests to get the response through the 2976 // Flush all the pending requests to get the response through the
2956 // MimeTypeResourceHandler. 2977 // MimeTypeResourceHandler.
2957 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 2978 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
2979
2980 first_filter->OnChannelClosing();
2958 } 2981 }
2959 // The first filter is now deleted, as if the child process died. 2982 // The first filter is now deleted, as if the child process died.
2960 2983
2961 // Make sure we don't hold onto the ResourceMessageFilter after it is deleted. 2984 // Make sure we don't hold onto the ResourceMessageFilter after it is deleted.
2962 GlobalRequestID first_global_request_id(first_child_id, request_id); 2985 GlobalRequestID first_global_request_id(first_child_id, request_id);
2963 2986
2964 // This second filter is used to emulate a second process. 2987 // This second filter is used to emulate a second process.
2965 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2988 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
2966 2989
2967 int new_render_view_id = 1; 2990 int new_render_view_id = 1;
(...skipping 11 matching lines...) Expand all
2979 host_.OnMessageReceived(transfer_request_msg, second_filter.get()); 3002 host_.OnMessageReceived(transfer_request_msg, second_filter.get());
2980 base::RunLoop().RunUntilIdle(); 3003 base::RunLoop().RunUntilIdle();
2981 3004
2982 // Check generated messages. 3005 // Check generated messages.
2983 ResourceIPCAccumulator::ClassifiedMessages msgs; 3006 ResourceIPCAccumulator::ClassifiedMessages msgs;
2984 accum_.GetClassifiedMessages(&msgs); 3007 accum_.GetClassifiedMessages(&msgs);
2985 3008
2986 ASSERT_EQ(2U, msgs.size()); 3009 ASSERT_EQ(2U, msgs.size());
2987 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 3010 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
2988 CheckSuccessfulRequest(msgs[1], kResponseBody); 3011 CheckSuccessfulRequest(msgs[1], kResponseBody);
3012
3013 second_filter->OnChannelClosing();
2989 } 3014 }
2990 3015
2991 TEST_P(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) { 3016 TEST_P(ResourceDispatcherHostTest, TransferNavigationWithTwoRedirects) {
2992 if (IsBrowserSideNavigationEnabled()) { 3017 if (IsBrowserSideNavigationEnabled()) {
2993 SUCCEED() << "Test is not applicable with browser side navigation enabled"; 3018 SUCCEED() << "Test is not applicable with browser side navigation enabled";
2994 return; 3019 return;
2995 } 3020 }
2996 3021
2997 NavigationResourceThrottle::set_force_transfer_for_testing(true); 3022 NavigationResourceThrottle::set_force_transfer_for_testing(true);
2998 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 3023 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
3065 // Let request complete. 3090 // Let request complete.
3066 base::RunLoop().RunUntilIdle(); 3091 base::RunLoop().RunUntilIdle();
3067 3092
3068 // Check generated messages. 3093 // Check generated messages.
3069 ResourceIPCAccumulator::ClassifiedMessages msgs; 3094 ResourceIPCAccumulator::ClassifiedMessages msgs;
3070 accum_.GetClassifiedMessages(&msgs); 3095 accum_.GetClassifiedMessages(&msgs);
3071 3096
3072 ASSERT_EQ(2U, msgs.size()); 3097 ASSERT_EQ(2U, msgs.size());
3073 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type()); 3098 EXPECT_EQ(ResourceMsg_ReceivedRedirect::ID, msgs[0][0].type());
3074 CheckSuccessfulRequest(msgs[1], kResponseBody); 3099 CheckSuccessfulRequest(msgs[1], kResponseBody);
3100
3101 second_filter->OnChannelClosing();
3075 } 3102 }
3076 3103
3077 TEST_P(ResourceDispatcherHostTest, UnknownURLScheme) { 3104 TEST_P(ResourceDispatcherHostTest, UnknownURLScheme) {
3078 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true); 3105 NavigationResourceThrottle::set_ui_checks_always_succeed_for_testing(true);
3079 EXPECT_EQ(0, host_.pending_requests()); 3106 EXPECT_EQ(0, host_.pending_requests());
3080 3107
3081 HandleScheme("http"); 3108 HandleScheme("http");
3082 3109
3083 const GURL invalid_sheme_url = GURL("foo://bar"); 3110 const GURL invalid_sheme_url = GURL("foo://bar");
3084 const int expected_error_code = net::ERR_UNKNOWN_URL_SCHEME; 3111 const int expected_error_code = net::ERR_UNKNOWN_URL_SCHEME;
(...skipping 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
3845 return nullptr; 3872 return nullptr;
3846 } 3873 }
3847 3874
3848 INSTANTIATE_TEST_CASE_P( 3875 INSTANTIATE_TEST_CASE_P(
3849 ResourceDispatcherHostTests, 3876 ResourceDispatcherHostTests,
3850 ResourceDispatcherHostTest, 3877 ResourceDispatcherHostTest,
3851 testing::Values(TestConfig::kDefault, 3878 testing::Values(TestConfig::kDefault,
3852 TestConfig::kOptimizeIPCForSmallResourceEnabled)); 3879 TestConfig::kOptimizeIPCForSmallResourceEnabled));
3853 3880
3854 } // namespace content 3881 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698