OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 fowards the messages from the | 7 // dispatches them to URLRequests. It then fowards 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 13 matching lines...) Expand all Loading... |
24 #include "chrome/common/child_process_info.h" | 24 #include "chrome/common/child_process_info.h" |
25 #include "chrome/browser/privacy_blacklist/blocked_response.h" | 25 #include "chrome/browser/privacy_blacklist/blocked_response.h" |
26 #include "ipc/ipc_message.h" | 26 #include "ipc/ipc_message.h" |
27 #include "net/url_request/url_request.h" | 27 #include "net/url_request/url_request.h" |
28 #include "webkit/glue/resource_type.h" | 28 #include "webkit/glue/resource_type.h" |
29 | 29 |
30 class CrossSiteResourceHandler; | 30 class CrossSiteResourceHandler; |
31 class DownloadFileManager; | 31 class DownloadFileManager; |
32 class DownloadRequestManager; | 32 class DownloadRequestManager; |
33 class LoginHandler; | 33 class LoginHandler; |
34 class MessageLoop; | |
35 class PluginService; | 34 class PluginService; |
36 class ResourceDispatcherHostRequestInfo; | 35 class ResourceDispatcherHostRequestInfo; |
37 class ResourceHandler; | 36 class ResourceHandler; |
38 class SafeBrowsingService; | 37 class SafeBrowsingService; |
39 class SaveFileManager; | 38 class SaveFileManager; |
40 class SSLClientAuthHandler; | 39 class SSLClientAuthHandler; |
41 class UserScriptListener; | 40 class UserScriptListener; |
42 class URLRequestContext; | 41 class URLRequestContext; |
43 class WebKitThread; | 42 class WebKitThread; |
44 struct ViewHostMsg_Resource_Request; | 43 struct ViewHostMsg_Resource_Request; |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 int child_id; | 97 int child_id; |
99 int request_id; | 98 int request_id; |
100 | 99 |
101 bool operator<(const GlobalRequestID& other) const { | 100 bool operator<(const GlobalRequestID& other) const { |
102 if (child_id == other.child_id) | 101 if (child_id == other.child_id) |
103 return request_id < other.request_id; | 102 return request_id < other.request_id; |
104 return child_id < other.child_id; | 103 return child_id < other.child_id; |
105 } | 104 } |
106 }; | 105 }; |
107 | 106 |
108 // TODO(jam): take the parameter out once 25354 is done. | 107 ResourceDispatcherHost(); |
109 explicit ResourceDispatcherHost(MessageLoop* io_loop); | |
110 ~ResourceDispatcherHost(); | 108 ~ResourceDispatcherHost(); |
111 | 109 |
112 void Initialize(); | 110 void Initialize(); |
113 | 111 |
114 // Puts the resource dispatcher host in an inactive state (unable to begin | 112 // Puts the resource dispatcher host in an inactive state (unable to begin |
115 // new requests). Cancels all pending requests. | 113 // new requests). Cancels all pending requests. |
116 void Shutdown(); | 114 void Shutdown(); |
117 | 115 |
118 // Returns true if the message was a resource message that was processed. | 116 // Returns true if the message was a resource message that was processed. |
119 // If it was, message_was_ok will be false iff the message was corrupt. | 117 // If it was, message_was_ok will be false iff the message was corrupt. |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 184 } |
187 | 185 |
188 SafeBrowsingService* safe_browsing_service() const { | 186 SafeBrowsingService* safe_browsing_service() const { |
189 return safe_browsing_; | 187 return safe_browsing_; |
190 } | 188 } |
191 | 189 |
192 WebKitThread* webkit_thread() const { | 190 WebKitThread* webkit_thread() const { |
193 return webkit_thread_.get(); | 191 return webkit_thread_.get(); |
194 } | 192 } |
195 | 193 |
196 MessageLoop* ui_loop() const { return ui_loop_; } | |
197 | |
198 // Called when the onunload handler for a cross-site request has finished. | 194 // Called when the onunload handler for a cross-site request has finished. |
199 void OnClosePageACK(const ViewMsg_ClosePage_Params& params); | 195 void OnClosePageACK(const ViewMsg_ClosePage_Params& params); |
200 | 196 |
201 // Force cancels any pending requests for the given process. | 197 // Force cancels any pending requests for the given process. |
202 void CancelRequestsForProcess(int process_unique_id); | 198 void CancelRequestsForProcess(int process_unique_id); |
203 | 199 |
204 // Force cancels any pending requests for the given route id. This method | 200 // Force cancels any pending requests for the given route id. This method |
205 // acts like CancelRequestsForProcess when route_id is -1. | 201 // acts like CancelRequestsForProcess when route_id is -1. |
206 void CancelRequestsForRoute(int process_unique_id, int route_id); | 202 void CancelRequestsForRoute(int process_unique_id, int route_id); |
207 | 203 |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 void OnDataReceivedACK(int request_id); | 400 void OnDataReceivedACK(int request_id); |
405 void OnUploadProgressACK(int request_id); | 401 void OnUploadProgressACK(int request_id); |
406 void OnCancelRequest(int request_id); | 402 void OnCancelRequest(int request_id); |
407 void OnFollowRedirect(int request_id); | 403 void OnFollowRedirect(int request_id); |
408 | 404 |
409 // Returns true if the message passed in is a resource related message. | 405 // Returns true if the message passed in is a resource related message. |
410 static bool IsResourceDispatcherHostMessage(const IPC::Message&); | 406 static bool IsResourceDispatcherHostMessage(const IPC::Message&); |
411 | 407 |
412 PendingRequestList pending_requests_; | 408 PendingRequestList pending_requests_; |
413 | 409 |
414 // We cache the UI message loop so we can create new UI-related objects on it. | |
415 MessageLoop* ui_loop_; | |
416 | |
417 // We cache the IO loop to ensure that GetURLRequest is only called from the | |
418 // IO thread. | |
419 MessageLoop* io_loop_; | |
420 | |
421 // A timer that periodically calls UpdateLoadStates while pending_requests_ | 410 // A timer that periodically calls UpdateLoadStates while pending_requests_ |
422 // is not empty. | 411 // is not empty. |
423 base::RepeatingTimer<ResourceDispatcherHost> update_load_states_timer_; | 412 base::RepeatingTimer<ResourceDispatcherHost> update_load_states_timer_; |
424 | 413 |
425 // We own the download file writing thread and manager | 414 // We own the download file writing thread and manager |
426 scoped_refptr<DownloadFileManager> download_file_manager_; | 415 scoped_refptr<DownloadFileManager> download_file_manager_; |
427 | 416 |
428 // Determines whether a download is allowed. | 417 // Determines whether a download is allowed. |
429 scoped_refptr<DownloadRequestManager> download_request_manager_; | 418 scoped_refptr<DownloadRequestManager> download_request_manager_; |
430 | 419 |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
481 | 470 |
482 // Keeps track of elements blocked by the Privacy Blacklist. | 471 // Keeps track of elements blocked by the Privacy Blacklist. |
483 chrome::BlockedResponse blocked_; | 472 chrome::BlockedResponse blocked_; |
484 | 473 |
485 static bool g_is_http_prioritization_enabled; | 474 static bool g_is_http_prioritization_enabled; |
486 | 475 |
487 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); | 476 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); |
488 }; | 477 }; |
489 | 478 |
490 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ | 479 #endif // CHROME_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ |
OLD | NEW |