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

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

Issue 2481093003: Introduce ResourceRequesterInfo to abstract the requester of resource request (Closed)
Patch Set: 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 // 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 class AsyncRevalidationManager; 57 class AsyncRevalidationManager;
58 class LoaderDelegate; 58 class LoaderDelegate;
59 class NavigationURLLoaderImplCore; 59 class NavigationURLLoaderImplCore;
60 class NavigationUIData; 60 class NavigationUIData;
61 class RenderFrameHostImpl; 61 class RenderFrameHostImpl;
62 class ResourceContext; 62 class ResourceContext;
63 class ResourceDispatcherHostDelegate; 63 class ResourceDispatcherHostDelegate;
64 class ResourceHandler; 64 class ResourceHandler;
65 class ResourceMessageDelegate; 65 class ResourceMessageDelegate;
66 class ResourceMessageFilter; 66 class ResourceMessageFilter;
67 class ResourceRequesterInfo;
67 class ResourceRequestInfoImpl; 68 class ResourceRequestInfoImpl;
68 class ServiceWorkerNavigationHandleCore; 69 class ServiceWorkerNavigationHandleCore;
69 struct NavigationRequestInfo; 70 struct NavigationRequestInfo;
70 struct Referrer; 71 struct Referrer;
71 struct ResourceRequest; 72 struct ResourceRequest;
72 73
73 namespace mojom { 74 namespace mojom {
74 class URLLoader; 75 class URLLoader;
75 } // namespace mojom 76 } // namespace mojom
76 77
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 295
295 void OnRenderFrameDeleted(const GlobalFrameRoutingId& global_routing_id); 296 void OnRenderFrameDeleted(const GlobalFrameRoutingId& global_routing_id);
296 297
297 // Called when loading a request with mojo. 298 // Called when loading a request with mojo.
298 void OnRequestResourceWithMojo( 299 void OnRequestResourceWithMojo(
299 int routing_id, 300 int routing_id,
300 int request_id, 301 int request_id,
301 const ResourceRequest& request, 302 const ResourceRequest& request,
302 mojom::URLLoaderAssociatedRequest mojo_request, 303 mojom::URLLoaderAssociatedRequest mojo_request,
303 mojom::URLLoaderClientAssociatedPtr url_loader_client, 304 mojom::URLLoaderClientAssociatedPtr url_loader_client,
304 ResourceMessageFilter* filter); 305 std::unique_ptr<ResourceRequesterInfo> requester_info);
305 306
306 void OnSyncLoadWithMojo(int routing_id, 307 void OnSyncLoadWithMojo(int routing_id,
307 int request_id, 308 int request_id,
308 const ResourceRequest& request_data, 309 const ResourceRequest& request_data,
309 ResourceMessageFilter* filter, 310 std::unique_ptr<ResourceRequesterInfo> requester_info,
310 const SyncLoadResultCallback& result_handler); 311 const SyncLoadResultCallback& result_handler);
311 312
312 // Helper function for initializing the |request| passed in. By initializing 313 // Helper function for initializing the |request| passed in. By initializing
313 // we mean setting the |referrer| on the |request|, associating the 314 // we mean setting the |referrer| on the |request|, associating the
314 // ResourceRequestInfoImpl structure with the |request|, etc. 315 // ResourceRequestInfoImpl structure with the |request|, etc.
315 // This function should be called for invoking the BeginURLRequest() function 316 // This function should be called for invoking the BeginURLRequest() function
316 // to initiate a URL request. 317 // to initiate a URL request.
317 void InitializeURLRequest(net::URLRequest* request, 318 void InitializeURLRequest(net::URLRequest* request,
318 const Referrer& referrer, 319 const Referrer& referrer,
319 bool is_download, 320 bool is_download,
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
578 bool continue_request, 579 bool continue_request,
579 int error_code); 580 int error_code);
580 581
581 // Creates a ResourceHandler to be used by BeginRequest() for normal resource 582 // Creates a ResourceHandler to be used by BeginRequest() for normal resource
582 // loading. 583 // loading.
583 std::unique_ptr<ResourceHandler> CreateResourceHandler( 584 std::unique_ptr<ResourceHandler> CreateResourceHandler(
584 net::URLRequest* request, 585 net::URLRequest* request,
585 const ResourceRequest& request_data, 586 const ResourceRequest& request_data,
586 const SyncLoadResultCallback& sync_result_handler, 587 const SyncLoadResultCallback& sync_result_handler,
587 int route_id, 588 int route_id,
588 int process_type,
589 int child_id, 589 int child_id,
590 ResourceContext* resource_context, 590 ResourceContext* resource_context,
591 mojom::URLLoaderAssociatedRequest mojo_request, 591 mojom::URLLoaderAssociatedRequest mojo_request,
592 mojom::URLLoaderClientAssociatedPtr 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,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 ResourceLoader* GetLoader(int child_id, int request_id) const; 642 ResourceLoader* GetLoader(int child_id, int request_id) const;
643 643
644 // Registers |delegate| to receive resource IPC messages targeted to the 644 // Registers |delegate| to receive resource IPC messages targeted to the
645 // specified |id|. 645 // specified |id|.
646 void RegisterResourceMessageDelegate(const GlobalRequestID& id, 646 void RegisterResourceMessageDelegate(const GlobalRequestID& id,
647 ResourceMessageDelegate* delegate); 647 ResourceMessageDelegate* delegate);
648 void UnregisterResourceMessageDelegate(const GlobalRequestID& id, 648 void UnregisterResourceMessageDelegate(const GlobalRequestID& id,
649 ResourceMessageDelegate* delegate); 649 ResourceMessageDelegate* delegate);
650 650
651 int BuildLoadFlagsForRequest(const ResourceRequest& request_data, 651 int BuildLoadFlagsForRequest(const ResourceRequest& request_data,
652 int child_id,
653 bool is_sync_load); 652 bool is_sync_load);
654 653
655 // Consults the RendererSecurity policy to determine whether the 654 // Consults the RendererSecurity policy to determine whether the
656 // ResourceDispatcherHostImpl should service this request. A request might 655 // ResourceDispatcherHostImpl should service this request. A request might
657 // be disallowed if the renderer is not authorized to retrieve the request 656 // be disallowed if the renderer is not authorized to retrieve the request
658 // URL or if the renderer is attempting to upload an unauthorized file. 657 // URL or if the renderer is attempting to upload an unauthorized file.
659 bool ShouldServiceRequest(int process_type, 658 bool ShouldServiceRequest(int child_id,
660 int child_id,
661 const ResourceRequest& request_data, 659 const ResourceRequest& request_data,
662 const net::HttpRequestHeaders& headers, 660 const net::HttpRequestHeaders& headers,
663 ResourceMessageFilter* filter, 661 ResourceRequesterInfo* requester_info,
664 ResourceContext* resource_context); 662 ResourceContext* resource_context);
665 663
666 // Notifies the ResourceDispatcherHostDelegate about a download having 664 // Notifies the ResourceDispatcherHostDelegate about a download having
667 // started. The function returns the |handler| passed in, if the download 665 // started. The function returns the |handler| passed in, if the download
668 // is not throttled. If the download is to be throttled (Decided by the 666 // is not throttled. If the download is to be throttled (Decided by the
669 // delegate) the function returns a ThrottlingResourceHandler to handle the 667 // delegate) the function returns a ThrottlingResourceHandler to handle the
670 // download. 668 // download.
671 std::unique_ptr<ResourceHandler> HandleDownloadStarted( 669 std::unique_ptr<ResourceHandler> HandleDownloadStarted(
672 net::URLRequest* request, 670 net::URLRequest* request,
673 std::unique_ptr<ResourceHandler> handler, 671 std::unique_ptr<ResourceHandler> handler,
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
737 // kAvgBytesPerOutstandingRequest) 735 // kAvgBytesPerOutstandingRequest)
738 int max_outstanding_requests_cost_per_process_; 736 int max_outstanding_requests_cost_per_process_;
739 737
740 // Time of the last user gesture. Stored so that we can add a load 738 // Time of the last user gesture. Stored so that we can add a load
741 // flag to requests occurring soon after a gesture to indicate they 739 // flag to requests occurring soon after a gesture to indicate they
742 // may be because of explicit user action. 740 // may be because of explicit user action.
743 base::TimeTicks last_user_gesture_time_; 741 base::TimeTicks last_user_gesture_time_;
744 742
745 // Used during IPC message dispatching so that the handlers can get a pointer 743 // Used during IPC message dispatching so that the handlers can get a pointer
746 // to the source of the message. 744 // to the source of the message.
747 ResourceMessageFilter* filter_; 745 std::unique_ptr<ResourceRequesterInfo> requester_info_;
kinuko 2016/11/10 08:17:57 RDH is browser process global object, owning Resou
horo 2016/11/10 14:46:33 Done.
748 746
749 ResourceDispatcherHostDelegate* delegate_; 747 ResourceDispatcherHostDelegate* delegate_;
750 748
751 LoaderDelegate* loader_delegate_; 749 LoaderDelegate* loader_delegate_;
752 750
753 bool allow_cross_origin_auth_prompt_; 751 bool allow_cross_origin_auth_prompt_;
754 752
755 // AsyncRevalidationManager is non-NULL if and only if 753 // AsyncRevalidationManager is non-NULL if and only if
756 // stale-while-revalidate is enabled. 754 // stale-while-revalidate is enabled.
757 std::unique_ptr<AsyncRevalidationManager> async_revalidation_manager_; 755 std::unique_ptr<AsyncRevalidationManager> async_revalidation_manager_;
758 756
759 typedef std::map<GlobalRequestID, 757 typedef std::map<GlobalRequestID,
760 base::ObserverList<ResourceMessageDelegate>*> DelegateMap; 758 base::ObserverList<ResourceMessageDelegate>*> DelegateMap;
761 DelegateMap delegate_map_; 759 DelegateMap delegate_map_;
762 760
763 std::unique_ptr<ResourceScheduler> scheduler_; 761 std::unique_ptr<ResourceScheduler> scheduler_;
764 762
765 // Used to invoke an interceptor for the HTTP header. 763 // Used to invoke an interceptor for the HTTP header.
766 HeaderInterceptorMap http_header_interceptor_map_; 764 HeaderInterceptorMap http_header_interceptor_map_;
767 765
768 // Points to the registered download handler intercept. 766 // Points to the registered download handler intercept.
769 CreateDownloadHandlerIntercept create_download_handler_intercept_; 767 CreateDownloadHandlerIntercept create_download_handler_intercept_;
770 768
771 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); 769 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl);
772 }; 770 };
773 771
774 } // namespace content 772 } // namespace content
775 773
776 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 774 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698