| 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 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 121 // has_new_first_party_for_cookies, and new_first_party_for_cookies will not | 121 // has_new_first_party_for_cookies, and new_first_party_for_cookies will not |
| 122 // be used. | 122 // be used. |
| 123 void FollowDeferredRedirect(int child_id, | 123 void FollowDeferredRedirect(int child_id, |
| 124 int request_id, | 124 int request_id, |
| 125 bool has_new_first_party_for_cookies, | 125 bool has_new_first_party_for_cookies, |
| 126 const GURL& new_first_party_for_cookies); | 126 const GURL& new_first_party_for_cookies); |
| 127 | 127 |
| 128 // Starts a request that was deferred during ResourceHandler::OnWillStart(). | 128 // Starts a request that was deferred during ResourceHandler::OnWillStart(). |
| 129 void StartDeferredRequest(int child_id, int request_id); | 129 void StartDeferredRequest(int child_id, int request_id); |
| 130 | 130 |
| 131 // Resumes network activity for a particular request. |
| 132 void ResumeDeferredRequest(int child_id, int request_id); |
| 133 |
| 131 // Returns true if it's ok to send the data. If there are already too many | 134 // Returns true if it's ok to send the data. If there are already too many |
| 132 // data messages pending, it pauses the request and returns false. In this | 135 // data messages pending, it pauses the request and returns false. In this |
| 133 // case the caller should not send the data. | 136 // case the caller should not send the data. |
| 134 bool WillSendData(int child_id, int request_id); | 137 bool WillSendData(int child_id, int request_id); |
| 135 | 138 |
| 136 // Pauses or resumes network activity for a particular request. | |
| 137 void PauseRequest(int child_id, int request_id, bool pause); | |
| 138 | |
| 139 // Returns the number of pending requests. This is designed for the unittests | 139 // Returns the number of pending requests. This is designed for the unittests |
| 140 int pending_requests() const { | 140 int pending_requests() const { |
| 141 return static_cast<int>(pending_requests_.size()); | 141 return static_cast<int>(pending_requests_.size()); |
| 142 } | 142 } |
| 143 | 143 |
| 144 // Intended for unit-tests only. Returns the memory cost of all the | 144 // Intended for unit-tests only. Returns the memory cost of all the |
| 145 // outstanding requests (pending and blocked) for |child_id|. | 145 // outstanding requests (pending and blocked) for |child_id|. |
| 146 int GetOutstandingRequestsMemoryCost(int child_id) const; | 146 int GetOutstandingRequestsMemoryCost(int child_id) const; |
| 147 | 147 |
| 148 // Intended for unit-tests only. Overrides the outstanding requests bound. | 148 // Intended for unit-tests only. Overrides the outstanding requests bound. |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 scoped_refptr<ResourceHandler> CreateResourceHandlerForDownload( | 253 scoped_refptr<ResourceHandler> CreateResourceHandlerForDownload( |
| 254 net::URLRequest* request, | 254 net::URLRequest* request, |
| 255 ResourceContext* context, | 255 ResourceContext* context, |
| 256 int child_id, | 256 int child_id, |
| 257 int route_id, | 257 int route_id, |
| 258 int request_id, | 258 int request_id, |
| 259 const DownloadSaveInfo& save_info, | 259 const DownloadSaveInfo& save_info, |
| 260 const DownloadResourceHandler::OnStartedCallback& started_cb); | 260 const DownloadResourceHandler::OnStartedCallback& started_cb); |
| 261 | 261 |
| 262 private: | 262 private: |
| 263 friend class ResourceDispatcherHostTest; |
| 263 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 264 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 264 TestBlockedRequestsProcessDies); | 265 TestBlockedRequestsProcessDies); |
| 265 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 266 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 266 IncrementOutstandingRequestsMemoryCost); | 267 IncrementOutstandingRequestsMemoryCost); |
| 267 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 268 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 268 CalculateApproximateMemoryCost); | 269 CalculateApproximateMemoryCost); |
| 269 | 270 |
| 270 class ShutdownTask; | 271 class ShutdownTask; |
| 271 | 272 |
| 272 friend class ShutdownTask; | 273 friend class ShutdownTask; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 284 | 285 |
| 285 // The real implementation of the OnSwapOutACK logic. Public methods call | 286 // The real implementation of the OnSwapOutACK logic. Public methods call |
| 286 // this method with the proper value for the timed_out parameter. | 287 // this method with the proper value for the timed_out parameter. |
| 287 void HandleSwapOutACK(const ViewMsg_SwapOut_Params& params, bool timed_out); | 288 void HandleSwapOutACK(const ViewMsg_SwapOut_Params& params, bool timed_out); |
| 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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 // http://crbug.com/90971 - Assists in tracking down use-after-frees on | 519 // http://crbug.com/90971 - Assists in tracking down use-after-frees on |
| 516 // shutdown. | 520 // shutdown. |
| 517 std::set<const ResourceContext*> canceled_resource_contexts_; | 521 std::set<const ResourceContext*> canceled_resource_contexts_; |
| 518 | 522 |
| 519 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 523 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
| 520 }; | 524 }; |
| 521 | 525 |
| 522 } // namespace content | 526 } // namespace content |
| 523 | 527 |
| 524 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 528 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
| OLD | NEW |