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

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

Powered by Google App Engine
This is Rietveld 408576698