OLD | NEW |
---|---|
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 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1190 request_id, url, RESOURCE_TYPE_SUB_RESOURCE); | 1190 request_id, url, RESOURCE_TYPE_SUB_RESOURCE); |
1191 } | 1191 } |
1192 | 1192 |
1193 void ResourceDispatcherHostTest:: | 1193 void ResourceDispatcherHostTest:: |
1194 MakeWebContentsAssociatedTestRequestWithResourceType(int request_id, | 1194 MakeWebContentsAssociatedTestRequestWithResourceType(int request_id, |
1195 const GURL& url, | 1195 const GURL& url, |
1196 ResourceType type) { | 1196 ResourceType type) { |
1197 ResourceRequest request = CreateResourceRequest("GET", type, url); | 1197 ResourceRequest request = CreateResourceRequest("GET", type, url); |
1198 request.origin_pid = web_contents_->GetRenderProcessHost()->GetID(); | 1198 request.origin_pid = web_contents_->GetRenderProcessHost()->GetID(); |
1199 request.render_frame_id = web_contents_->GetMainFrame()->GetRoutingID(); | 1199 request.render_frame_id = web_contents_->GetMainFrame()->GetRoutingID(); |
1200 ResourceHostMsg_RequestResource msg(web_contents_->GetRoutingID(), request_id, | 1200 ResourceHostMsg_RequestResource msg( |
1201 request); | 1201 web_contents_->GetRenderViewHost()->GetRoutingID(), request_id, request); |
mmenke
2016/11/28 18:53:25
Need to include RenderViewHost header, and update
davidsac (gone - try alexmos)
2016/11/28 19:12:42
Done.
| |
1202 host_.OnMessageReceived(msg, web_contents_filter_.get()); | 1202 host_.OnMessageReceived(msg, web_contents_filter_.get()); |
1203 KickOffRequest(); | 1203 KickOffRequest(); |
1204 } | 1204 } |
1205 | 1205 |
1206 void ResourceDispatcherHostTest::MakeTestRequestWithPriority( | 1206 void ResourceDispatcherHostTest::MakeTestRequestWithPriority( |
1207 int render_view_id, | 1207 int render_view_id, |
1208 int request_id, | 1208 int request_id, |
1209 net::RequestPriority priority) { | 1209 net::RequestPriority priority) { |
1210 MakeTestRequestWithPriorityAndRenderFrame(render_view_id, -1, request_id, | 1210 MakeTestRequestWithPriorityAndRenderFrame(render_view_id, -1, request_id, |
1211 priority); | 1211 priority); |
(...skipping 16 matching lines...) Expand all Loading... | |
1228 int request_id, | 1228 int request_id, |
1229 const GURL& url) { | 1229 const GURL& url) { |
1230 net::URLRequestContext* request_context = | 1230 net::URLRequestContext* request_context = |
1231 browser_context_->GetResourceContext()->GetRequestContext(); | 1231 browser_context_->GetResourceContext()->GetRequestContext(); |
1232 std::unique_ptr<net::URLRequest> request( | 1232 std::unique_ptr<net::URLRequest> request( |
1233 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL)); | 1233 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL)); |
1234 DownloadManagerImpl::BeginDownloadRequest( | 1234 DownloadManagerImpl::BeginDownloadRequest( |
1235 std::move(request), Referrer(), browser_context_->GetResourceContext(), | 1235 std::move(request), Referrer(), browser_context_->GetResourceContext(), |
1236 false, // is_content_initiated | 1236 false, // is_content_initiated |
1237 web_contents_->GetRenderProcessHost()->GetID(), | 1237 web_contents_->GetRenderProcessHost()->GetID(), |
1238 web_contents_->GetRoutingID(), | 1238 web_contents_->GetRenderViewHost()->GetRoutingID(), |
1239 web_contents_->GetMainFrame()->GetRoutingID(), false); | 1239 web_contents_->GetMainFrame()->GetRoutingID(), false); |
1240 } | 1240 } |
1241 | 1241 |
1242 void ResourceDispatcherHostTest::CancelRequest(int request_id) { | 1242 void ResourceDispatcherHostTest::CancelRequest(int request_id) { |
1243 host_.CancelRequest(filter_->child_id(), request_id); | 1243 host_.CancelRequest(filter_->child_id(), request_id); |
1244 } | 1244 } |
1245 | 1245 |
1246 void ResourceDispatcherHostTest::CompleteStartRequest(int request_id) { | 1246 void ResourceDispatcherHostTest::CompleteStartRequest(int request_id) { |
1247 CompleteStartRequest(filter_.get(), request_id); | 1247 CompleteStartRequest(filter_.get(), request_id); |
1248 } | 1248 } |
(...skipping 1510 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2759 // And now simulate a cancellation coming from the renderer. | 2759 // And now simulate a cancellation coming from the renderer. |
2760 ResourceHostMsg_CancelRequest msg(request_id); | 2760 ResourceHostMsg_CancelRequest msg(request_id); |
2761 host_.OnMessageReceived(msg, web_contents_filter_.get()); | 2761 host_.OnMessageReceived(msg, web_contents_filter_.get()); |
2762 | 2762 |
2763 // Since the request is marked as being transferred, | 2763 // Since the request is marked as being transferred, |
2764 // the cancellation above should have been ignored and the request | 2764 // the cancellation above should have been ignored and the request |
2765 // should still be alive. | 2765 // should still be alive. |
2766 EXPECT_EQ(1, host_.pending_requests()); | 2766 EXPECT_EQ(1, host_.pending_requests()); |
2767 | 2767 |
2768 // Cancelling by other methods shouldn't work either. | 2768 // Cancelling by other methods shouldn't work either. |
2769 host_.CancelRequestsForProcess(web_contents_->GetRoutingID()); | 2769 host_.CancelRequestsForProcess( |
2770 web_contents_->GetRenderViewHost()->GetRoutingID()); | |
2770 EXPECT_EQ(1, host_.pending_requests()); | 2771 EXPECT_EQ(1, host_.pending_requests()); |
2771 | 2772 |
2772 // Cancelling by context should work. | 2773 // Cancelling by context should work. |
2773 host_.CancelRequestsForContext(web_contents_filter_->resource_context()); | 2774 host_.CancelRequestsForContext(web_contents_filter_->resource_context()); |
2774 EXPECT_EQ(0, host_.pending_requests()); | 2775 EXPECT_EQ(0, host_.pending_requests()); |
2775 } | 2776 } |
2776 | 2777 |
2777 // Test transferred navigations with text/html, which doesn't trigger any | 2778 // Test transferred navigations with text/html, which doesn't trigger any |
2778 // content sniffing. | 2779 // content sniffing. |
2779 TEST_P(ResourceDispatcherHostTest, TransferNavigationHtml) { | 2780 TEST_P(ResourceDispatcherHostTest, TransferNavigationHtml) { |
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3935 return nullptr; | 3936 return nullptr; |
3936 } | 3937 } |
3937 | 3938 |
3938 INSTANTIATE_TEST_CASE_P( | 3939 INSTANTIATE_TEST_CASE_P( |
3939 ResourceDispatcherHostTests, | 3940 ResourceDispatcherHostTests, |
3940 ResourceDispatcherHostTest, | 3941 ResourceDispatcherHostTest, |
3941 testing::Values(TestConfig::kDefault, | 3942 testing::Values(TestConfig::kDefault, |
3942 TestConfig::kOptimizeIPCForSmallResourceEnabled)); | 3943 TestConfig::kOptimizeIPCForSmallResourceEnabled)); |
3943 | 3944 |
3944 } // namespace content | 3945 } // namespace content |
OLD | NEW |