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 25 matching lines...) Expand all Loading... |
36 #include "content/browser/loader/resource_request_info_impl.h" | 36 #include "content/browser/loader/resource_request_info_impl.h" |
37 #include "content/browser/loader_delegate_impl.h" | 37 #include "content/browser/loader_delegate_impl.h" |
38 #include "content/common/appcache_interfaces.h" | 38 #include "content/common/appcache_interfaces.h" |
39 #include "content/common/child_process_host_impl.h" | 39 #include "content/common/child_process_host_impl.h" |
40 #include "content/common/navigation_params.h" | 40 #include "content/common/navigation_params.h" |
41 #include "content/common/resource_messages.h" | 41 #include "content/common/resource_messages.h" |
42 #include "content/common/resource_request.h" | 42 #include "content/common/resource_request.h" |
43 #include "content/common/view_messages.h" | 43 #include "content/common/view_messages.h" |
44 #include "content/public/browser/global_request_id.h" | 44 #include "content/public/browser/global_request_id.h" |
45 #include "content/public/browser/render_process_host.h" | 45 #include "content/public/browser/render_process_host.h" |
| 46 #include "content/public/browser/render_view_host.h" |
46 #include "content/public/browser/resource_context.h" | 47 #include "content/public/browser/resource_context.h" |
47 #include "content/public/browser/resource_dispatcher_host_delegate.h" | 48 #include "content/public/browser/resource_dispatcher_host_delegate.h" |
48 #include "content/public/browser/resource_request_info.h" | 49 #include "content/public/browser/resource_request_info.h" |
49 #include "content/public/browser/resource_throttle.h" | 50 #include "content/public/browser/resource_throttle.h" |
50 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
51 #include "content/public/browser/web_contents_observer.h" | 52 #include "content/public/browser/web_contents_observer.h" |
52 #include "content/public/common/browser_side_navigation_policy.h" | 53 #include "content/public/common/browser_side_navigation_policy.h" |
53 #include "content/public/common/child_process_host.h" | 54 #include "content/public/common/child_process_host.h" |
54 #include "content/public/common/content_features.h" | 55 #include "content/public/common/content_features.h" |
55 #include "content/public/common/process_type.h" | 56 #include "content/public/common/process_type.h" |
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1192 request_id, url, RESOURCE_TYPE_SUB_RESOURCE); | 1193 request_id, url, RESOURCE_TYPE_SUB_RESOURCE); |
1193 } | 1194 } |
1194 | 1195 |
1195 void ResourceDispatcherHostTest:: | 1196 void ResourceDispatcherHostTest:: |
1196 MakeWebContentsAssociatedTestRequestWithResourceType(int request_id, | 1197 MakeWebContentsAssociatedTestRequestWithResourceType(int request_id, |
1197 const GURL& url, | 1198 const GURL& url, |
1198 ResourceType type) { | 1199 ResourceType type) { |
1199 ResourceRequest request = CreateResourceRequest("GET", type, url); | 1200 ResourceRequest request = CreateResourceRequest("GET", type, url); |
1200 request.origin_pid = web_contents_->GetRenderProcessHost()->GetID(); | 1201 request.origin_pid = web_contents_->GetRenderProcessHost()->GetID(); |
1201 request.render_frame_id = web_contents_->GetMainFrame()->GetRoutingID(); | 1202 request.render_frame_id = web_contents_->GetMainFrame()->GetRoutingID(); |
1202 ResourceHostMsg_RequestResource msg(web_contents_->GetRoutingID(), request_id, | 1203 ResourceHostMsg_RequestResource msg( |
1203 request); | 1204 web_contents_->GetRenderViewHost()->GetRoutingID(), request_id, request); |
1204 OnMessageReceived(msg, web_contents_filter_.get()); | 1205 OnMessageReceived(msg, web_contents_filter_.get()); |
1205 KickOffRequest(); | 1206 KickOffRequest(); |
1206 } | 1207 } |
1207 | 1208 |
1208 void ResourceDispatcherHostTest::MakeTestRequestWithPriority( | 1209 void ResourceDispatcherHostTest::MakeTestRequestWithPriority( |
1209 int render_view_id, | 1210 int render_view_id, |
1210 int request_id, | 1211 int request_id, |
1211 net::RequestPriority priority) { | 1212 net::RequestPriority priority) { |
1212 MakeTestRequestWithPriorityAndRenderFrame(render_view_id, -1, request_id, | 1213 MakeTestRequestWithPriorityAndRenderFrame(render_view_id, -1, request_id, |
1213 priority); | 1214 priority); |
(...skipping 16 matching lines...) Expand all Loading... |
1230 int request_id, | 1231 int request_id, |
1231 const GURL& url) { | 1232 const GURL& url) { |
1232 net::URLRequestContext* request_context = | 1233 net::URLRequestContext* request_context = |
1233 browser_context_->GetResourceContext()->GetRequestContext(); | 1234 browser_context_->GetResourceContext()->GetRequestContext(); |
1234 std::unique_ptr<net::URLRequest> request( | 1235 std::unique_ptr<net::URLRequest> request( |
1235 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL)); | 1236 request_context->CreateRequest(url, net::DEFAULT_PRIORITY, NULL)); |
1236 DownloadManagerImpl::BeginDownloadRequest( | 1237 DownloadManagerImpl::BeginDownloadRequest( |
1237 std::move(request), Referrer(), browser_context_->GetResourceContext(), | 1238 std::move(request), Referrer(), browser_context_->GetResourceContext(), |
1238 false, // is_content_initiated | 1239 false, // is_content_initiated |
1239 web_contents_->GetRenderProcessHost()->GetID(), | 1240 web_contents_->GetRenderProcessHost()->GetID(), |
1240 web_contents_->GetRoutingID(), | 1241 web_contents_->GetRenderViewHost()->GetRoutingID(), |
1241 web_contents_->GetMainFrame()->GetRoutingID(), false); | 1242 web_contents_->GetMainFrame()->GetRoutingID(), false); |
1242 } | 1243 } |
1243 | 1244 |
1244 void ResourceDispatcherHostTest::CancelRequest(int request_id) { | 1245 void ResourceDispatcherHostTest::CancelRequest(int request_id) { |
1245 host_.CancelRequest(filter_->child_id(), request_id); | 1246 host_.CancelRequest(filter_->child_id(), request_id); |
1246 } | 1247 } |
1247 | 1248 |
1248 void ResourceDispatcherHostTest::CompleteStartRequest(int request_id) { | 1249 void ResourceDispatcherHostTest::CompleteStartRequest(int request_id) { |
1249 CompleteStartRequest(filter_.get(), request_id); | 1250 CompleteStartRequest(filter_.get(), request_id); |
1250 } | 1251 } |
(...skipping 1507 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2758 // And now simulate a cancellation coming from the renderer. | 2759 // And now simulate a cancellation coming from the renderer. |
2759 ResourceHostMsg_CancelRequest msg(request_id); | 2760 ResourceHostMsg_CancelRequest msg(request_id); |
2760 OnMessageReceived(msg, web_contents_filter_.get()); | 2761 OnMessageReceived(msg, web_contents_filter_.get()); |
2761 | 2762 |
2762 // Since the request is marked as being transferred, | 2763 // Since the request is marked as being transferred, |
2763 // the cancellation above should have been ignored and the request | 2764 // the cancellation above should have been ignored and the request |
2764 // should still be alive. | 2765 // should still be alive. |
2765 EXPECT_EQ(1, host_.pending_requests()); | 2766 EXPECT_EQ(1, host_.pending_requests()); |
2766 | 2767 |
2767 // Cancelling by other methods shouldn't work either. | 2768 // Cancelling by other methods shouldn't work either. |
2768 host_.CancelRequestsForProcess(web_contents_->GetRoutingID()); | 2769 host_.CancelRequestsForProcess( |
| 2770 web_contents_->GetRenderViewHost()->GetRoutingID()); |
2769 EXPECT_EQ(1, host_.pending_requests()); | 2771 EXPECT_EQ(1, host_.pending_requests()); |
2770 | 2772 |
2771 // Cancelling by context should work. | 2773 // Cancelling by context should work. |
2772 host_.CancelRequestsForContext(web_contents_filter_->resource_context()); | 2774 host_.CancelRequestsForContext(web_contents_filter_->resource_context()); |
2773 EXPECT_EQ(0, host_.pending_requests()); | 2775 EXPECT_EQ(0, host_.pending_requests()); |
2774 } | 2776 } |
2775 | 2777 |
2776 // Test transferred navigations with text/html, which doesn't trigger any | 2778 // Test transferred navigations with text/html, which doesn't trigger any |
2777 // content sniffing. | 2779 // content sniffing. |
2778 TEST_P(ResourceDispatcherHostTest, TransferNavigationHtml) { | 2780 TEST_P(ResourceDispatcherHostTest, TransferNavigationHtml) { |
(...skipping 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3934 return nullptr; | 3936 return nullptr; |
3935 } | 3937 } |
3936 | 3938 |
3937 INSTANTIATE_TEST_CASE_P( | 3939 INSTANTIATE_TEST_CASE_P( |
3938 ResourceDispatcherHostTests, | 3940 ResourceDispatcherHostTests, |
3939 ResourceDispatcherHostTest, | 3941 ResourceDispatcherHostTest, |
3940 testing::Values(TestConfig::kDefault, | 3942 testing::Values(TestConfig::kDefault, |
3941 TestConfig::kOptimizeIPCForSmallResourceEnabled)); | 3943 TestConfig::kOptimizeIPCForSmallResourceEnabled)); |
3942 | 3944 |
3943 } // namespace content | 3945 } // namespace content |
OLD | NEW |