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

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 808 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 int request_id, 1049 int request_id,
1050 const ResourceRequest& request_data) { 1050 const ResourceRequest& request_data) {
1051 OnRequestResourceInternal(routing_id, request_id, request_data, nullptr, 1051 OnRequestResourceInternal(routing_id, request_id, request_data, nullptr,
1052 nullptr); 1052 nullptr);
1053 } 1053 }
1054 1054
1055 void ResourceDispatcherHostImpl::OnRequestResourceInternal( 1055 void ResourceDispatcherHostImpl::OnRequestResourceInternal(
1056 int routing_id, 1056 int routing_id,
1057 int request_id, 1057 int request_id,
1058 const ResourceRequest& request_data, 1058 const ResourceRequest& request_data,
1059 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 1059 mojom::URLLoaderAssociatedRequest mojo_request,
1060 mojom::URLLoaderClientPtr url_loader_client) { 1060 mojom::URLLoaderClientAssociatedPtr url_loader_client) {
1061 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed. 1061 // TODO(pkasting): Remove ScopedTracker below once crbug.com/477117 is fixed.
1062 tracked_objects::ScopedTracker tracking_profile( 1062 tracked_objects::ScopedTracker tracking_profile(
1063 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1063 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1064 "477117 ResourceDispatcherHostImpl::OnRequestResource")); 1064 "477117 ResourceDispatcherHostImpl::OnRequestResource"));
1065 // When logging time-to-network only care about main frame and non-transfer 1065 // When logging time-to-network only care about main frame and non-transfer
1066 // navigations. 1066 // navigations.
1067 // PlzNavigate: this log happens from NavigationRequest::OnRequestStarted 1067 // PlzNavigate: this log happens from NavigationRequest::OnRequestStarted
1068 // instead. 1068 // instead.
1069 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME && 1069 if (request_data.resource_type == RESOURCE_TYPE_MAIN_FRAME &&
1070 request_data.transferred_request_request_id == -1 && 1070 request_data.transferred_request_request_id == -1 &&
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 // If the request is transferring to a new process, we can update our 1241 // If the request is transferring to a new process, we can update our
1242 // state and let it resume with its existing ResourceHandlers. 1242 // state and let it resume with its existing ResourceHandlers.
1243 UpdateRequestForTransfer(filter_->child_id(), route_id, request_id, 1243 UpdateRequestForTransfer(filter_->child_id(), route_id, request_id,
1244 request_data, it); 1244 request_data, it);
1245 pending_loader->CompleteTransfer(); 1245 pending_loader->CompleteTransfer();
1246 } 1246 }
1247 1247
1248 void ResourceDispatcherHostImpl::BeginRequest( 1248 void ResourceDispatcherHostImpl::BeginRequest(
1249 int request_id, 1249 int request_id,
1250 const ResourceRequest& request_data, 1250 const ResourceRequest& request_data,
1251 const SyncLoadResultCallback& sync_result_handler, // only valid for sync 1251 const SyncLoadResultCallback& sync_result_handler, // only valid for sync
1252 int route_id, 1252 int route_id,
1253 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 1253 mojom::URLLoaderAssociatedRequest mojo_request,
1254 mojom::URLLoaderClientPtr url_loader_client) { 1254 mojom::URLLoaderClientAssociatedPtr url_loader_client) {
1255 int process_type = filter_->process_type(); 1255 int process_type = filter_->process_type();
1256 int child_id = filter_->child_id(); 1256 int child_id = filter_->child_id();
1257 1257
1258 // Reject request id that's currently in use. 1258 // Reject request id that's currently in use.
1259 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) { 1259 if (IsRequestIDInUse(GlobalRequestID(child_id, request_id))) {
1260 bad_message::ReceivedBadMessage(filter_, 1260 bad_message::ReceivedBadMessage(filter_,
1261 bad_message::RDH_INVALID_REQUEST_ID); 1261 bad_message::RDH_INVALID_REQUEST_ID);
1262 return; 1262 return;
1263 } 1263 }
1264 1264
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 } 1344 }
1345 } 1345 }
1346 ContinuePendingBeginRequest(request_id, request_data, sync_result_handler, 1346 ContinuePendingBeginRequest(request_id, request_data, sync_result_handler,
1347 route_id, headers, std::move(mojo_request), 1347 route_id, headers, std::move(mojo_request),
1348 std::move(url_loader_client), true, 0); 1348 std::move(url_loader_client), true, 0);
1349 } 1349 }
1350 1350
1351 void ResourceDispatcherHostImpl::ContinuePendingBeginRequest( 1351 void ResourceDispatcherHostImpl::ContinuePendingBeginRequest(
1352 int request_id, 1352 int request_id,
1353 const ResourceRequest& request_data, 1353 const ResourceRequest& request_data,
1354 const SyncLoadResultCallback& sync_result_handler, // only valid for sync 1354 const SyncLoadResultCallback& sync_result_handler, // only valid for sync
1355 int route_id, 1355 int route_id,
1356 const net::HttpRequestHeaders& headers, 1356 const net::HttpRequestHeaders& headers,
1357 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 1357 mojom::URLLoaderAssociatedRequest mojo_request,
1358 mojom::URLLoaderClientPtr url_loader_client, 1358 mojom::URLLoaderClientAssociatedPtr url_loader_client,
1359 bool continue_request, 1359 bool continue_request,
1360 int error_code) { 1360 int error_code) {
1361 if (!continue_request) { 1361 if (!continue_request) {
1362 // TODO(ananta): Find a way to specify the right error code here. Passing 1362 // TODO(ananta): Find a way to specify the right error code here. Passing
1363 // in a non-content error code is not safe. 1363 // in a non-content error code is not safe.
1364 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_ILLEGAL_ORIGIN); 1364 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_ILLEGAL_ORIGIN);
1365 AbortRequestBeforeItStarts(filter_, sync_result_handler, request_id, 1365 AbortRequestBeforeItStarts(filter_, sync_result_handler, request_id,
1366 std::move(url_loader_client)); 1366 std::move(url_loader_client));
1367 return; 1367 return;
1368 } 1368 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 1580
1581 std::unique_ptr<ResourceHandler> 1581 std::unique_ptr<ResourceHandler>
1582 ResourceDispatcherHostImpl::CreateResourceHandler( 1582 ResourceDispatcherHostImpl::CreateResourceHandler(
1583 net::URLRequest* request, 1583 net::URLRequest* request,
1584 const ResourceRequest& request_data, 1584 const ResourceRequest& request_data,
1585 const SyncLoadResultCallback& sync_result_handler, 1585 const SyncLoadResultCallback& sync_result_handler,
1586 int route_id, 1586 int route_id,
1587 int process_type, 1587 int process_type,
1588 int child_id, 1588 int child_id,
1589 ResourceContext* resource_context, 1589 ResourceContext* resource_context,
1590 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 1590 mojom::URLLoaderAssociatedRequest mojo_request,
1591 mojom::URLLoaderClientPtr url_loader_client) { 1591 mojom::URLLoaderClientAssociatedPtr url_loader_client) {
1592 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed. 1592 // TODO(pkasting): Remove ScopedTracker below once crbug.com/456331 is fixed.
1593 tracked_objects::ScopedTracker tracking_profile( 1593 tracked_objects::ScopedTracker tracking_profile(
1594 FROM_HERE_WITH_EXPLICIT_FUNCTION( 1594 FROM_HERE_WITH_EXPLICIT_FUNCTION(
1595 "456331 ResourceDispatcherHostImpl::CreateResourceHandler")); 1595 "456331 ResourceDispatcherHostImpl::CreateResourceHandler"));
1596 // Construct the IPC resource handler. 1596 // Construct the IPC resource handler.
1597 std::unique_ptr<ResourceHandler> handler; 1597 std::unique_ptr<ResourceHandler> handler;
1598 if (sync_result_handler) { 1598 if (sync_result_handler) {
1599 // download_to_file is not supported for synchronous requests. 1599 // download_to_file is not supported for synchronous requests.
1600 if (request_data.download_to_file) { 1600 if (request_data.download_to_file) {
1601 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_BAD_DOWNLOAD); 1601 bad_message::ReceivedBadMessage(filter_, bad_message::RDH_BAD_DOWNLOAD);
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after
2289 2289
2290 void ResourceDispatcherHostImpl::OnRenderFrameDeleted( 2290 void ResourceDispatcherHostImpl::OnRenderFrameDeleted(
2291 const GlobalFrameRoutingId& global_routing_id) { 2291 const GlobalFrameRoutingId& global_routing_id) {
2292 CancelRequestsForRoute(global_routing_id); 2292 CancelRequestsForRoute(global_routing_id);
2293 } 2293 }
2294 2294
2295 void ResourceDispatcherHostImpl::OnRequestResourceWithMojo( 2295 void ResourceDispatcherHostImpl::OnRequestResourceWithMojo(
2296 int routing_id, 2296 int routing_id,
2297 int request_id, 2297 int request_id,
2298 const ResourceRequest& request, 2298 const ResourceRequest& request,
2299 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, 2299 mojom::URLLoaderAssociatedRequest mojo_request,
2300 mojom::URLLoaderClientPtr url_loader_client, 2300 mojom::URLLoaderClientAssociatedPtr url_loader_client,
2301 ResourceMessageFilter* filter) { 2301 ResourceMessageFilter* filter) {
2302 filter_ = filter; 2302 filter_ = filter;
2303 OnRequestResourceInternal(routing_id, request_id, request, 2303 OnRequestResourceInternal(routing_id, request_id, request,
2304 std::move(mojo_request), 2304 std::move(mojo_request),
2305 std::move(url_loader_client)); 2305 std::move(url_loader_client));
2306 filter_ = nullptr; 2306 filter_ = nullptr;
2307 } 2307 }
2308 2308
2309 void ResourceDispatcherHostImpl::OnSyncLoadWithMojo( 2309 void ResourceDispatcherHostImpl::OnSyncLoadWithMojo(
2310 int routing_id, 2310 int routing_id,
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
2785 &throttles); 2785 &throttles);
2786 if (!throttles.empty()) { 2786 if (!throttles.empty()) {
2787 handler.reset(new ThrottlingResourceHandler(std::move(handler), request, 2787 handler.reset(new ThrottlingResourceHandler(std::move(handler), request,
2788 std::move(throttles))); 2788 std::move(throttles)));
2789 } 2789 }
2790 } 2790 }
2791 return handler; 2791 return handler;
2792 } 2792 }
2793 2793
2794 } // namespace content 2794 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/loader/resource_dispatcher_host_impl.h ('k') | content/browser/loader/resource_message_filter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698