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

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

Issue 1542743002: [RDHI] Refactored blocked_loaders_map_ to key by render frame route id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: New, simpler API (default recurses frame tree) Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 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 #include <utility> 6 #include <utility>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 923 matching lines...) Expand 10 before | Expand all | Expand 10 after
934 child_ids_.insert(filter->child_id()); 934 child_ids_.insert(filter->child_id());
935 return filter; 935 return filter;
936 } 936 }
937 937
938 // Creates a request using the current test object as the filter and 938 // Creates a request using the current test object as the filter and
939 // SubResource as the resource type. 939 // SubResource as the resource type.
940 void MakeTestRequest(int render_view_id, 940 void MakeTestRequest(int render_view_id,
941 int request_id, 941 int request_id,
942 const GURL& url); 942 const GURL& url);
943 943
944 void MakeTestRequestWithRenderFrame(int render_view_id,
945 int render_frame_id,
946 int request_id,
947 const GURL& url,
948 ResourceType type);
949
944 // Generates a request using the given filter and resource type. 950 // Generates a request using the given filter and resource type.
945 void MakeTestRequestWithResourceType(ResourceMessageFilter* filter, 951 void MakeTestRequestWithResourceType(ResourceMessageFilter* filter,
946 int render_view_id, 952 int render_view_id,
947 int request_id, 953 int request_id,
948 const GURL& url, 954 const GURL& url,
949 ResourceType type); 955 ResourceType type);
950 956
951 void MakeWebContentsAssociatedTestRequest(int request_id, const GURL& url); 957 void MakeWebContentsAssociatedTestRequest(int request_id, const GURL& url);
952 void MakeWebContentsAssociatedTestRequestWithResourceType(int request_id, 958 void MakeWebContentsAssociatedTestRequestWithResourceType(int request_id,
953 const GURL& url, 959 const GURL& url,
954 ResourceType type); 960 ResourceType type);
955 961
956 // Generates a request with the given priority. 962 // Generates a request with the given priority.
957 void MakeTestRequestWithPriority(int render_view_id, 963 void MakeTestRequestWithPriority(int render_view_id,
958 int request_id, 964 int request_id,
959 net::RequestPriority priority); 965 net::RequestPriority priority);
960 966
967 void MakeTestRequestWithPriorityAndRenderFrame(int render_view_id,
968 int render_frame_id,
969 int request_id,
970 net::RequestPriority priority);
971
961 void MakeWebContentsAssociatedDownloadRequest(int request_id, 972 void MakeWebContentsAssociatedDownloadRequest(int request_id,
962 const GURL& url); 973 const GURL& url);
963 974
964 void CancelRequest(int request_id); 975 void CancelRequest(int request_id);
965 void RendererCancelRequest(int request_id) { 976 void RendererCancelRequest(int request_id) {
966 ResourceMessageFilter* old_filter = SetFilter(filter_.get()); 977 ResourceMessageFilter* old_filter = SetFilter(filter_.get());
967 host_.OnCancelRequest(request_id); 978 host_.OnCancelRequest(request_id);
968 SetFilter(old_filter); 979 SetFilter(old_filter);
969 } 980 }
970 981
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 RenderViewHostTestEnabler render_view_host_test_enabler_; 1064 RenderViewHostTestEnabler render_view_host_test_enabler_;
1054 }; 1065 };
1055 1066
1056 void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id, 1067 void ResourceDispatcherHostTest::MakeTestRequest(int render_view_id,
1057 int request_id, 1068 int request_id,
1058 const GURL& url) { 1069 const GURL& url) {
1059 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id, 1070 MakeTestRequestWithResourceType(filter_.get(), render_view_id, request_id,
1060 url, RESOURCE_TYPE_SUB_RESOURCE); 1071 url, RESOURCE_TYPE_SUB_RESOURCE);
1061 } 1072 }
1062 1073
1074 void ResourceDispatcherHostTest::MakeTestRequestWithRenderFrame(
1075 int render_view_id,
1076 int render_frame_id,
1077 int request_id,
1078 const GURL& url,
1079 ResourceType type) {
1080 ResourceHostMsg_Request request = CreateResourceRequest("GET", type, url);
1081 request.render_frame_id = render_frame_id;
1082 ResourceHostMsg_RequestResource msg(render_view_id, request_id, request);
1083 host_.OnMessageReceived(msg, filter_.get());
1084 KickOffRequest();
1085 }
1086
1063 void ResourceDispatcherHostTest::MakeTestRequestWithResourceType( 1087 void ResourceDispatcherHostTest::MakeTestRequestWithResourceType(
1064 ResourceMessageFilter* filter, 1088 ResourceMessageFilter* filter,
1065 int render_view_id, 1089 int render_view_id,
1066 int request_id, 1090 int request_id,
1067 const GURL& url, 1091 const GURL& url,
1068 ResourceType type) { 1092 ResourceType type) {
1069 ResourceHostMsg_Request request = 1093 ResourceHostMsg_Request request =
1070 CreateResourceRequest("GET", type, url); 1094 CreateResourceRequest("GET", type, url);
1071 ResourceHostMsg_RequestResource msg(render_view_id, request_id, request); 1095 ResourceHostMsg_RequestResource msg(render_view_id, request_id, request);
1072 host_.OnMessageReceived(msg, filter); 1096 host_.OnMessageReceived(msg, filter);
(...skipping 17 matching lines...) Expand all
1090 ResourceHostMsg_RequestResource msg(web_contents_->GetRoutingID(), request_id, 1114 ResourceHostMsg_RequestResource msg(web_contents_->GetRoutingID(), request_id,
1091 request); 1115 request);
1092 host_.OnMessageReceived(msg, web_contents_filter_.get()); 1116 host_.OnMessageReceived(msg, web_contents_filter_.get());
1093 KickOffRequest(); 1117 KickOffRequest();
1094 } 1118 }
1095 1119
1096 void ResourceDispatcherHostTest::MakeTestRequestWithPriority( 1120 void ResourceDispatcherHostTest::MakeTestRequestWithPriority(
1097 int render_view_id, 1121 int render_view_id,
1098 int request_id, 1122 int request_id,
1099 net::RequestPriority priority) { 1123 net::RequestPriority priority) {
1124 MakeTestRequestWithPriorityAndRenderFrame(render_view_id, -1, request_id,
1125 priority);
1126 }
1127
1128 void ResourceDispatcherHostTest::MakeTestRequestWithPriorityAndRenderFrame(
1129 int render_view_id,
1130 int render_frame_id,
1131 int request_id,
1132 net::RequestPriority priority) {
1100 ResourceHostMsg_Request request = CreateResourceRequest( 1133 ResourceHostMsg_Request request = CreateResourceRequest(
1101 "GET", RESOURCE_TYPE_SUB_RESOURCE, GURL("http://example.com/priority")); 1134 "GET", RESOURCE_TYPE_SUB_RESOURCE, GURL("http://example.com/priority"));
1135 request.render_frame_id = render_frame_id;
1102 request.priority = priority; 1136 request.priority = priority;
1103 ResourceHostMsg_RequestResource msg(render_view_id, request_id, request); 1137 ResourceHostMsg_RequestResource msg(render_view_id, request_id, request);
1104 host_.OnMessageReceived(msg, filter_.get()); 1138 host_.OnMessageReceived(msg, filter_.get());
1105 } 1139 }
1106 1140
1107 void ResourceDispatcherHostTest::MakeWebContentsAssociatedDownloadRequest( 1141 void ResourceDispatcherHostTest::MakeWebContentsAssociatedDownloadRequest(
1108 int request_id, 1142 int request_id,
1109 const GURL& url) { 1143 const GURL& url) {
1110 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo()); 1144 scoped_ptr<DownloadSaveInfo> save_info(new DownloadSaveInfo());
1111 save_info->prompt_for_save_location = false; 1145 save_info->prompt_for_save_location = false;
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
1741 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[1][0].type()); 1775 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[1][0].type());
1742 CheckRequestCompleteErrorCode(msgs[1][1], net::ERR_ABORTED); 1776 CheckRequestCompleteErrorCode(msgs[1][1], net::ERR_ABORTED);
1743 // But it completed anyway. For the network stack, no requests were canceled. 1777 // But it completed anyway. For the network stack, no requests were canceled.
1744 EXPECT_EQ(4, network_delegate()->completed_requests()); 1778 EXPECT_EQ(4, network_delegate()->completed_requests());
1745 EXPECT_EQ(0, network_delegate()->canceled_requests()); 1779 EXPECT_EQ(0, network_delegate()->canceled_requests());
1746 EXPECT_EQ(0, network_delegate()->error_count()); 1780 EXPECT_EQ(0, network_delegate()->error_count());
1747 } 1781 }
1748 1782
1749 // Tests whether the correct requests get canceled when a RenderViewHost is 1783 // Tests whether the correct requests get canceled when a RenderViewHost is
1750 // deleted. 1784 // deleted.
1751 TEST_F(ResourceDispatcherHostTest, CancelRequestsOnRenderViewHostDeleted) { 1785 TEST_F(ResourceDispatcherHostTest, CancelRequestsOnRenderFrameDeleted) {
1752 // Requests all hang once started. This prevents requests from being 1786 // Requests all hang once started. This prevents requests from being
1753 // destroyed due to completion. 1787 // destroyed due to completion.
1754 job_factory_->SetHangAfterStartJobGeneration(true); 1788 job_factory_->SetHangAfterStartJobGeneration(true);
1755 HandleScheme("http"); 1789 HandleScheme("http");
1756 1790
1757 TestResourceDispatcherHostDelegate delegate; 1791 TestResourceDispatcherHostDelegate delegate;
1758 host_.SetDelegate(&delegate); 1792 host_.SetDelegate(&delegate);
1759 host_.OnRenderViewHostCreated(filter_->child_id(), 0, true, false); 1793 host_.OnRenderViewHostCreated(filter_->child_id(), 0, true, false);
1760 1794
1761 // One RenderView issues a high priority request and a low priority one. Both 1795 // One RenderView issues a high priority request and a low priority one. Both
1762 // should be started. 1796 // should be started.
1763 MakeTestRequestWithPriority(0, 1, net::HIGHEST); 1797 MakeTestRequestWithPriorityAndRenderFrame(0, 10, 1, net::HIGHEST);
1764 MakeTestRequestWithPriority(0, 2, net::LOWEST); 1798 MakeTestRequestWithPriorityAndRenderFrame(0, 11, 2, net::LOWEST);
1765 KickOffRequest(); 1799 KickOffRequest();
1766 EXPECT_EQ(2, network_delegate_.created_requests()); 1800 EXPECT_EQ(2, network_delegate_.created_requests());
1767 EXPECT_EQ(0, network_delegate_.canceled_requests()); 1801 EXPECT_EQ(0, network_delegate_.canceled_requests());
1768 1802
1769 // The same RenderView issues two more low priority requests. The 1803 // The same RenderView issues two more low priority requests. The
1770 // ResourceScheduler shouldn't let them start immediately. 1804 // ResourceScheduler shouldn't let them start immediately.
1771 MakeTestRequestWithPriority(0, 3, net::LOWEST); 1805 MakeTestRequestWithPriorityAndRenderFrame(0, 10, 3, net::LOWEST);
1772 MakeTestRequestWithPriority(0, 4, net::LOWEST); 1806 MakeTestRequestWithPriorityAndRenderFrame(0, 11, 4, net::LOWEST);
1773 KickOffRequest(); 1807 KickOffRequest();
1774 EXPECT_EQ(2, network_delegate_.created_requests()); 1808 EXPECT_EQ(2, network_delegate_.created_requests());
1775 EXPECT_EQ(0, network_delegate_.canceled_requests()); 1809 EXPECT_EQ(0, network_delegate_.canceled_requests());
1776 1810
1777 // Another RenderView in the same process as the old one issues a request, 1811 // Another RenderView in the same process as the old one issues a request,
1778 // which is then started. 1812 // which is then started.
1779 MakeTestRequestWithPriority(1, 5, net::LOWEST); 1813 MakeTestRequestWithPriorityAndRenderFrame(1, 12, 5, net::LOWEST);
1780 KickOffRequest(); 1814 KickOffRequest();
1781 EXPECT_EQ(3, network_delegate_.created_requests()); 1815 EXPECT_EQ(3, network_delegate_.created_requests());
1782 EXPECT_EQ(0, network_delegate_.canceled_requests()); 1816 EXPECT_EQ(0, network_delegate_.canceled_requests());
1783 1817
1784 // The first RenderView is destroyed. All 4 of its requests should be 1818 // The first two RenderFrameHosts are destroyed. All 4 of their requests
1785 // cancelled, and none of the two deferred requests should be started. 1819 // should be cancelled, and none of the two deferred requests should be
1820 // started.
1821 host_.OnRenderFrameDeleted(GlobalFrameRoutingId(filter_->child_id(), 10));
1822 host_.OnRenderFrameDeleted(GlobalFrameRoutingId(filter_->child_id(), 11));
1786 host_.OnRenderViewHostDeleted(filter_->child_id(), 0); 1823 host_.OnRenderViewHostDeleted(filter_->child_id(), 0);
1787 base::RunLoop().RunUntilIdle(); 1824 base::RunLoop().RunUntilIdle();
1788 EXPECT_EQ(3, network_delegate_.created_requests()); 1825 EXPECT_EQ(3, network_delegate_.created_requests());
1789 EXPECT_EQ(4, network_delegate_.canceled_requests()); 1826 EXPECT_EQ(4, network_delegate_.canceled_requests());
1790 1827
1791 // No messages should have been sent, since none of the jobs made any 1828 // No messages should have been sent, since none of the jobs made any
1792 // progress. 1829 // progress.
1793 ResourceIPCAccumulator::ClassifiedMessages msgs; 1830 ResourceIPCAccumulator::ClassifiedMessages msgs;
1794 accum_.GetClassifiedMessages(&msgs); 1831 accum_.GetClassifiedMessages(&msgs);
1795 EXPECT_EQ(0U, msgs.size()); 1832 EXPECT_EQ(0U, msgs.size());
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1835 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[0][0].type()); 1872 ASSERT_EQ(ResourceMsg_ReceivedResponse::ID, msgs[0][0].type());
1836 CheckRequestCompleteErrorCode(msgs[0][1], net::ERR_ABORTED); 1873 CheckRequestCompleteErrorCode(msgs[0][1], net::ERR_ABORTED);
1837 // And not run to completion. 1874 // And not run to completion.
1838 EXPECT_EQ(1, network_delegate()->completed_requests()); 1875 EXPECT_EQ(1, network_delegate()->completed_requests());
1839 EXPECT_EQ(1, network_delegate()->canceled_requests()); 1876 EXPECT_EQ(1, network_delegate()->canceled_requests());
1840 EXPECT_EQ(0, network_delegate()->error_count()); 1877 EXPECT_EQ(0, network_delegate()->error_count());
1841 } 1878 }
1842 1879
1843 // Tests blocking and resuming requests. 1880 // Tests blocking and resuming requests.
1844 TEST_F(ResourceDispatcherHostTest, TestBlockingResumingRequests) { 1881 TEST_F(ResourceDispatcherHostTest, TestBlockingResumingRequests) {
1845 host_.BlockRequestsForRoute(filter_->child_id(), 1); 1882 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 11));
1846 host_.BlockRequestsForRoute(filter_->child_id(), 2); 1883 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 12));
1847 host_.BlockRequestsForRoute(filter_->child_id(), 3); 1884 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 13));
1848 1885
1849 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); 1886 MakeTestRequestWithRenderFrame(0, 10, 1, net::URLRequestTestJob::test_url_1(),
1850 MakeTestRequest(1, 2, net::URLRequestTestJob::test_url_2()); 1887 RESOURCE_TYPE_SUB_RESOURCE);
1851 MakeTestRequest(0, 3, net::URLRequestTestJob::test_url_3()); 1888 MakeTestRequestWithRenderFrame(1, 11, 2, net::URLRequestTestJob::test_url_2(),
1852 MakeTestRequest(1, 4, net::URLRequestTestJob::test_url_1()); 1889 RESOURCE_TYPE_SUB_RESOURCE);
1853 MakeTestRequest(2, 5, net::URLRequestTestJob::test_url_2()); 1890 MakeTestRequestWithRenderFrame(0, 10, 3, net::URLRequestTestJob::test_url_3(),
1854 MakeTestRequest(3, 6, net::URLRequestTestJob::test_url_3()); 1891 RESOURCE_TYPE_SUB_RESOURCE);
1892 MakeTestRequestWithRenderFrame(1, 11, 4, net::URLRequestTestJob::test_url_1(),
1893 RESOURCE_TYPE_SUB_RESOURCE);
1894 MakeTestRequestWithRenderFrame(2, 12, 5, net::URLRequestTestJob::test_url_2(),
1895 RESOURCE_TYPE_SUB_RESOURCE);
1896 MakeTestRequestWithRenderFrame(3, 13, 6, net::URLRequestTestJob::test_url_3(),
1897 RESOURCE_TYPE_SUB_RESOURCE);
1855 1898
1856 // Flush all the pending requests 1899 // Flush all the pending requests
1857 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1900 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1858 1901
1859 // Sort out all the messages we saw by request 1902 // Sort out all the messages we saw by request
1860 ResourceIPCAccumulator::ClassifiedMessages msgs; 1903 ResourceIPCAccumulator::ClassifiedMessages msgs;
1861 accum_.GetClassifiedMessages(&msgs); 1904 accum_.GetClassifiedMessages(&msgs);
1862 1905
1863 // All requests but the 2 for the RVH 0 should have been blocked. 1906 // All requests but the 2 for the RFH 0 should have been blocked.
1864 ASSERT_EQ(2U, msgs.size()); 1907 ASSERT_EQ(2U, msgs.size());
1865 1908
1866 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); 1909 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1());
1867 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3()); 1910 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3());
1868 1911
1869 // Resume requests for RVH 1 and flush pending requests. 1912 // Resume requests for RFH 11 and flush pending requests.
1870 host_.ResumeBlockedRequestsForRoute(filter_->child_id(), 1); 1913 host_.ResumeBlockedRequestsForRoute(
1914 GlobalFrameRoutingId(filter_->child_id(), 11));
1871 KickOffRequest(); 1915 KickOffRequest();
1872 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1916 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1873 1917
1874 msgs.clear(); 1918 msgs.clear();
1875 accum_.GetClassifiedMessages(&msgs); 1919 accum_.GetClassifiedMessages(&msgs);
1876 ASSERT_EQ(2U, msgs.size()); 1920 ASSERT_EQ(2U, msgs.size());
1877 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_2()); 1921 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_2());
1878 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_1()); 1922 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_1());
1879 1923
1880 // Test that new requests are not blocked for RVH 1. 1924 // Test that new requests are not blocked for RFH 11.
1881 MakeTestRequest(1, 7, net::URLRequestTestJob::test_url_1()); 1925 MakeTestRequestWithRenderFrame(1, 11, 7, net::URLRequestTestJob::test_url_1(),
1926 RESOURCE_TYPE_SUB_RESOURCE);
1882 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1927 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1883 msgs.clear(); 1928 msgs.clear();
1884 accum_.GetClassifiedMessages(&msgs); 1929 accum_.GetClassifiedMessages(&msgs);
1885 ASSERT_EQ(1U, msgs.size()); 1930 ASSERT_EQ(1U, msgs.size());
1886 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); 1931 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1());
1887 1932
1888 // Now resumes requests for all RVH (2 and 3). 1933 // Now resumes requests for all RFH (12 and 13).
1889 host_.ResumeBlockedRequestsForRoute(filter_->child_id(), 2); 1934 host_.ResumeBlockedRequestsForRoute(
1890 host_.ResumeBlockedRequestsForRoute(filter_->child_id(), 3); 1935 GlobalFrameRoutingId(filter_->child_id(), 12));
1936 host_.ResumeBlockedRequestsForRoute(
1937 GlobalFrameRoutingId(filter_->child_id(), 13));
1891 KickOffRequest(); 1938 KickOffRequest();
1892 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1939 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1893 1940
1894 msgs.clear(); 1941 msgs.clear();
1895 accum_.GetClassifiedMessages(&msgs); 1942 accum_.GetClassifiedMessages(&msgs);
1896 ASSERT_EQ(2U, msgs.size()); 1943 ASSERT_EQ(2U, msgs.size());
1897 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_2()); 1944 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_2());
1898 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3()); 1945 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3());
1899 } 1946 }
1900 1947
1901 // Tests blocking and canceling requests. 1948 // Tests blocking and canceling requests.
1902 TEST_F(ResourceDispatcherHostTest, TestBlockingCancelingRequests) { 1949 TEST_F(ResourceDispatcherHostTest, TestBlockingCancelingRequests) {
1903 host_.BlockRequestsForRoute(filter_->child_id(), 1); 1950 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 11));
1904 1951
1905 MakeTestRequest(0, 1, net::URLRequestTestJob::test_url_1()); 1952 MakeTestRequestWithRenderFrame(0, 10, 1, net::URLRequestTestJob::test_url_1(),
1906 MakeTestRequest(1, 2, net::URLRequestTestJob::test_url_2()); 1953 RESOURCE_TYPE_SUB_RESOURCE);
1907 MakeTestRequest(0, 3, net::URLRequestTestJob::test_url_3()); 1954 MakeTestRequestWithRenderFrame(1, 11, 2, net::URLRequestTestJob::test_url_2(),
1908 MakeTestRequest(1, 4, net::URLRequestTestJob::test_url_1()); 1955 RESOURCE_TYPE_SUB_RESOURCE);
1956 MakeTestRequestWithRenderFrame(0, 10, 3, net::URLRequestTestJob::test_url_3(),
1957 RESOURCE_TYPE_SUB_RESOURCE);
1958 MakeTestRequestWithRenderFrame(1, 11, 4, net::URLRequestTestJob::test_url_1(),
1959 RESOURCE_TYPE_SUB_RESOURCE);
1909 // Blocked detachable resources should not delay cancellation. 1960 // Blocked detachable resources should not delay cancellation.
1910 MakeTestRequestWithResourceType(filter_.get(), 1, 5, 1961 //
1911 net::URLRequestTestJob::test_url_4(), 1962 MakeTestRequestWithRenderFrame(1, 11, 5, net::URLRequestTestJob::test_url_4(),
1912 RESOURCE_TYPE_PREFETCH); // detachable type 1963 RESOURCE_TYPE_PREFETCH); // detachable type
1913 1964
1914 // Flush all the pending requests. 1965 // Flush all the pending requests.
1915 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1966 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1916 1967
1917 // Sort out all the messages we saw by request. 1968 // Sort out all the messages we saw by request.
1918 ResourceIPCAccumulator::ClassifiedMessages msgs; 1969 ResourceIPCAccumulator::ClassifiedMessages msgs;
1919 accum_.GetClassifiedMessages(&msgs); 1970 accum_.GetClassifiedMessages(&msgs);
1920 1971
1921 // The 2 requests for the RVH 0 should have been processed. 1972 // The 2 requests for the RFH 10 should have been processed.
1922 ASSERT_EQ(2U, msgs.size()); 1973 ASSERT_EQ(2U, msgs.size());
1923 1974
1924 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1()); 1975 CheckSuccessfulRequest(msgs[0], net::URLRequestTestJob::test_data_1());
1925 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3()); 1976 CheckSuccessfulRequest(msgs[1], net::URLRequestTestJob::test_data_3());
1926 1977
1927 // Cancel requests for RVH 1. 1978 // Cancel requests for RFH 11.
1928 host_.CancelBlockedRequestsForRoute(filter_->child_id(), 1); 1979 host_.CancelBlockedRequestsForRoute(
1980 GlobalFrameRoutingId(filter_->child_id(), 11));
1929 KickOffRequest(); 1981 KickOffRequest();
1930 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} 1982 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {}
1931 1983
1932 msgs.clear(); 1984 msgs.clear();
1933 accum_.GetClassifiedMessages(&msgs); 1985 accum_.GetClassifiedMessages(&msgs);
1934 ASSERT_EQ(0U, msgs.size()); 1986 ASSERT_EQ(0U, msgs.size());
1935 } 1987 }
1936 1988
1937 // Tests that blocked requests are canceled if their associated process dies. 1989 // Tests that blocked requests are canceled if their associated process dies.
1938 TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) { 1990 TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsProcessDies) {
1939 // This second filter is used to emulate a second process. 1991 // This second filter is used to emulate a second process.
1940 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 1992 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
1941 1993
1942 host_.BlockRequestsForRoute(second_filter->child_id(), 0); 1994 host_.BlockRequestsForRoute(
1995 GlobalFrameRoutingId(second_filter->child_id(), 0));
1943 1996
1944 MakeTestRequestWithResourceType(filter_.get(), 0, 1, 1997 MakeTestRequestWithResourceType(filter_.get(), 0, 1,
1945 net::URLRequestTestJob::test_url_1(), 1998 net::URLRequestTestJob::test_url_1(),
1946 RESOURCE_TYPE_SUB_RESOURCE); 1999 RESOURCE_TYPE_SUB_RESOURCE);
1947 MakeTestRequestWithResourceType(second_filter.get(), 0, 2, 2000 MakeTestRequestWithResourceType(second_filter.get(), 0, 2,
1948 net::URLRequestTestJob::test_url_2(), 2001 net::URLRequestTestJob::test_url_2(),
1949 RESOURCE_TYPE_SUB_RESOURCE); 2002 RESOURCE_TYPE_SUB_RESOURCE);
1950 MakeTestRequestWithResourceType(filter_.get(), 0, 3, 2003 MakeTestRequestWithResourceType(filter_.get(), 0, 3,
1951 net::URLRequestTestJob::test_url_3(), 2004 net::URLRequestTestJob::test_url_3(),
1952 RESOURCE_TYPE_SUB_RESOURCE); 2005 RESOURCE_TYPE_SUB_RESOURCE);
(...skipping 25 matching lines...) Expand all
1978 } 2031 }
1979 2032
1980 // Tests that blocked requests don't leak when the ResourceDispatcherHost goes 2033 // Tests that blocked requests don't leak when the ResourceDispatcherHost goes
1981 // away. Note that we rely on Purify for finding the leaks if any. 2034 // away. Note that we rely on Purify for finding the leaks if any.
1982 // If this test turns the Purify bot red, check the ResourceDispatcherHost 2035 // If this test turns the Purify bot red, check the ResourceDispatcherHost
1983 // destructor to make sure the blocked requests are deleted. 2036 // destructor to make sure the blocked requests are deleted.
1984 TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) { 2037 TEST_F(ResourceDispatcherHostTest, TestBlockedRequestsDontLeak) {
1985 // This second filter is used to emulate a second process. 2038 // This second filter is used to emulate a second process.
1986 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter(); 2039 scoped_refptr<ForwardingFilter> second_filter = MakeForwardingFilter();
1987 2040
1988 host_.BlockRequestsForRoute(filter_->child_id(), 1); 2041 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 1));
1989 host_.BlockRequestsForRoute(filter_->child_id(), 2); 2042 host_.BlockRequestsForRoute(GlobalFrameRoutingId(filter_->child_id(), 2));
1990 host_.BlockRequestsForRoute(second_filter->child_id(), 1); 2043 host_.BlockRequestsForRoute(
2044 GlobalFrameRoutingId(second_filter->child_id(), 1));
1991 2045
1992 MakeTestRequestWithResourceType(filter_.get(), 0, 1, 2046 MakeTestRequestWithResourceType(filter_.get(), 0, 1,
1993 net::URLRequestTestJob::test_url_1(), 2047 net::URLRequestTestJob::test_url_1(),
1994 RESOURCE_TYPE_SUB_RESOURCE); 2048 RESOURCE_TYPE_SUB_RESOURCE);
1995 MakeTestRequestWithResourceType(filter_.get(), 1, 2, 2049 MakeTestRequestWithResourceType(filter_.get(), 1, 2,
1996 net::URLRequestTestJob::test_url_2(), 2050 net::URLRequestTestJob::test_url_2(),
1997 RESOURCE_TYPE_SUB_RESOURCE); 2051 RESOURCE_TYPE_SUB_RESOURCE);
1998 MakeTestRequestWithResourceType(filter_.get(), 0, 3, 2052 MakeTestRequestWithResourceType(filter_.get(), 0, 3,
1999 net::URLRequestTestJob::test_url_3(), 2053 net::URLRequestTestJob::test_url_3(),
2000 RESOURCE_TYPE_SUB_RESOURCE); 2054 RESOURCE_TYPE_SUB_RESOURCE);
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after
3539 return nullptr; 3593 return nullptr;
3540 } 3594 }
3541 3595
3542 net::URLRequestJob* TestURLRequestJobFactory::MaybeInterceptResponse( 3596 net::URLRequestJob* TestURLRequestJobFactory::MaybeInterceptResponse(
3543 net::URLRequest* request, 3597 net::URLRequest* request,
3544 net::NetworkDelegate* network_delegate) const { 3598 net::NetworkDelegate* network_delegate) const {
3545 return nullptr; 3599 return nullptr;
3546 } 3600 }
3547 3601
3548 } // namespace content 3602 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698