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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // alt-clicking a link. If the download is started, |started_cb| will be | 84 // alt-clicking a link. If the download is started, |started_cb| will be |
85 // called on the UI thread with the DownloadId; otherwise an error code will | 85 // called on the UI thread with the DownloadId; otherwise an error code will |
86 // be returned. | 86 // be returned. |
87 net::Error BeginDownload( | 87 net::Error BeginDownload( |
88 scoped_ptr<net::URLRequest> request, | 88 scoped_ptr<net::URLRequest> request, |
89 bool prefer_cache, | 89 bool prefer_cache, |
90 const DownloadSaveInfo& save_info, | 90 const DownloadSaveInfo& save_info, |
91 const DownloadResourceHandler::OnStartedCallback& started_cb, | 91 const DownloadResourceHandler::OnStartedCallback& started_cb, |
92 int child_id, | 92 int child_id, |
93 int route_id, | 93 int route_id, |
94 const content::ResourceContext& context); | 94 content::ResourceContext* context); |
95 | 95 |
96 // Initiates a save file from the browser process (as opposed to a resource | 96 // Initiates a save file from the browser process (as opposed to a resource |
97 // request from the renderer or another child process). | 97 // request from the renderer or another child process). |
98 void BeginSaveFile(const GURL& url, | 98 void BeginSaveFile(const GURL& url, |
99 const GURL& referrer, | 99 const GURL& referrer, |
100 int child_id, | 100 int child_id, |
101 int route_id, | 101 int route_id, |
102 const content::ResourceContext& context); | 102 content::ResourceContext* context); |
103 | 103 |
104 // Cancels the given request if it still exists. We ignore cancels from the | 104 // Cancels the given request if it still exists. We ignore cancels from the |
105 // renderer in the event of a download. | 105 // renderer in the event of a download. |
106 void CancelRequest(int child_id, | 106 void CancelRequest(int child_id, |
107 int request_id, | 107 int request_id, |
108 bool from_renderer); | 108 bool from_renderer); |
109 | 109 |
110 // Follows a deferred redirect for the given request. | 110 // Follows a deferred redirect for the given request. |
111 // new_first_party_for_cookies, if non-empty, is the new cookie policy URL | 111 // new_first_party_for_cookies, if non-empty, is the new cookie policy URL |
112 // for the redirected URL. If the cookie policy URL needs changing, pass | 112 // for the redirected URL. If the cookie policy URL needs changing, pass |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // Force cancels any pending requests for the given process. | 168 // Force cancels any pending requests for the given process. |
169 void CancelRequestsForProcess(int child_id); | 169 void CancelRequestsForProcess(int child_id); |
170 | 170 |
171 // Force cancels any pending requests for the given route id. This method | 171 // Force cancels any pending requests for the given route id. This method |
172 // acts like CancelRequestsForProcess when route_id is -1. | 172 // acts like CancelRequestsForProcess when route_id is -1. |
173 void CancelRequestsForRoute(int child_id, int route_id); | 173 void CancelRequestsForRoute(int child_id, int route_id); |
174 | 174 |
175 // Force cancels any pending requests for the given |context|. This is | 175 // Force cancels any pending requests for the given |context|. This is |
176 // necessary to ensure that before |context| goes away, all requests | 176 // necessary to ensure that before |context| goes away, all requests |
177 // for it are dead. | 177 // for it are dead. |
178 void CancelRequestsForContext(const content::ResourceContext* context); | 178 void CancelRequestsForContext(content::ResourceContext* context); |
179 | 179 |
180 // net::URLRequest::Delegate | 180 // net::URLRequest::Delegate |
181 virtual void OnReceivedRedirect(net::URLRequest* request, | 181 virtual void OnReceivedRedirect(net::URLRequest* request, |
182 const GURL& new_url, | 182 const GURL& new_url, |
183 bool* defer_redirect) OVERRIDE; | 183 bool* defer_redirect) OVERRIDE; |
184 virtual void OnAuthRequired(net::URLRequest* request, | 184 virtual void OnAuthRequired(net::URLRequest* request, |
185 net::AuthChallengeInfo* auth_info) OVERRIDE; | 185 net::AuthChallengeInfo* auth_info) OVERRIDE; |
186 virtual void OnCertificateRequested( | 186 virtual void OnCertificateRequested( |
187 net::URLRequest* request, | 187 net::URLRequest* request, |
188 net::SSLCertRequestInfo* cert_request_info) OVERRIDE; | 188 net::SSLCertRequestInfo* cert_request_info) OVERRIDE; |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
270 } | 270 } |
271 | 271 |
272 // Marks the request as "parked". This happens if a request is | 272 // Marks the request as "parked". This happens if a request is |
273 // redirected cross-site and needs to be resumed by a new render view. | 273 // redirected cross-site and needs to be resumed by a new render view. |
274 void MarkAsTransferredNavigation( | 274 void MarkAsTransferredNavigation( |
275 const content::GlobalRequestID& transferred_request_id, | 275 const content::GlobalRequestID& transferred_request_id, |
276 net::URLRequest* transferred_request); | 276 net::URLRequest* transferred_request); |
277 | 277 |
278 scoped_refptr<ResourceHandler> CreateResourceHandlerForDownload( | 278 scoped_refptr<ResourceHandler> CreateResourceHandlerForDownload( |
279 net::URLRequest* request, | 279 net::URLRequest* request, |
280 const content::ResourceContext& context, | 280 content::ResourceContext* context, |
281 int child_id, | 281 int child_id, |
282 int route_id, | 282 int route_id, |
283 int request_id, | 283 int request_id, |
284 const DownloadSaveInfo& save_info, | 284 const DownloadSaveInfo& save_info, |
285 const DownloadResourceHandler::OnStartedCallback& started_cb); | 285 const DownloadResourceHandler::OnStartedCallback& started_cb); |
286 | 286 |
287 private: | 287 private: |
288 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 288 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
289 TestBlockedRequestsProcessDies); | 289 TestBlockedRequestsProcessDies); |
290 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 290 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
421 const GURL& new_first_party_for_cookies); | 421 const GURL& new_first_party_for_cookies); |
422 void OnReleaseDownloadedFile(int request_id); | 422 void OnReleaseDownloadedFile(int request_id); |
423 | 423 |
424 // Creates ResourceDispatcherHostRequestInfo for a download or page save. | 424 // Creates ResourceDispatcherHostRequestInfo for a download or page save. |
425 // |download| should be true if the request is a file download. | 425 // |download| should be true if the request is a file download. |
426 ResourceDispatcherHostRequestInfo* CreateRequestInfo( | 426 ResourceDispatcherHostRequestInfo* CreateRequestInfo( |
427 ResourceHandler* handler, | 427 ResourceHandler* handler, |
428 int child_id, | 428 int child_id, |
429 int route_id, | 429 int route_id, |
430 bool download, | 430 bool download, |
431 const content::ResourceContext& context); | 431 content::ResourceContext* context); |
432 | 432 |
433 // Returns true if |request| is in |pending_requests_|. | 433 // Returns true if |request| is in |pending_requests_|. |
434 bool IsValidRequest(net::URLRequest* request); | 434 bool IsValidRequest(net::URLRequest* request); |
435 | 435 |
436 // Sends the given notification on the UI thread. The RenderViewHost's | 436 // Sends the given notification on the UI thread. The RenderViewHost's |
437 // controller is used as the source. | 437 // controller is used as the source. |
438 template <class T> | 438 template <class T> |
439 static void NotifyOnUI(int type, | 439 static void NotifyOnUI(int type, |
440 int render_process_id, | 440 int render_process_id, |
441 int render_view_id, | 441 int render_view_id, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 // Maps the request ID of request that is being transferred to a new RVH | 537 // Maps the request ID of request that is being transferred to a new RVH |
538 // to the respective request. | 538 // to the respective request. |
539 typedef std::map<content::GlobalRequestID, net::URLRequest*> | 539 typedef std::map<content::GlobalRequestID, net::URLRequest*> |
540 TransferredNavigations; | 540 TransferredNavigations; |
541 TransferredNavigations transferred_navigations_; | 541 TransferredNavigations transferred_navigations_; |
542 | 542 |
543 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); | 543 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); |
544 }; | 544 }; |
545 | 545 |
546 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ | 546 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ |
OLD | NEW |