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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 // has_new_first_party_for_cookies, and new_first_party_for_cookies will not | 129 // has_new_first_party_for_cookies, and new_first_party_for_cookies will not |
130 // be used. | 130 // be used. |
131 void FollowDeferredRedirect(int child_id, | 131 void FollowDeferredRedirect(int child_id, |
132 int request_id, | 132 int request_id, |
133 bool has_new_first_party_for_cookies, | 133 bool has_new_first_party_for_cookies, |
134 const GURL& new_first_party_for_cookies); | 134 const GURL& new_first_party_for_cookies); |
135 | 135 |
136 // Starts a request that was deferred during ResourceHandler::OnWillStart(). | 136 // Starts a request that was deferred during ResourceHandler::OnWillStart(). |
137 void StartDeferredRequest(int child_id, int request_id); | 137 void StartDeferredRequest(int child_id, int request_id); |
138 | 138 |
| 139 // Resumes network activity for a particular request. |
| 140 void ResumeDeferredRequest(int child_id, int request_id); |
| 141 |
139 // Returns true if it's ok to send the data. If there are already too many | 142 // Returns true if it's ok to send the data. If there are already too many |
140 // data messages pending, it pauses the request and returns false. In this | 143 // data messages pending, it pauses the request and returns false. In this |
141 // case the caller should not send the data. | 144 // case the caller should not send the data. |
142 bool WillSendData(int child_id, int request_id); | 145 bool WillSendData(int child_id, int request_id); |
143 | 146 |
144 // Pauses or resumes network activity for a particular request. | |
145 void PauseRequest(int child_id, int request_id, bool pause); | |
146 | |
147 // Returns the number of pending requests. This is designed for the unittests | 147 // Returns the number of pending requests. This is designed for the unittests |
148 int pending_requests() const { | 148 int pending_requests() const { |
149 return static_cast<int>(pending_requests_.size()); | 149 return static_cast<int>(pending_requests_.size()); |
150 } | 150 } |
151 | 151 |
152 // Intended for unit-tests only. Returns the memory cost of all the | 152 // Intended for unit-tests only. Returns the memory cost of all the |
153 // outstanding requests (pending and blocked) for |child_id|. | 153 // outstanding requests (pending and blocked) for |child_id|. |
154 int GetOutstandingRequestsMemoryCost(int child_id) const; | 154 int GetOutstandingRequestsMemoryCost(int child_id) const; |
155 | 155 |
156 // Intended for unit-tests only. Overrides the outstanding requests bound. | 156 // Intended for unit-tests only. Overrides the outstanding requests bound. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 net::URLRequest* request, | 257 net::URLRequest* request, |
258 ResourceContext* context, | 258 ResourceContext* context, |
259 int child_id, | 259 int child_id, |
260 int route_id, | 260 int route_id, |
261 int request_id, | 261 int request_id, |
262 bool is_content_initiated, | 262 bool is_content_initiated, |
263 const DownloadSaveInfo& save_info, | 263 const DownloadSaveInfo& save_info, |
264 const DownloadResourceHandler::OnStartedCallback& started_cb); | 264 const DownloadResourceHandler::OnStartedCallback& started_cb); |
265 | 265 |
266 private: | 266 private: |
| 267 friend class ResourceDispatcherHostTest; |
267 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 268 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
268 TestBlockedRequestsProcessDies); | 269 TestBlockedRequestsProcessDies); |
269 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 270 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
270 IncrementOutstandingRequestsMemoryCost); | 271 IncrementOutstandingRequestsMemoryCost); |
271 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 272 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
272 CalculateApproximateMemoryCost); | 273 CalculateApproximateMemoryCost); |
273 | 274 |
274 class ShutdownTask; | 275 class ShutdownTask; |
275 | 276 |
276 friend class ShutdownTask; | 277 friend class ShutdownTask; |
277 | 278 |
278 // Extracts the render view/process host's identifiers from the given request | 279 // Extracts the render view/process host's identifiers from the given request |
279 // and places them in the given out params (both required). If there are no | 280 // and places them in the given out params (both required). If there are no |
280 // such IDs associated with the request (such as non-page-related requests), | 281 // such IDs associated with the request (such as non-page-related requests), |
281 // this function will return false and both out params will be -1. | 282 // this function will return false and both out params will be -1. |
282 static bool RenderViewForRequest(const net::URLRequest* request, | 283 static bool RenderViewForRequest(const net::URLRequest* request, |
283 int* render_process_host_id, | 284 int* render_process_host_id, |
284 int* render_view_host_id); | 285 int* render_view_host_id); |
285 | 286 |
286 // A shutdown helper that runs on the IO thread. | 287 // A shutdown helper that runs on the IO thread. |
287 void OnShutdown(); | 288 void OnShutdown(); |
288 | 289 |
289 void StartRequest(net::URLRequest* request); | 290 void StartRequest(net::URLRequest* request); |
290 | 291 |
291 // Returns true if the request is paused. | 292 // Returns true if the request is paused. |
292 bool PauseRequestIfNeeded(ResourceRequestInfoImpl* info); | 293 bool PauseRequestIfNeeded(ResourceRequestInfoImpl* info); |
293 | 294 |
| 295 // Pause or resume network activity for a particular request. |
| 296 void PauseRequest(int child_id, int request_id, bool pause); |
| 297 |
294 // Resumes the given request by calling OnResponseStarted or OnReadCompleted. | 298 // Resumes the given request by calling OnResponseStarted or OnReadCompleted. |
295 void ResumeRequest(const GlobalRequestID& request_id); | 299 void ResumeRequest(const GlobalRequestID& request_id); |
296 | 300 |
297 // Internal function to start reading for the first time. | 301 // Internal function to start reading for the first time. |
298 void StartReading(net::URLRequest* request); | 302 void StartReading(net::URLRequest* request); |
299 | 303 |
300 // Reads data from the response using our internal buffer as async IO. | 304 // Reads data from the response using our internal buffer as async IO. |
301 // Returns true if data is available immediately, false otherwise. If the | 305 // Returns true if data is available immediately, false otherwise. If the |
302 // return value is false, we will receive a OnReadComplete() callback later. | 306 // return value is false, we will receive a OnReadComplete() callback later. |
303 bool Read(net::URLRequest* request, int* bytes_read); | 307 bool Read(net::URLRequest* request, int* bytes_read); |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
518 // http://crbug.com/90971 - Assists in tracking down use-after-frees on | 522 // http://crbug.com/90971 - Assists in tracking down use-after-frees on |
519 // shutdown. | 523 // shutdown. |
520 std::set<const ResourceContext*> active_resource_contexts_; | 524 std::set<const ResourceContext*> active_resource_contexts_; |
521 | 525 |
522 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 526 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
523 }; | 527 }; |
524 | 528 |
525 } // namespace content | 529 } // namespace content |
526 | 530 |
527 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 531 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
OLD | NEW |