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

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

Issue 2715423003: [Mojo-Loading] Use independent URLLoaderClient (Closed)
Patch Set: fix Created 3 years, 9 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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc e-loading
6 6
7 #include "content/browser/loader/resource_dispatcher_host_impl.h" 7 #include "content/browser/loader/resource_dispatcher_host_impl.h"
8 8
9 #include <stddef.h> 9 #include <stddef.h>
10 10
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 default: 227 default:
228 return false; 228 return false;
229 } 229 }
230 } 230 }
231 231
232 // Aborts a request before an URLRequest has actually been created. 232 // Aborts a request before an URLRequest has actually been created.
233 void AbortRequestBeforeItStarts( 233 void AbortRequestBeforeItStarts(
234 IPC::Sender* sender, 234 IPC::Sender* sender,
235 const SyncLoadResultCallback& sync_result_handler, 235 const SyncLoadResultCallback& sync_result_handler,
236 int request_id, 236 int request_id,
237 mojom::URLLoaderClientAssociatedPtr url_loader_client) { 237 mojom::URLLoaderClientPtr url_loader_client) {
238 if (sync_result_handler) { 238 if (sync_result_handler) {
239 SyncLoadResult result; 239 SyncLoadResult result;
240 result.error_code = net::ERR_ABORTED; 240 result.error_code = net::ERR_ABORTED;
241 sync_result_handler.Run(&result); 241 sync_result_handler.Run(&result);
242 } else { 242 } else {
243 // Tell the renderer that this request was disallowed. 243 // Tell the renderer that this request was disallowed.
244 ResourceRequestCompletionStatus request_complete_data; 244 ResourceRequestCompletionStatus request_complete_data;
245 request_complete_data.error_code = net::ERR_ABORTED; 245 request_complete_data.error_code = net::ERR_ABORTED;
246 request_complete_data.was_ignored_by_handler = false; 246 request_complete_data.was_ignored_by_handler = false;
247 request_complete_data.exists_in_cache = false; 247 request_complete_data.exists_in_cache = false;
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
1019 OnRequestResourceInternal(requester_info, routing_id, request_id, 1019 OnRequestResourceInternal(requester_info, routing_id, request_id,
1020 request_data, nullptr, nullptr); 1020 request_data, nullptr, nullptr);
1021 } 1021 }
1022 1022
1023 void ResourceDispatcherHostImpl::OnRequestResourceInternal( 1023 void ResourceDispatcherHostImpl::OnRequestResourceInternal(
1024 ResourceRequesterInfo* requester_info, 1024 ResourceRequesterInfo* requester_info,
1025 int routing_id, 1025 int routing_id,
1026 int request_id, 1026 int request_id,
1027 const ResourceRequest& request_data, 1027 const ResourceRequest& request_data,
1028 mojom::URLLoaderAssociatedRequest mojo_request, 1028 mojom::URLLoaderAssociatedRequest mojo_request,
1029 mojom::URLLoaderClientAssociatedPtr url_loader_client) { 1029 mojom::URLLoaderClientPtr url_loader_client) {
1030 DCHECK(requester_info->IsRenderer() || requester_info->IsNavigationPreload()); 1030 DCHECK(requester_info->IsRenderer() || requester_info->IsNavigationPreload());
1031 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. 1031 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed.
1032 tracked_objects::ScopedTracker tracking_profile( 1032 tracked_objects::ScopedTracker tracking_profile(
1033 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1033 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1034 "477117 ResourceDispatcherHostImpl::OnRequestResource")); 1034 "477117 ResourceDispatcherHostImpl::OnRequestResource"));
1035 // When logging time-to-network only care about main frame and non-transfer 1035 // When logging time-to-network only care about main frame and non-transfer
1036 // navigations. 1036 // navigations.
1037 // PlzNavigate: this log happens from NavigationRequest::OnRequestStarted 1037 // PlzNavigate: this log happens from NavigationRequest::OnRequestStarted
1038 // instead. 1038 // instead.
1039 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME && 1039 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME &&
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 return false; 1084 return false;
1085 } 1085 }
1086 1086
1087 void ResourceDispatcherHostImpl::UpdateRequestForTransfer( 1087 void ResourceDispatcherHostImpl::UpdateRequestForTransfer(
1088 ResourceRequesterInfo* requester_info, 1088 ResourceRequesterInfo* requester_info,
1089 int route_id, 1089 int route_id,
1090 int request_id, 1090 int request_id,
1091 const ResourceRequest& request_data, 1091 const ResourceRequest& request_data,
1092 LoaderMap::iterator iter, 1092 LoaderMap::iterator iter,
1093 mojom::URLLoaderAssociatedRequest mojo_request, 1093 mojom::URLLoaderAssociatedRequest mojo_request,
1094 mojom::URLLoaderClientAssociatedPtr url_loader_client) { 1094 mojom::URLLoaderClientPtr url_loader_client) {
1095 DCHECK(requester_info->IsRenderer()); 1095 DCHECK(requester_info->IsRenderer());
1096 int child_id = requester_info->child_id(); 1096 int child_id = requester_info->child_id();
1097 ResourceRequestInfoImpl* info = iter->second->GetRequestInfo(); 1097 ResourceRequestInfoImpl* info = iter->second->GetRequestInfo();
1098 GlobalFrameRoutingId old_routing_id(request_data.transferred_request_child_id, 1098 GlobalFrameRoutingId old_routing_id(request_data.transferred_request_child_id,
1099 info->GetRenderFrameID()); 1099 info->GetRenderFrameID());
1100 GlobalRequestID old_request_id(request_data.transferred_request_child_id, 1100 GlobalRequestID old_request_id(request_data.transferred_request_child_id,
1101 request_data.transferred_request_request_id); 1101 request_data.transferred_request_request_id);
1102 GlobalFrameRoutingId new_routing_id(child_id, request_data.render_frame_id); 1102 GlobalFrameRoutingId new_routing_id(child_id, request_data.render_frame_id);
1103 GlobalRequestID new_request_id(child_id, request_id); 1103 GlobalRequestID new_request_id(child_id, request_id);
1104 1104
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1167 } 1167 }
1168 } 1168 }
1169 } 1169 }
1170 1170
1171 void ResourceDispatcherHostImpl::CompleteTransfer( 1171 void ResourceDispatcherHostImpl::CompleteTransfer(
1172 ResourceRequesterInfo* requester_info, 1172 ResourceRequesterInfo* requester_info,
1173 int request_id, 1173 int request_id,
1174 const ResourceRequest& request_data, 1174 const ResourceRequest& request_data,
1175 int route_id, 1175 int route_id,
1176 mojom::URLLoaderAssociatedRequest mojo_request, 1176 mojom::URLLoaderAssociatedRequest mojo_request,
1177 mojom::URLLoaderClientAssociatedPtr url_loader_client) { 1177 mojom::URLLoaderClientPtr url_loader_client) {
1178 DCHECK(requester_info->IsRenderer()); 1178 DCHECK(requester_info->IsRenderer());
1179 // Caller should ensure that |request_data| is associated with a transfer. 1179 // Caller should ensure that |request_data| is associated with a transfer.
1180 DCHECK(request_data.transferred_request_child_id != -1 || 1180 DCHECK(request_data.transferred_request_child_id != -1 ||
1181 request_data.transferred_request_request_id != -1); 1181 request_data.transferred_request_request_id != -1);
1182 1182
1183 if (!IsResourceTypeFrame(request_data.resource_type)) { 1183 if (!IsResourceTypeFrame(request_data.resource_type)) {
1184 // Transfers apply only to navigational requests - the renderer seems to 1184 // Transfers apply only to navigational requests - the renderer seems to
1185 // have sent bogus IPC data. 1185 // have sent bogus IPC data.
1186 bad_message::ReceivedBadMessage( 1186 bad_message::ReceivedBadMessage(
1187 requester_info->filter(), 1187 requester_info->filter(),
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 pending_loader->CompleteTransfer(); 1222 pending_loader->CompleteTransfer();
1223 } 1223 }
1224 1224
1225 void ResourceDispatcherHostImpl::BeginRequest( 1225 void ResourceDispatcherHostImpl::BeginRequest(
1226 ResourceRequesterInfo* requester_info, 1226 ResourceRequesterInfo* requester_info,
1227 int request_id, 1227 int request_id,
1228 const ResourceRequest& request_data, 1228 const ResourceRequest& request_data,
1229 const SyncLoadResultCallback& sync_result_handler, // only valid for sync 1229 const SyncLoadResultCallback& sync_result_handler, // only valid for sync
1230 int route_id, 1230 int route_id,
1231 mojom::URLLoaderAssociatedRequest mojo_request, 1231 mojom::URLLoaderAssociatedRequest mojo_request,
1232 mojom::URLLoaderClientAssociatedPtr url_loader_client) { 1232 mojom::URLLoaderClientPtr url_loader_client) {
1233 DCHECK(requester_info->IsRenderer() || requester_info->IsNavigationPreload()); 1233 DCHECK(requester_info->IsRenderer() || requester_info->IsNavigationPreload());
1234 int child_id = requester_info->child_id(); 1234 int child_id = requester_info->child_id();
1235 1235
1236 // Reject request id that's currently in use. 1236 // Reject request id that's currently in use.
1237 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) { 1237 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) {
1238 // Navigation preload requests have child_id's of -1 and monotonically 1238 // Navigation preload requests have child_id's of -1 and monotonically
1239 // increasing request IDs allocated by MakeRequestID. 1239 // increasing request IDs allocated by MakeRequestID.
1240 DCHECK(requester_info->IsRenderer()); 1240 DCHECK(requester_info->IsRenderer());
1241 bad_message::ReceivedBadMessage(requester_info->filter(), 1241 bad_message::ReceivedBadMessage(requester_info->filter(),
1242 bad_message::RDH_INVALID_REQUEST_ID); 1242 bad_message::RDH_INVALID_REQUEST_ID);
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
1333 } 1333 }
1334 1334
1335 void ResourceDispatcherHostImpl::ContinuePendingBeginRequest( 1335 void ResourceDispatcherHostImpl::ContinuePendingBeginRequest(
1336 scoped_refptr<ResourceRequesterInfo> requester_info, 1336 scoped_refptr<ResourceRequesterInfo> requester_info,
1337 int request_id, 1337 int request_id,
1338 const ResourceRequest& request_data, 1338 const ResourceRequest& request_data,
1339 const SyncLoadResultCallback& sync_result_handler, // only valid for sync 1339 const SyncLoadResultCallback& sync_result_handler, // only valid for sync
1340 int route_id, 1340 int route_id,
1341 const net::HttpRequestHeaders& headers, 1341 const net::HttpRequestHeaders& headers,
1342 mojom::URLLoaderAssociatedRequest mojo_request, 1342 mojom::URLLoaderAssociatedRequest mojo_request,
1343 mojom::URLLoaderClientAssociatedPtr url_loader_client, 1343 mojom::URLLoaderClientPtr url_loader_client,
1344 bool continue_request, 1344 bool continue_request,
1345 int error_code) { 1345 int error_code) {
1346 DCHECK(requester_info->IsRenderer() || requester_info->IsNavigationPreload()); 1346 DCHECK(requester_info->IsRenderer() || requester_info->IsNavigationPreload());
1347 if (!continue_request) { 1347 if (!continue_request) {
1348 if (requester_info->IsRenderer()) { 1348 if (requester_info->IsRenderer()) {
1349 // TODO(ananta): Find a way to specify the right error code here. Passing 1349 // TODO(ananta): Find a way to specify the right error code here. Passing
1350 // in a non-content error code is not safe. 1350 // in a non-content error code is not safe.
1351 bad_message::ReceivedBadMessage(requester_info->filter(), 1351 bad_message::ReceivedBadMessage(requester_info->filter(),
1352 bad_message::RDH_ILLEGAL_ORIGIN); 1352 bad_message::RDH_ILLEGAL_ORIGIN);
1353 } 1353 }
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
1576 std::unique_ptr<ResourceHandler> 1576 std::unique_ptr<ResourceHandler>
1577 ResourceDispatcherHostImpl::CreateResourceHandler( 1577 ResourceDispatcherHostImpl::CreateResourceHandler(
1578 ResourceRequesterInfo* requester_info, 1578 ResourceRequesterInfo* requester_info,
1579 net::URLRequest* request, 1579 net::URLRequest* request,
1580 const ResourceRequest& request_data, 1580 const ResourceRequest& request_data,
1581 const SyncLoadResultCallback& sync_result_handler, 1581 const SyncLoadResultCallback& sync_result_handler,
1582 int route_id, 1582 int route_id,
1583 int child_id, 1583 int child_id,
1584 ResourceContext* resource_context, 1584 ResourceContext* resource_context,
1585 mojom::URLLoaderAssociatedRequest mojo_request, 1585 mojom::URLLoaderAssociatedRequest mojo_request,
1586 mojom::URLLoaderClientAssociatedPtr url_loader_client) { 1586 mojom::URLLoaderClientPtr url_loader_client) {
1587 DCHECK(requester_info->IsRenderer() || requester_info->IsNavigationPreload()); 1587 DCHECK(requester_info->IsRenderer() || requester_info->IsNavigationPreload());
1588 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed. 1588 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed.
1589 tracked_objects::ScopedTracker tracking_profile( 1589 tracked_objects::ScopedTracker tracking_profile(
1590 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1590 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1591 "456331 ResourceDispatcherHostImpl::CreateResourceHandler")); 1591 "456331 ResourceDispatcherHostImpl::CreateResourceHandler"));
1592 // Construct the IPC resource handler. 1592 // Construct the IPC resource handler.
1593 std::unique_ptr<ResourceHandler> handler; 1593 std::unique_ptr<ResourceHandler> handler;
1594 if (sync_result_handler) { 1594 if (sync_result_handler) {
1595 // download_to_file is not supported for synchronous requests. 1595 // download_to_file is not supported for synchronous requests.
1596 if (request_data.download_to_file) { 1596 if (request_data.download_to_file) {
(...skipping 682 matching lines...) Expand 10 before | Expand all | Expand 10 after
2279 const GlobalFrameRoutingId& global_routing_id) { 2279 const GlobalFrameRoutingId& global_routing_id) {
2280 CancelRequestsForRoute(global_routing_id); 2280 CancelRequestsForRoute(global_routing_id);
2281 } 2281 }
2282 2282
2283 void ResourceDispatcherHostImpl::OnRequestResourceWithMojo( 2283 void ResourceDispatcherHostImpl::OnRequestResourceWithMojo(
2284 ResourceRequesterInfo* requester_info, 2284 ResourceRequesterInfo* requester_info,
2285 int routing_id, 2285 int routing_id,
2286 int request_id, 2286 int request_id,
2287 const ResourceRequest& request, 2287 const ResourceRequest& request,
2288 mojom::URLLoaderAssociatedRequest mojo_request, 2288 mojom::URLLoaderAssociatedRequest mojo_request,
2289 mojom::URLLoaderClientAssociatedPtr url_loader_client) { 2289 mojom::URLLoaderClientPtr url_loader_client) {
2290 OnRequestResourceInternal(requester_info, routing_id, request_id, request, 2290 OnRequestResourceInternal(requester_info, routing_id, request_id, request,
2291 std::move(mojo_request), 2291 std::move(mojo_request),
2292 std::move(url_loader_client)); 2292 std::move(url_loader_client));
2293 } 2293 }
2294 2294
2295 void ResourceDispatcherHostImpl::OnSyncLoadWithMojo( 2295 void ResourceDispatcherHostImpl::OnSyncLoadWithMojo(
2296 ResourceRequesterInfo* requester_info, 2296 ResourceRequesterInfo* requester_info,
2297 int routing_id, 2297 int routing_id,
2298 int request_id, 2298 int request_id,
2299 const ResourceRequest& request_data, 2299 const ResourceRequest& request_data,
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
2795 &throttles); 2795 &throttles);
2796 if (!throttles.empty()) { 2796 if (!throttles.empty()) {
2797 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2797 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2798 std::move(throttles))); 2798 std::move(throttles)));
2799 } 2799 }
2800 } 2800 }
2801 return handler; 2801 return handler;
2802 } 2802 }
2803 2803
2804 } // namespace content 2804 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698