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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // or experiment status. For unit tests only. | 291 // or experiment status. For unit tests only. |
292 void EnableStaleWhileRevalidateForTesting(); | 292 void EnableStaleWhileRevalidateForTesting(); |
293 | 293 |
294 // Sets the LoaderDelegate, which must outlive this object. Ownership is not | 294 // Sets the LoaderDelegate, which must outlive this object. Ownership is not |
295 // transferred. The LoaderDelegate should be interacted with on the IO thread. | 295 // transferred. The LoaderDelegate should be interacted with on the IO thread. |
296 void SetLoaderDelegate(LoaderDelegate* loader_delegate); | 296 void SetLoaderDelegate(LoaderDelegate* loader_delegate); |
297 | 297 |
298 void OnRenderFrameDeleted(const GlobalFrameRoutingId& global_routing_id); | 298 void OnRenderFrameDeleted(const GlobalFrameRoutingId& global_routing_id); |
299 | 299 |
300 // Called when loading a request with mojo. | 300 // Called when loading a request with mojo. |
301 void OnRequestResourceWithMojo( | 301 void OnRequestResourceWithMojo(ResourceRequesterInfo* requester_info, |
302 ResourceRequesterInfo* requester_info, | 302 int routing_id, |
303 int routing_id, | 303 int request_id, |
304 int request_id, | 304 const ResourceRequest& request, |
305 const ResourceRequest& request, | 305 mojom::URLLoaderAssociatedRequest mojo_request, |
306 mojom::URLLoaderAssociatedRequest mojo_request, | 306 mojom::URLLoaderClientPtr url_loader_client); |
307 mojom::URLLoaderClientAssociatedPtr url_loader_client); | |
308 | 307 |
309 void OnSyncLoadWithMojo(ResourceRequesterInfo* requester_info, | 308 void OnSyncLoadWithMojo(ResourceRequesterInfo* requester_info, |
310 int routing_id, | 309 int routing_id, |
311 int request_id, | 310 int request_id, |
312 const ResourceRequest& request_data, | 311 const ResourceRequest& request_data, |
313 const SyncLoadResultCallback& result_handler); | 312 const SyncLoadResultCallback& result_handler); |
314 | 313 |
315 // Helper function for initializing the |request| passed in. By initializing | 314 // Helper function for initializing the |request| passed in. By initializing |
316 // we mean setting the |referrer| on the |request|, associating the | 315 // we mean setting the |referrer| on the |request|, associating the |
317 // ResourceRequestInfoImpl structure with the |request|, etc. | 316 // ResourceRequestInfoImpl structure with the |request|, etc. |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. | 527 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. |
529 void ProcessBlockedRequestsForRoute( | 528 void ProcessBlockedRequestsForRoute( |
530 const GlobalFrameRoutingId& global_routing_id, | 529 const GlobalFrameRoutingId& global_routing_id, |
531 bool cancel_requests); | 530 bool cancel_requests); |
532 | 531 |
533 void OnRequestResource(ResourceRequesterInfo* requester_info, | 532 void OnRequestResource(ResourceRequesterInfo* requester_info, |
534 int routing_id, | 533 int routing_id, |
535 int request_id, | 534 int request_id, |
536 const ResourceRequest& request_data); | 535 const ResourceRequest& request_data); |
537 | 536 |
538 void OnRequestResourceInternal( | 537 void OnRequestResourceInternal(ResourceRequesterInfo* requester_info, |
539 ResourceRequesterInfo* requester_info, | 538 int routing_id, |
540 int routing_id, | 539 int request_id, |
541 int request_id, | 540 const ResourceRequest& request_data, |
542 const ResourceRequest& request_data, | 541 mojom::URLLoaderAssociatedRequest mojo_request, |
543 mojom::URLLoaderAssociatedRequest mojo_request, | 542 mojom::URLLoaderClientPtr url_loader_client); |
544 mojom::URLLoaderClientAssociatedPtr url_loader_client); | |
545 | 543 |
546 void OnSyncLoad(ResourceRequesterInfo* requester_info, | 544 void OnSyncLoad(ResourceRequesterInfo* requester_info, |
547 int request_id, | 545 int request_id, |
548 const ResourceRequest& request_data, | 546 const ResourceRequest& request_data, |
549 IPC::Message* sync_result); | 547 IPC::Message* sync_result); |
550 | 548 |
551 bool IsRequestIDInUse(const GlobalRequestID& id) const; | 549 bool IsRequestIDInUse(const GlobalRequestID& id) const; |
552 | 550 |
553 // Update the ResourceRequestInfo and internal maps when a request is | 551 // Update the ResourceRequestInfo and internal maps when a request is |
554 // transferred from one process to another. | 552 // transferred from one process to another. |
555 void UpdateRequestForTransfer( | 553 void UpdateRequestForTransfer(ResourceRequesterInfo* requester_info, |
556 ResourceRequesterInfo* requester_info, | 554 int route_id, |
557 int route_id, | 555 int request_id, |
558 int request_id, | 556 const ResourceRequest& request_data, |
559 const ResourceRequest& request_data, | 557 LoaderMap::iterator iter, |
560 LoaderMap::iterator iter, | 558 mojom::URLLoaderAssociatedRequest mojo_request, |
561 mojom::URLLoaderAssociatedRequest mojo_request, | 559 mojom::URLLoaderClientPtr url_loader_client); |
562 mojom::URLLoaderClientAssociatedPtr url_loader_client); | |
563 | 560 |
564 // If |request_data| is for a request being transferred from another process, | 561 // If |request_data| is for a request being transferred from another process, |
565 // then CompleteTransfer method can be used to complete the transfer. | 562 // then CompleteTransfer method can be used to complete the transfer. |
566 void CompleteTransfer(ResourceRequesterInfo* requester_info, | 563 void CompleteTransfer(ResourceRequesterInfo* requester_info, |
567 int request_id, | 564 int request_id, |
568 const ResourceRequest& request_data, | 565 const ResourceRequest& request_data, |
569 int route_id, | 566 int route_id, |
570 mojom::URLLoaderAssociatedRequest mojo_request, | 567 mojom::URLLoaderAssociatedRequest mojo_request, |
571 mojom::URLLoaderClientAssociatedPtr url_loader_client); | 568 mojom::URLLoaderClientPtr url_loader_client); |
572 | 569 |
573 void BeginRequest( | 570 void BeginRequest( |
574 ResourceRequesterInfo* requester_info, | 571 ResourceRequesterInfo* requester_info, |
575 int request_id, | 572 int request_id, |
576 const ResourceRequest& request_data, | 573 const ResourceRequest& request_data, |
577 const SyncLoadResultCallback& sync_result_handler, // only valid for sync | 574 const SyncLoadResultCallback& sync_result_handler, // only valid for sync |
578 int route_id, | 575 int route_id, |
579 mojom::URLLoaderAssociatedRequest mojo_request, | 576 mojom::URLLoaderAssociatedRequest mojo_request, |
580 mojom::URLLoaderClientAssociatedPtr url_loader_client); | 577 mojom::URLLoaderClientPtr url_loader_client); |
581 | 578 |
582 // There are requests which need decisions to be made like the following: | 579 // There are requests which need decisions to be made like the following: |
583 // Whether the presence of certain HTTP headers like the Origin header are | 580 // Whether the presence of certain HTTP headers like the Origin header are |
584 // valid, etc. These requests may need to be aborted based on these | 581 // valid, etc. These requests may need to be aborted based on these |
585 // decisions which could be time consuming. We allow for these decisions | 582 // decisions which could be time consuming. We allow for these decisions |
586 // to be made asynchronously. The request proceeds when we hear back from | 583 // to be made asynchronously. The request proceeds when we hear back from |
587 // the interceptors about whether to continue or not. | 584 // the interceptors about whether to continue or not. |
588 // The |continue_request| parameter in the function indicates whether the | 585 // The |continue_request| parameter in the function indicates whether the |
589 // request should be continued or aborted. The |error_code| parameter is set | 586 // request should be continued or aborted. The |error_code| parameter is set |
590 // if |continue_request| is false. | 587 // if |continue_request| is false. |
591 void ContinuePendingBeginRequest( | 588 void ContinuePendingBeginRequest( |
592 scoped_refptr<ResourceRequesterInfo> requester_info, | 589 scoped_refptr<ResourceRequesterInfo> requester_info, |
593 int request_id, | 590 int request_id, |
594 const ResourceRequest& request_data, | 591 const ResourceRequest& request_data, |
595 const SyncLoadResultCallback& sync_result_handler, // only valid for sync | 592 const SyncLoadResultCallback& sync_result_handler, // only valid for sync |
596 int route_id, | 593 int route_id, |
597 const net::HttpRequestHeaders& headers, | 594 const net::HttpRequestHeaders& headers, |
598 mojom::URLLoaderAssociatedRequest mojo_request, | 595 mojom::URLLoaderAssociatedRequest mojo_request, |
599 mojom::URLLoaderClientAssociatedPtr url_loader_client, | 596 mojom::URLLoaderClientPtr url_loader_client, |
600 bool continue_request, | 597 bool continue_request, |
601 int error_code); | 598 int error_code); |
602 | 599 |
603 // Creates a ResourceHandler to be used by BeginRequest() for normal resource | 600 // Creates a ResourceHandler to be used by BeginRequest() for normal resource |
604 // loading. | 601 // loading. |
605 std::unique_ptr<ResourceHandler> CreateResourceHandler( | 602 std::unique_ptr<ResourceHandler> CreateResourceHandler( |
606 ResourceRequesterInfo* requester_info, | 603 ResourceRequesterInfo* requester_info, |
607 net::URLRequest* request, | 604 net::URLRequest* request, |
608 const ResourceRequest& request_data, | 605 const ResourceRequest& request_data, |
609 const SyncLoadResultCallback& sync_result_handler, | 606 const SyncLoadResultCallback& sync_result_handler, |
610 int route_id, | 607 int route_id, |
611 int child_id, | 608 int child_id, |
612 ResourceContext* resource_context, | 609 ResourceContext* resource_context, |
613 mojom::URLLoaderAssociatedRequest mojo_request, | 610 mojom::URLLoaderAssociatedRequest mojo_request, |
614 mojom::URLLoaderClientAssociatedPtr url_loader_client); | 611 mojom::URLLoaderClientPtr url_loader_client); |
615 | 612 |
616 // Wraps |handler| in the standard resource handlers for normal resource | 613 // Wraps |handler| in the standard resource handlers for normal resource |
617 // loading and navigation requests. This adds MimeTypeResourceHandler and | 614 // loading and navigation requests. This adds MimeTypeResourceHandler and |
618 // ResourceThrottles. | 615 // ResourceThrottles. |
619 std::unique_ptr<ResourceHandler> AddStandardHandlers( | 616 std::unique_ptr<ResourceHandler> AddStandardHandlers( |
620 net::URLRequest* request, | 617 net::URLRequest* request, |
621 ResourceType resource_type, | 618 ResourceType resource_type, |
622 ResourceContext* resource_context, | 619 ResourceContext* resource_context, |
623 RequestContextType fetch_request_context_type, | 620 RequestContextType fetch_request_context_type, |
624 blink::WebMixedContentContextType fetch_mixed_content_context_type, | 621 blink::WebMixedContentContextType fetch_mixed_content_context_type, |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
787 | 784 |
788 // Points to the registered download handler intercept. | 785 // Points to the registered download handler intercept. |
789 CreateDownloadHandlerIntercept create_download_handler_intercept_; | 786 CreateDownloadHandlerIntercept create_download_handler_intercept_; |
790 | 787 |
791 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 788 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
792 }; | 789 }; |
793 | 790 |
794 } // namespace content | 791 } // namespace content |
795 | 792 |
796 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 793 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
OLD | NEW |