| 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 // This is the browser side of the resource dispatcher, it receives requests | 5 // This is the browser side of the resource dispatcher, it receives requests |
| 6 // from the child process (i.e. [Renderer, Plugin, Worker]ProcessHost), and | 6 // from the child process (i.e. [Renderer, Plugin, Worker]ProcessHost), and |
| 7 // dispatches them to URLRequests. It then forwards the messages from the | 7 // dispatches them to URLRequests. It then forwards the messages from the |
| 8 // URLRequests back to the correct process for handling. | 8 // URLRequests back to the correct process for handling. |
| 9 // | 9 // |
| 10 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 10 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 // transferred. The LoaderDelegate should be interacted with on the IO thread. | 292 // transferred. The LoaderDelegate should be interacted with on the IO thread. |
| 293 void SetLoaderDelegate(LoaderDelegate* loader_delegate); | 293 void SetLoaderDelegate(LoaderDelegate* loader_delegate); |
| 294 | 294 |
| 295 void OnRenderFrameDeleted(const GlobalFrameRoutingId& global_routing_id); | 295 void OnRenderFrameDeleted(const GlobalFrameRoutingId& global_routing_id); |
| 296 | 296 |
| 297 // Called when loading a request with mojo. | 297 // Called when loading a request with mojo. |
| 298 void OnRequestResourceWithMojo( | 298 void OnRequestResourceWithMojo( |
| 299 int routing_id, | 299 int routing_id, |
| 300 int request_id, | 300 int request_id, |
| 301 const ResourceRequest& request, | 301 const ResourceRequest& request, |
| 302 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, | 302 mojom::URLLoaderAssociatedRequest mojo_request, |
| 303 mojom::URLLoaderClientPtr url_loader_client, | 303 mojom::URLLoaderClientAssociatedPtr url_loader_client, |
| 304 ResourceMessageFilter* filter); | 304 ResourceMessageFilter* filter); |
| 305 | 305 |
| 306 void OnSyncLoadWithMojo(int routing_id, | 306 void OnSyncLoadWithMojo(int routing_id, |
| 307 int request_id, | 307 int request_id, |
| 308 const ResourceRequest& request_data, | 308 const ResourceRequest& request_data, |
| 309 ResourceMessageFilter* filter, | 309 ResourceMessageFilter* filter, |
| 310 const SyncLoadResultCallback& result_handler); | 310 const SyncLoadResultCallback& result_handler); |
| 311 | 311 |
| 312 // Helper function for initializing the |request| passed in. By initializing | 312 // Helper function for initializing the |request| passed in. By initializing |
| 313 // we mean setting the |referrer| on the |request|, associating the | 313 // we mean setting the |referrer| on the |request|, associating the |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 bool cancel_requests); | 520 bool cancel_requests); |
| 521 | 521 |
| 522 void OnRequestResource(int routing_id, | 522 void OnRequestResource(int routing_id, |
| 523 int request_id, | 523 int request_id, |
| 524 const ResourceRequest& request_data); | 524 const ResourceRequest& request_data); |
| 525 | 525 |
| 526 void OnRequestResourceInternal( | 526 void OnRequestResourceInternal( |
| 527 int routing_id, | 527 int routing_id, |
| 528 int request_id, | 528 int request_id, |
| 529 const ResourceRequest& request_data, | 529 const ResourceRequest& request_data, |
| 530 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, | 530 mojom::URLLoaderAssociatedRequest mojo_request, |
| 531 mojom::URLLoaderClientPtr url_loader_client); | 531 mojom::URLLoaderClientAssociatedPtr url_loader_client); |
| 532 | 532 |
| 533 void OnSyncLoad(int request_id, | 533 void OnSyncLoad(int request_id, |
| 534 const ResourceRequest& request_data, | 534 const ResourceRequest& request_data, |
| 535 IPC::Message* sync_result); | 535 IPC::Message* sync_result); |
| 536 | 536 |
| 537 bool IsRequestIDInUse(const GlobalRequestID& id) const; | 537 bool IsRequestIDInUse(const GlobalRequestID& id) const; |
| 538 | 538 |
| 539 // Update the ResourceRequestInfo and internal maps when a request is | 539 // Update the ResourceRequestInfo and internal maps when a request is |
| 540 // transferred from one process to another. | 540 // transferred from one process to another. |
| 541 void UpdateRequestForTransfer(int child_id, | 541 void UpdateRequestForTransfer(int child_id, |
| 542 int route_id, | 542 int route_id, |
| 543 int request_id, | 543 int request_id, |
| 544 const ResourceRequest& request_data, | 544 const ResourceRequest& request_data, |
| 545 LoaderMap::iterator iter); | 545 LoaderMap::iterator iter); |
| 546 | 546 |
| 547 // If |request_data| is for a request being transferred from another process, | 547 // If |request_data| is for a request being transferred from another process, |
| 548 // then CompleteTransfer method can be used to complete the transfer. | 548 // then CompleteTransfer method can be used to complete the transfer. |
| 549 void CompleteTransfer(int request_id, | 549 void CompleteTransfer(int request_id, |
| 550 const ResourceRequest& request_data, | 550 const ResourceRequest& request_data, |
| 551 int route_id); | 551 int route_id); |
| 552 | 552 |
| 553 void BeginRequest( | 553 void BeginRequest( |
| 554 int request_id, | 554 int request_id, |
| 555 const ResourceRequest& request_data, | 555 const ResourceRequest& request_data, |
| 556 const SyncLoadResultCallback& sync_result_handler, // only valid for sync | 556 const SyncLoadResultCallback& sync_result_handler, // only valid for sync |
| 557 int route_id, | 557 int route_id, |
| 558 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, | 558 mojom::URLLoaderAssociatedRequest mojo_request, |
| 559 mojom::URLLoaderClientPtr url_loader_client); | 559 mojom::URLLoaderClientAssociatedPtr url_loader_client); |
| 560 | 560 |
| 561 // There are requests which need decisions to be made like the following: | 561 // There are requests which need decisions to be made like the following: |
| 562 // Whether the presence of certain HTTP headers like the Origin header are | 562 // Whether the presence of certain HTTP headers like the Origin header are |
| 563 // valid, etc. These requests may need to be aborted based on these | 563 // valid, etc. These requests may need to be aborted based on these |
| 564 // decisions which could be time consuming. We allow for these decisions | 564 // decisions which could be time consuming. We allow for these decisions |
| 565 // to be made asynchronously. The request proceeds when we hear back from | 565 // to be made asynchronously. The request proceeds when we hear back from |
| 566 // the interceptors about whether to continue or not. | 566 // the interceptors about whether to continue or not. |
| 567 // The |continue_request| parameter in the function indicates whether the | 567 // The |continue_request| parameter in the function indicates whether the |
| 568 // request should be continued or aborted. The |error_code| parameter is set | 568 // request should be continued or aborted. The |error_code| parameter is set |
| 569 // if |continue_request| is false. | 569 // if |continue_request| is false. |
| 570 void ContinuePendingBeginRequest( | 570 void ContinuePendingBeginRequest( |
| 571 int request_id, | 571 int request_id, |
| 572 const ResourceRequest& request_data, | 572 const ResourceRequest& request_data, |
| 573 const SyncLoadResultCallback& sync_result_handler, // only valid for sync | 573 const SyncLoadResultCallback& sync_result_handler, // only valid for sync |
| 574 int route_id, | 574 int route_id, |
| 575 const net::HttpRequestHeaders& headers, | 575 const net::HttpRequestHeaders& headers, |
| 576 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, | 576 mojom::URLLoaderAssociatedRequest mojo_request, |
| 577 mojom::URLLoaderClientPtr url_loader_client, | 577 mojom::URLLoaderClientAssociatedPtr url_loader_client, |
| 578 bool continue_request, | 578 bool continue_request, |
| 579 int error_code); | 579 int error_code); |
| 580 | 580 |
| 581 // Creates a ResourceHandler to be used by BeginRequest() for normal resource | 581 // Creates a ResourceHandler to be used by BeginRequest() for normal resource |
| 582 // loading. | 582 // loading. |
| 583 std::unique_ptr<ResourceHandler> CreateResourceHandler( | 583 std::unique_ptr<ResourceHandler> CreateResourceHandler( |
| 584 net::URLRequest* request, | 584 net::URLRequest* request, |
| 585 const ResourceRequest& request_data, | 585 const ResourceRequest& request_data, |
| 586 const SyncLoadResultCallback& sync_result_handler, | 586 const SyncLoadResultCallback& sync_result_handler, |
| 587 int route_id, | 587 int route_id, |
| 588 int process_type, | 588 int process_type, |
| 589 int child_id, | 589 int child_id, |
| 590 ResourceContext* resource_context, | 590 ResourceContext* resource_context, |
| 591 mojo::InterfaceRequest<mojom::URLLoader> mojo_request, | 591 mojom::URLLoaderAssociatedRequest mojo_request, |
| 592 mojom::URLLoaderClientPtr url_loader_client); | 592 mojom::URLLoaderClientAssociatedPtr url_loader_client); |
| 593 | 593 |
| 594 // Wraps |handler| in the standard resource handlers for normal resource | 594 // Wraps |handler| in the standard resource handlers for normal resource |
| 595 // loading and navigation requests. This adds MimeTypeResourceHandler and | 595 // loading and navigation requests. This adds MimeTypeResourceHandler and |
| 596 // ResourceThrottles. | 596 // ResourceThrottles. |
| 597 std::unique_ptr<ResourceHandler> AddStandardHandlers( | 597 std::unique_ptr<ResourceHandler> AddStandardHandlers( |
| 598 net::URLRequest* request, | 598 net::URLRequest* request, |
| 599 ResourceType resource_type, | 599 ResourceType resource_type, |
| 600 ResourceContext* resource_context, | 600 ResourceContext* resource_context, |
| 601 RequestContextType fetch_request_context_type, | 601 RequestContextType fetch_request_context_type, |
| 602 AppCacheService* appcache_service, | 602 AppCacheService* appcache_service, |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 | 767 |
| 768 // Points to the registered download handler intercept. | 768 // Points to the registered download handler intercept. |
| 769 CreateDownloadHandlerIntercept create_download_handler_intercept_; | 769 CreateDownloadHandlerIntercept create_download_handler_intercept_; |
| 770 | 770 |
| 771 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 771 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
| 772 }; | 772 }; |
| 773 | 773 |
| 774 } // namespace content | 774 } // namespace content |
| 775 | 775 |
| 776 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 776 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
| OLD | NEW |