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

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

Issue 2449933003: Use Associated interfaces for mojo-loading (Closed)
Patch Set: fix Created 4 years, 1 month 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 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 default: 220 default:
221 return false; 221 return false;
222 } 222 }
223 } 223 }
224 224
225 // Aborts a request before an URLRequest has actually been created. 225 // Aborts a request before an URLRequest has actually been created.
226 void AbortRequestBeforeItStarts( 226 void AbortRequestBeforeItStarts(
227 ResourceMessageFilter* filter, 227 ResourceMessageFilter* filter,
228 const SyncLoadResultCallback& sync_result_handler, 228 const SyncLoadResultCallback& sync_result_handler,
229 int request_id, 229 int request_id,
230 mojom::URLLoaderClientPtr url_loader_client) { 230 mojom::URLLoaderClientAssociatedPtr url_loader_client) {
231 if (sync_result_handler) { 231 if (sync_result_handler) {
232 SyncLoadResult result; 232 SyncLoadResult result;
233 result.error_code = net::ERR_ABORTED; 233 result.error_code = net::ERR_ABORTED;
234 sync_result_handler.Run(&result); 234 sync_result_handler.Run(&result);
235 } else { 235 } else {
236 // Tell the renderer that this request was disallowed. 236 // Tell the renderer that this request was disallowed.
237 ResourceRequestCompletionStatus request_complete_data; 237 ResourceRequestCompletionStatus request_complete_data;
238 request_complete_data.error_code = net::ERR_ABORTED; 238 request_complete_data.error_code = net::ERR_ABORTED;
239 request_complete_data.was_ignored_by_handler = false; 239 request_complete_data.was_ignored_by_handler = false;
240 request_complete_data.exists_in_cache = false; 240 request_complete_data.exists_in_cache = false;
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 int request_id, 1050 int request_id,
1051 const ResourceRequest& request_data) { 1051 const ResourceRequest& request_data) {
1052 OnRequestResourceInternal(routing_id, request_id, request_data, nullptr, 1052 OnRequestResourceInternal(routing_id, request_id, request_data, nullptr,
1053 nullptr); 1053 nullptr);
1054 } 1054 }
1055 1055
1056 void ResourceDispatcherHostImpl::OnRequestResourceInternal( 1056 void ResourceDispatcherHostImpl::OnRequestResourceInternal(
1057 int routing_id, 1057 int routing_id,
1058 int request_id, 1058 int request_id,
1059 const ResourceRequest& request_data, 1059 const ResourceRequest& request_data,
1060 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 1060 mojom::URLLoaderAssociatedRequest mojo_request,
1061 mojom::URLLoaderClientPtr url_loader_client) { 1061 mojom::URLLoaderClientAssociatedPtr url_loader_client) {
1062 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. 1062 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed.
1063 tracked_objects::ScopedTracker tracking_profile( 1063 tracked_objects::ScopedTracker tracking_profile(
1064 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1064 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1065 "477117 ResourceDispatcherHostImpl::OnRequestResource")); 1065 "477117 ResourceDispatcherHostImpl::OnRequestResource"));
1066 // When logging time-to-network only care about main frame and non-transfer 1066 // When logging time-to-network only care about main frame and non-transfer
1067 // navigations. 1067 // navigations.
1068 // PlzNavigate: this log happens from NavigationRequest::OnRequestStarted 1068 // PlzNavigate: this log happens from NavigationRequest::OnRequestStarted
1069 // instead. 1069 // instead.
1070 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME && 1070 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME &&
1071 request_data.transferred_request_request_id == -1 && 1071 request_data.transferred_request_request_id == -1 &&
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1242 // If the request is transferring to a new process, we can update our 1242 // If the request is transferring to a new process, we can update our
1243 // state and let it resume with its existing ResourceHandlers. 1243 // state and let it resume with its existing ResourceHandlers.
1244 UpdateRequestForTransfer(filter_->child_id(), route_id, request_id, 1244 UpdateRequestForTransfer(filter_->child_id(), route_id, request_id,
1245 request_data, it); 1245 request_data, it);
1246 pending_loader->CompleteTransfer(); 1246 pending_loader->CompleteTransfer();
1247 } 1247 }
1248 1248
1249 void ResourceDispatcherHostImpl::BeginRequest( 1249 void ResourceDispatcherHostImpl::BeginRequest(
1250 int request_id, 1250 int request_id,
1251 const ResourceRequest& request_data, 1251 const ResourceRequest& request_data,
1252 const SyncLoadResultCallback& sync_result_handler, // only valid for sync 1252 const SyncLoadResultCallback& sync_result_handler, // only valid for sync
1253 int route_id, 1253 int route_id,
1254 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 1254 mojom::URLLoaderAssociatedRequest mojo_request,
1255 mojom::URLLoaderClientPtr url_loader_client) { 1255 mojom::URLLoaderClientAssociatedPtr url_loader_client) {
1256 int process_type = filter_->process_type(); 1256 int process_type = filter_->process_type();
1257 int child_id = filter_->child_id(); 1257 int child_id = filter_->child_id();
1258 1258
1259 // Reject request id that's currently in use. 1259 // Reject request id that's currently in use.
1260 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) { 1260 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) {
1261 bad_message::ReceivedBadMessage(filter_, 1261 bad_message::ReceivedBadMessage(filter_,
1262 bad_message::RDH_INVALID_REQUEST_ID); 1262 bad_message::RDH_INVALID_REQUEST_ID);
1263 return; 1263 return;
1264 } 1264 }
1265 1265
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1345 } 1345 }
1346 } 1346 }
1347 ContinuePendingBeginRequest(request_id, request_data, sync_result_handler, 1347 ContinuePendingBeginRequest(request_id, request_data, sync_result_handler,
1348 route_id, headers, std::move(mojo_request), 1348 route_id, headers, std::move(mojo_request),
1349 std::move(url_loader_client), true, 0); 1349 std::move(url_loader_client), true, 0);
1350 } 1350 }
1351 1351
1352 void ResourceDispatcherHostImpl::ContinuePendingBeginRequest( 1352 void ResourceDispatcherHostImpl::ContinuePendingBeginRequest(
1353 int request_id, 1353 int request_id,
1354 const ResourceRequest& request_data, 1354 const ResourceRequest& request_data,
1355 const SyncLoadResultCallback& sync_result_handler, // only valid for sync 1355 const SyncLoadResultCallback& sync_result_handler, // only valid for sync
1356 int route_id, 1356 int route_id,
1357 const net::HttpRequestHeaders& headers, 1357 const net::HttpRequestHeaders& headers,
1358 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 1358 mojom::URLLoaderAssociatedRequest mojo_request,
1359 mojom::URLLoaderClientPtr url_loader_client, 1359 mojom::URLLoaderClientAssociatedPtr url_loader_client,
1360 bool continue_request, 1360 bool continue_request,
1361 int error_code) { 1361 int error_code) {
1362 if (!continue_request) { 1362 if (!continue_request) {
1363 // TODO(ananta): Find a way to specify the right error code here. Passing 1363 // TODO(ananta): Find a way to specify the right error code here. Passing
1364 // in a non-content error code is not safe. 1364 // in a non-content error code is not safe.
1365 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_ILLEGAL_ORIGIN); 1365 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_ILLEGAL_ORIGIN);
1366 AbortRequestBeforeItStarts(filter_, sync_result_handler, request_id, 1366 AbortRequestBeforeItStarts(filter_, sync_result_handler, request_id,
1367 std::move(url_loader_client)); 1367 std::move(url_loader_client));
1368 return; 1368 return;
1369 } 1369 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1581 1581
1582 std::unique_ptr<ResourceHandler> 1582 std::unique_ptr<ResourceHandler>
1583 ResourceDispatcherHostImpl::CreateResourceHandler( 1583 ResourceDispatcherHostImpl::CreateResourceHandler(
1584 net::URLRequest* request, 1584 net::URLRequest* request,
1585 const ResourceRequest& request_data, 1585 const ResourceRequest& request_data,
1586 const SyncLoadResultCallback& sync_result_handler, 1586 const SyncLoadResultCallback& sync_result_handler,
1587 int route_id, 1587 int route_id,
1588 int process_type, 1588 int process_type,
1589 int child_id, 1589 int child_id,
1590 ResourceContext* resource_context, 1590 ResourceContext* resource_context,
1591 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 1591 mojom::URLLoaderAssociatedRequest mojo_request,
1592 mojom::URLLoaderClientPtr url_loader_client) { 1592 mojom::URLLoaderClientAssociatedPtr url_loader_client) {
1593 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed. 1593 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed.
1594 tracked_objects::ScopedTracker tracking_profile( 1594 tracked_objects::ScopedTracker tracking_profile(
1595 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1595 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1596 "456331 ResourceDispatcherHostImpl::CreateResourceHandler")); 1596 "456331 ResourceDispatcherHostImpl::CreateResourceHandler"));
1597 // Construct the IPC resource handler. 1597 // Construct the IPC resource handler.
1598 std::unique_ptr<ResourceHandler> handler; 1598 std::unique_ptr<ResourceHandler> handler;
1599 if (sync_result_handler) { 1599 if (sync_result_handler) {
1600 // download_to_file is not supported for synchronous requests. 1600 // download_to_file is not supported for synchronous requests.
1601 if (request_data.download_to_file) { 1601 if (request_data.download_to_file) {
1602 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_BAD_DOWNLOAD); 1602 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_BAD_DOWNLOAD);
(...skipping 691 matching lines...) Expand 10 before | Expand all | Expand 10 after
2294 2294
2295 void ResourceDispatcherHostImpl::OnRenderFrameDeleted( 2295 void ResourceDispatcherHostImpl::OnRenderFrameDeleted(
2296 const GlobalFrameRoutingId& global_routing_id) { 2296 const GlobalFrameRoutingId& global_routing_id) {
2297 CancelRequestsForRoute(global_routing_id); 2297 CancelRequestsForRoute(global_routing_id);
2298 } 2298 }
2299 2299
2300 void ResourceDispatcherHostImpl::OnRequestResourceWithMojo( 2300 void ResourceDispatcherHostImpl::OnRequestResourceWithMojo(
2301 int routing_id, 2301 int routing_id,
2302 int request_id, 2302 int request_id,
2303 const ResourceRequest& request, 2303 const ResourceRequest& request,
2304 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 2304 mojom::URLLoaderAssociatedRequest mojo_request,
2305 mojom::URLLoaderClientPtr url_loader_client, 2305 mojom::URLLoaderClientAssociatedPtr url_loader_client,
2306 ResourceMessageFilter* filter) { 2306 ResourceMessageFilter* filter) {
2307 filter_ = filter; 2307 filter_ = filter;
2308 OnRequestResourceInternal(routing_id, request_id, request, 2308 OnRequestResourceInternal(routing_id, request_id, request,
2309 std::move(mojo_request), 2309 std::move(mojo_request),
2310 std::move(url_loader_client)); 2310 std::move(url_loader_client));
2311 filter_ = nullptr; 2311 filter_ = nullptr;
2312 } 2312 }
2313 2313
2314 void ResourceDispatcherHostImpl::OnSyncLoadWithMojo( 2314 void ResourceDispatcherHostImpl::OnSyncLoadWithMojo(
2315 int routing_id, 2315 int routing_id,
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
2790 &throttles); 2790 &throttles);
2791 if (!throttles.empty()) { 2791 if (!throttles.empty()) {
2792 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2792 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2793 std::move(throttles))); 2793 std::move(throttles)));
2794 } 2794 }
2795 } 2795 }
2796 return handler; 2796 return handler;
2797 } 2797 }
2798 2798
2799 } // namespace content 2799 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698