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

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

Issue 1542743002: [RDHI] Refactored blocked_loaders_map_ to key by render frame route id (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: just comments / minor restructuring (trybots previous) Created 4 years, 11 months 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 18 matching lines...) Expand all
29 #include "content/browser/loader/resource_loader.h" 29 #include "content/browser/loader/resource_loader.h"
30 #include "content/browser/loader/resource_loader_delegate.h" 30 #include "content/browser/loader/resource_loader_delegate.h"
31 #include "content/browser/loader/resource_scheduler.h" 31 #include "content/browser/loader/resource_scheduler.h"
32 #include "content/common/content_export.h" 32 #include "content/common/content_export.h"
33 #include "content/common/resource_request_body.h" 33 #include "content/common/resource_request_body.h"
34 #include "content/public/browser/child_process_data.h" 34 #include "content/public/browser/child_process_data.h"
35 #include "content/public/browser/download_item.h" 35 #include "content/public/browser/download_item.h"
36 #include "content/public/browser/download_url_parameters.h" 36 #include "content/public/browser/download_url_parameters.h"
37 #include "content/public/browser/global_request_id.h" 37 #include "content/public/browser/global_request_id.h"
38 #include "content/public/browser/notification_types.h" 38 #include "content/public/browser/notification_types.h"
39 #include "content/public/browser/render_view_host.h"
39 #include "content/public/browser/resource_dispatcher_host.h" 40 #include "content/public/browser/resource_dispatcher_host.h"
40 #include "content/public/common/resource_type.h" 41 #include "content/public/common/resource_type.h"
41 #include "ipc/ipc_message.h" 42 #include "ipc/ipc_message.h"
42 #include "net/base/request_priority.h" 43 #include "net/base/request_priority.h"
43 #include "net/cookies/canonical_cookie.h" 44 #include "net/cookies/canonical_cookie.h"
44 #include "net/url_request/url_request.h" 45 #include "net/url_request/url_request.h"
45 46
46 class ResourceHandler; 47 class ResourceHandler;
47 struct ResourceHostMsg_Request; 48 struct ResourceHostMsg_Request;
48 49
49 namespace base { 50 namespace base {
50 class FilePath; 51 class FilePath;
51 } 52 }
52 53
53 namespace net { 54 namespace net {
54 class URLRequestJobFactory; 55 class URLRequestJobFactory;
55 } 56 }
56 57
57 namespace storage { 58 namespace storage {
58 class ShareableFileReference; 59 class ShareableFileReference;
59 } 60 }
60 61
61 namespace content { 62 namespace content {
62 class AppCacheService; 63 class AppCacheService;
63 class AsyncRevalidationManager; 64 class AsyncRevalidationManager;
65 class FrameTree;
64 class NavigationURLLoaderImplCore; 66 class NavigationURLLoaderImplCore;
65 class ResourceContext; 67 class ResourceContext;
66 class ResourceDispatcherHostDelegate; 68 class ResourceDispatcherHostDelegate;
67 class ResourceMessageDelegate; 69 class ResourceMessageDelegate;
68 class ResourceMessageFilter; 70 class ResourceMessageFilter;
69 class ResourceRequestInfoImpl; 71 class ResourceRequestInfoImpl;
70 class SaveFileManager; 72 class SaveFileManager;
71 class ServiceWorkerNavigationHandleCore; 73 class ServiceWorkerNavigationHandleCore;
72 class WebContentsImpl; 74 class WebContentsImpl;
73 struct CommonNavigationParams; 75 struct CommonNavigationParams;
(...skipping 22 matching lines...) Expand all
96 ResourceContext* context, 98 ResourceContext* context,
97 int child_id, 99 int child_id,
98 int render_view_route_id, 100 int render_view_route_id,
99 int render_frame_route_id, 101 int render_frame_route_id,
100 bool prefer_cache, 102 bool prefer_cache,
101 bool do_not_prompt_for_login, 103 bool do_not_prompt_for_login,
102 scoped_ptr<DownloadSaveInfo> save_info, 104 scoped_ptr<DownloadSaveInfo> save_info,
103 uint32 download_id, 105 uint32 download_id,
104 const DownloadStartedCallback& started_callback) override; 106 const DownloadStartedCallback& started_callback) override;
105 void ClearLoginDelegateForRequest(net::URLRequest* request) override; 107 void ClearLoginDelegateForRequest(net::URLRequest* request) override;
106 void BlockRequestsForRoute(int child_id, int route_id) override; 108 void BlockRequestsForFrame(int child_id, int route_id) override;
107 void ResumeBlockedRequestsForRoute(int child_id, int route_id) override; 109 void ResumeBlockedRequestsForFrame(int child_id, int route_id) override;
108 110
109 // Puts the resource dispatcher host in an inactive state (unable to begin 111 // Puts the resource dispatcher host in an inactive state (unable to begin
110 // new requests). Cancels all pending requests. 112 // new requests). Cancels all pending requests.
111 void Shutdown(); 113 void Shutdown();
112 114
113 // Notify the ResourceDispatcherHostImpl of a new resource context. 115 // Notify the ResourceDispatcherHostImpl of a new resource context.
114 void AddResourceContext(ResourceContext* context); 116 void AddResourceContext(ResourceContext* context);
115 117
116 // Notify the ResourceDispatcherHostImpl of a resource context destruction. 118 // Notify the ResourceDispatcherHostImpl of a resource context destruction.
117 void RemoveResourceContext(ResourceContext* context); 119 void RemoveResourceContext(ResourceContext* context);
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 } 169 }
168 170
169 // The average private bytes increase of the browser for each new pending 171 // The average private bytes increase of the browser for each new pending
170 // request. Experimentally obtained. 172 // request. Experimentally obtained.
171 static const int kAvgBytesPerOutstandingRequest = 4400; 173 static const int kAvgBytesPerOutstandingRequest = 4400;
172 174
173 SaveFileManager* save_file_manager() const { 175 SaveFileManager* save_file_manager() const {
174 return save_file_manager_.get(); 176 return save_file_manager_.get();
175 } 177 }
176 178
179 void OnRenderFrameHostDeleted(int child_id, int route_id);
180
177 // Called when a RenderViewHost is created. 181 // Called when a RenderViewHost is created.
178 void OnRenderViewHostCreated(int child_id, 182 void OnRenderViewHostCreated(int child_id,
179 int route_id, 183 int route_id,
180 bool is_visible, 184 bool is_visible,
181 bool is_audible); 185 bool is_audible);
182 186
183 // Called when a RenderViewHost is deleted. 187 // Called when a RenderViewHost is deleted.
184 void OnRenderViewHostDeleted(int child_id, int route_id); 188 void OnRenderViewHostDeleted(int child_id, int route_id);
185 189
186 // Called when a RenderViewHost starts or stops loading. 190 // Called when a RenderViewHost starts or stops loading.
(...skipping 16 matching lines...) Expand all
203 void CancelRequestsForProcess(int child_id); 207 void CancelRequestsForProcess(int child_id);
204 208
205 void OnUserGesture(WebContentsImpl* contents); 209 void OnUserGesture(WebContentsImpl* contents);
206 210
207 // Retrieves a net::URLRequest. Must be called from the IO thread. 211 // Retrieves a net::URLRequest. Must be called from the IO thread.
208 net::URLRequest* GetURLRequest(const GlobalRequestID& request_id); 212 net::URLRequest* GetURLRequest(const GlobalRequestID& request_id);
209 213
210 void RemovePendingRequest(int child_id, int request_id); 214 void RemovePendingRequest(int child_id, int request_id);
211 215
212 // Cancels any blocked request for the specified route id. 216 // Cancels any blocked request for the specified route id.
213 void CancelBlockedRequestsForRoute(int child_id, int route_id); 217 void CancelBlockedRequestsForFrame(int child_id, int route_id);
214 218
215 // Maintains a collection of temp files created in support of 219 // Maintains a collection of temp files created in support of
216 // the download_to_file capability. Used to grant access to the 220 // the download_to_file capability. Used to grant access to the
217 // child process and to defer deletion of the file until it's 221 // child process and to defer deletion of the file until it's
218 // no longer needed. 222 // no longer needed.
219 void RegisterDownloadedTempFile( 223 void RegisterDownloadedTempFile(
220 int child_id, int request_id, 224 int child_id, int request_id,
221 const base::FilePath& file_path); 225 const base::FilePath& file_path);
222 void UnregisterDownloadedTempFile(int child_id, int request_id); 226 void UnregisterDownloadedTempFile(int child_id, int request_id);
223 227
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // |count| must be 1 or -1. 374 // |count| must be 1 or -1.
371 OustandingRequestsStats IncrementOutstandingRequestsCount( 375 OustandingRequestsStats IncrementOutstandingRequestsCount(
372 int count, 376 int count,
373 ResourceRequestInfoImpl* info); 377 ResourceRequestInfoImpl* info);
374 378
375 // Estimate how much heap space |request| will consume to run. 379 // Estimate how much heap space |request| will consume to run.
376 static int CalculateApproximateMemoryCost(net::URLRequest* request); 380 static int CalculateApproximateMemoryCost(net::URLRequest* request);
377 381
378 // Force cancels any pending requests for the given route id. This method 382 // Force cancels any pending requests for the given route id. This method
379 // acts like CancelRequestsForProcess when route_id is -1. 383 // acts like CancelRequestsForProcess when route_id is -1.
380 void CancelRequestsForRoute(int child_id, int route_id); 384 void CancelRequestsForFrame(int child_id, int route_id);
381 385
382 // The list of all requests that we have pending. This list is not really 386 // The list of all requests that we have pending. This list is not really
383 // optimized, and assumes that we have relatively few requests pending at once 387 // optimized, and assumes that we have relatively few requests pending at once
384 // since some operations require brute-force searching of the list. 388 // since some operations require brute-force searching of the list.
385 // 389 //
386 // It may be enhanced in the future to provide some kind of prioritization 390 // It may be enhanced in the future to provide some kind of prioritization
387 // mechanism. We should also consider a hashtable or binary tree if it turns 391 // mechanism. We should also consider a hashtable or binary tree if it turns
388 // out we have a lot of things here. 392 // out we have a lot of things here.
389 typedef std::map<GlobalRequestID, linked_ptr<ResourceLoader> > LoaderMap; 393 typedef std::map<GlobalRequestID, linked_ptr<ResourceLoader> > LoaderMap;
390 394
(...skipping 24 matching lines...) Expand all
415 // are done as a single callback to avoid spamming the UI thread. 419 // are done as a single callback to avoid spamming the UI thread.
416 static void UpdateLoadInfoOnUIThread(scoped_ptr<LoadInfoMap> info_map); 420 static void UpdateLoadInfoOnUIThread(scoped_ptr<LoadInfoMap> info_map);
417 421
418 // Gets the most interesting LoadInfo for each GlobalRoutingID. 422 // Gets the most interesting LoadInfo for each GlobalRoutingID.
419 scoped_ptr<LoadInfoMap> GetLoadInfoForAllRoutes(); 423 scoped_ptr<LoadInfoMap> GetLoadInfoForAllRoutes();
420 424
421 // Checks all pending requests and updates the load info if necessary. 425 // Checks all pending requests and updates the load info if necessary.
422 void UpdateLoadInfo(); 426 void UpdateLoadInfo();
423 427
424 // Resumes or cancels (if |cancel_requests| is true) any blocked requests. 428 // Resumes or cancels (if |cancel_requests| is true) any blocked requests.
425 void ProcessBlockedRequestsForRoute(int child_id, 429 void ProcessBlockedRequestsForFrame(int child_id,
426 int route_id, 430 int route_id,
427 bool cancel_requests); 431 bool cancel_requests);
428 432
429 void OnRequestResource(int routing_id, 433 void OnRequestResource(int routing_id,
430 int request_id, 434 int request_id,
431 const ResourceHostMsg_Request& request_data); 435 const ResourceHostMsg_Request& request_data);
432 void OnSyncLoad(int request_id, 436 void OnSyncLoad(int request_id,
433 const ResourceHostMsg_Request& request_data, 437 const ResourceHostMsg_Request& request_data,
434 IPC::Message* sync_result); 438 IPC::Message* sync_result);
435 439
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
542 // used as a special value all over the resource_dispatcher_host for 546 // used as a special value all over the resource_dispatcher_host for
543 // uninitialized variables.) This way, we no longer have the unlikely (but 547 // uninitialized variables.) This way, we no longer have the unlikely (but
544 // observed in the real world!) event where we have two requests with the same 548 // observed in the real world!) event where we have two requests with the same
545 // request_id_. 549 // request_id_.
546 int request_id_; 550 int request_id_;
547 551
548 // True if the resource dispatcher host has been shut down. 552 // True if the resource dispatcher host has been shut down.
549 bool is_shutdown_; 553 bool is_shutdown_;
550 554
551 typedef std::vector<linked_ptr<ResourceLoader> > BlockedLoadersList; 555 typedef std::vector<linked_ptr<ResourceLoader> > BlockedLoadersList;
552 typedef std::map<GlobalRoutingID, BlockedLoadersList*> BlockedLoadersMap; 556 typedef std::map<GlobalFrameRoutingID, BlockedLoadersList*> BlockedLoadersMap;
553 BlockedLoadersMap blocked_loaders_map_; 557 BlockedLoadersMap blocked_loaders_map_;
554 558
555 // Maps the child_ids to the approximate number of bytes 559 // Maps the child_ids to the approximate number of bytes
556 // being used to service its resource requests. No entry implies 0 cost. 560 // being used to service its resource requests. No entry implies 0 cost.
557 typedef std::map<int, OustandingRequestsStats> OutstandingRequestsStatsMap; 561 typedef std::map<int, OustandingRequestsStats> OutstandingRequestsStatsMap;
558 OutstandingRequestsStatsMap outstanding_requests_stats_map_; 562 OutstandingRequestsStatsMap outstanding_requests_stats_map_;
559 563
560 // |num_in_flight_requests_| is the total number of requests currently issued 564 // |num_in_flight_requests_| is the total number of requests currently issued
561 // summed across all renderers. 565 // summed across all renderers.
562 int num_in_flight_requests_; 566 int num_in_flight_requests_;
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
608 DelegateMap delegate_map_; 612 DelegateMap delegate_map_;
609 613
610 scoped_ptr<ResourceScheduler> scheduler_; 614 scoped_ptr<ResourceScheduler> scheduler_;
611 615
612 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); 616 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl);
613 }; 617 };
614 618
615 } // namespace content 619 } // namespace content
616 620
617 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ 621 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698