| 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 26 matching lines...) Expand all Loading... |
| 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/resource_dispatcher_host.h" | 39 #include "content/public/browser/resource_dispatcher_host.h" |
| 40 #include "ipc/ipc_message.h" | 40 #include "ipc/ipc_message.h" |
| 41 #include "net/cookies/canonical_cookie.h" | 41 #include "net/cookies/canonical_cookie.h" |
| 42 #include "net/url_request/url_request.h" | 42 #include "net/url_request/url_request.h" |
| 43 #include "webkit/glue/resource_type.h" | 43 #include "webkit/glue/resource_type.h" |
| 44 | 44 |
| 45 class ResourceHandler; | 45 class ResourceHandler; |
| 46 struct ResourceHostMsg_Request; | 46 struct ResourceHostMsg_Request; |
| 47 struct ViewMsg_SwapOut_Params; | |
| 48 | 47 |
| 49 namespace net { | 48 namespace net { |
| 50 class URLRequestJobFactory; | 49 class URLRequestJobFactory; |
| 51 } | 50 } |
| 52 | 51 |
| 53 namespace webkit_blob { | 52 namespace webkit_blob { |
| 54 class ShareableFileReference; | 53 class ShareableFileReference; |
| 55 } | 54 } |
| 56 | 55 |
| 57 namespace content { | 56 namespace content { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 // Cancels the given request if it still exists. We ignore cancels from the | 125 // Cancels the given request if it still exists. We ignore cancels from the |
| 127 // renderer in the event of a download. | 126 // renderer in the event of a download. |
| 128 void CancelRequest(int child_id, | 127 void CancelRequest(int child_id, |
| 129 int request_id, | 128 int request_id, |
| 130 bool from_renderer); | 129 bool from_renderer); |
| 131 | 130 |
| 132 // Marks the request as "parked". This happens if a request is | 131 // Marks the request as "parked". This happens if a request is |
| 133 // redirected cross-site and needs to be resumed by a new render view. | 132 // redirected cross-site and needs to be resumed by a new render view. |
| 134 void MarkAsTransferredNavigation(const GlobalRequestID& id); | 133 void MarkAsTransferredNavigation(const GlobalRequestID& id); |
| 135 | 134 |
| 135 // Resumes the request without transferring it to a new render view. |
| 136 void ResumeDeferredNavigation(const GlobalRequestID& id); |
| 137 |
| 136 // Returns the number of pending requests. This is designed for the unittests | 138 // Returns the number of pending requests. This is designed for the unittests |
| 137 int pending_requests() const { | 139 int pending_requests() const { |
| 138 return static_cast<int>(pending_loaders_.size()); | 140 return static_cast<int>(pending_loaders_.size()); |
| 139 } | 141 } |
| 140 | 142 |
| 141 // Intended for unit-tests only. Overrides the outstanding requests bound. | 143 // Intended for unit-tests only. Overrides the outstanding requests bound. |
| 142 void set_max_outstanding_requests_cost_per_process(int limit) { | 144 void set_max_outstanding_requests_cost_per_process(int limit) { |
| 143 max_outstanding_requests_cost_per_process_ = limit; | 145 max_outstanding_requests_cost_per_process_ = limit; |
| 144 } | 146 } |
| 145 void set_max_num_in_flight_requests_per_process(int limit) { | 147 void set_max_num_in_flight_requests_per_process(int limit) { |
| 146 max_num_in_flight_requests_per_process_ = limit; | 148 max_num_in_flight_requests_per_process_ = limit; |
| 147 } | 149 } |
| 148 void set_max_num_in_flight_requests(int limit) { | 150 void set_max_num_in_flight_requests(int limit) { |
| 149 max_num_in_flight_requests_ = limit; | 151 max_num_in_flight_requests_ = limit; |
| 150 } | 152 } |
| 151 | 153 |
| 152 // The average private bytes increase of the browser for each new pending | 154 // The average private bytes increase of the browser for each new pending |
| 153 // request. Experimentally obtained. | 155 // request. Experimentally obtained. |
| 154 static const int kAvgBytesPerOutstandingRequest = 4400; | 156 static const int kAvgBytesPerOutstandingRequest = 4400; |
| 155 | 157 |
| 156 SaveFileManager* save_file_manager() const { | 158 SaveFileManager* save_file_manager() const { |
| 157 return save_file_manager_.get(); | 159 return save_file_manager_.get(); |
| 158 } | 160 } |
| 159 | 161 |
| 160 // Called when the unload handler for a cross-site request has finished. | |
| 161 void OnSwapOutACK(const ViewMsg_SwapOut_Params& params); | |
| 162 | |
| 163 // Called when we want to simulate the renderer process sending | |
| 164 // ViewHostMsg_SwapOut_ACK in cases where the renderer has died or is | |
| 165 // unresponsive. | |
| 166 void OnSimulateSwapOutACK(const ViewMsg_SwapOut_Params& params); | |
| 167 | |
| 168 // Called when the renderer loads a resource from its internal cache. | 162 // Called when the renderer loads a resource from its internal cache. |
| 169 void OnDidLoadResourceFromMemoryCache(const GURL& url, | 163 void OnDidLoadResourceFromMemoryCache(const GURL& url, |
| 170 const std::string& security_info, | 164 const std::string& security_info, |
| 171 const std::string& http_method, | 165 const std::string& http_method, |
| 172 const std::string& mime_type, | 166 const std::string& mime_type, |
| 173 ResourceType::Type resource_type); | 167 ResourceType::Type resource_type); |
| 174 | 168 |
| 175 // Called when a RenderViewHost is created. | 169 // Called when a RenderViewHost is created. |
| 176 void OnRenderViewHostCreated(int child_id, int route_id); | 170 void OnRenderViewHostCreated(int child_id, int route_id); |
| 177 | 171 |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 static bool RenderViewForRequest(const net::URLRequest* request, | 279 static bool RenderViewForRequest(const net::URLRequest* request, |
| 286 int* render_process_host_id, | 280 int* render_process_host_id, |
| 287 int* render_view_host_id); | 281 int* render_view_host_id); |
| 288 | 282 |
| 289 // An init helper that runs on the IO thread. | 283 // An init helper that runs on the IO thread. |
| 290 void OnInit(); | 284 void OnInit(); |
| 291 | 285 |
| 292 // A shutdown helper that runs on the IO thread. | 286 // A shutdown helper that runs on the IO thread. |
| 293 void OnShutdown(); | 287 void OnShutdown(); |
| 294 | 288 |
| 295 // The real implementation of the OnSwapOutACK logic. OnSwapOutACK and | |
| 296 // OnSimulateSwapOutACK just call this method, supplying the |timed_out| | |
| 297 // parameter, which indicates whether the call is due to a timeout while | |
| 298 // waiting for SwapOut acknowledgement from the renderer process. | |
| 299 void HandleSwapOutACK(const ViewMsg_SwapOut_Params& params, bool timed_out); | |
| 300 | |
| 301 // Helper function for regular and download requests. | 289 // Helper function for regular and download requests. |
| 302 void BeginRequestInternal(scoped_ptr<net::URLRequest> request, | 290 void BeginRequestInternal(scoped_ptr<net::URLRequest> request, |
| 303 scoped_ptr<ResourceHandler> handler); | 291 scoped_ptr<ResourceHandler> handler); |
| 304 | 292 |
| 305 void StartLoading(ResourceRequestInfoImpl* info, | 293 void StartLoading(ResourceRequestInfoImpl* info, |
| 306 const linked_ptr<ResourceLoader>& loader); | 294 const linked_ptr<ResourceLoader>& loader); |
| 307 | 295 |
| 308 // We keep track of how much memory each request needs and how many requests | 296 // We keep track of how much memory each request needs and how many requests |
| 309 // are issued by each renderer. These are known as OustandingRequestStats. | 297 // are issued by each renderer. These are known as OustandingRequestStats. |
| 310 // Memory limits apply to all requests sent to us by the renderers. There is a | 298 // Memory limits apply to all requests sent to us by the renderers. There is a |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 typedef std::map<GlobalRoutingID, OfflinePolicy*> OfflineMap; | 498 typedef std::map<GlobalRoutingID, OfflinePolicy*> OfflineMap; |
| 511 | 499 |
| 512 OfflineMap offline_policy_map_; | 500 OfflineMap offline_policy_map_; |
| 513 | 501 |
| 514 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 502 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
| 515 }; | 503 }; |
| 516 | 504 |
| 517 } // namespace content | 505 } // namespace content |
| 518 | 506 |
| 519 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 507 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
| OLD | NEW |