| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 16 matching lines...) Expand all Loading... |
| 27 #include "ipc/ipc_message.h" | 27 #include "ipc/ipc_message.h" |
| 28 #include "net/url_request/url_request.h" | 28 #include "net/url_request/url_request.h" |
| 29 #include "webkit/glue/resource_type.h" | 29 #include "webkit/glue/resource_type.h" |
| 30 | 30 |
| 31 class CrossSiteResourceHandler; | 31 class CrossSiteResourceHandler; |
| 32 class DownloadFileManager; | 32 class DownloadFileManager; |
| 33 class DownloadRequestLimiter; | 33 class DownloadRequestLimiter; |
| 34 class LoginHandler; | 34 class LoginHandler; |
| 35 class NotificationDetails; | 35 class NotificationDetails; |
| 36 class PluginService; | 36 class PluginService; |
| 37 class ResourceDispatcherHostDelegate; |
| 37 class ResourceDispatcherHostRequestInfo; | 38 class ResourceDispatcherHostRequestInfo; |
| 38 class ResourceHandler; | 39 class ResourceHandler; |
| 39 class ResourceMessageFilter; | 40 class ResourceMessageFilter; |
| 40 class SaveFileManager; | 41 class SaveFileManager; |
| 41 class SSLClientAuthHandler; | 42 class SSLClientAuthHandler; |
| 42 class WebKitThread; | 43 class WebKitThread; |
| 43 struct DownloadSaveInfo; | 44 struct DownloadSaveInfo; |
| 44 struct GlobalRequestID; | 45 struct GlobalRequestID; |
| 45 struct ResourceHostMsg_Request; | 46 struct ResourceHostMsg_Request; |
| 46 struct ViewMsg_SwapOut_Params; | 47 struct ViewMsg_SwapOut_Params; |
| 47 | 48 |
| 48 namespace content { | 49 namespace content { |
| 49 class ResourceContext; | 50 class ResourceContext; |
| 50 } | 51 } |
| 51 namespace net { | 52 namespace net { |
| 52 class URLRequestJobFactory; | 53 class URLRequestJobFactory; |
| 53 } // namespace net | 54 } // namespace net |
| 54 | 55 |
| 55 namespace webkit_blob { | 56 namespace webkit_blob { |
| 56 class DeletableFileReference; | 57 class DeletableFileReference; |
| 57 } | 58 } |
| 58 | 59 |
| 59 class ResourceDispatcherHost : public net::URLRequest::Delegate { | 60 class ResourceDispatcherHost : public net::URLRequest::Delegate { |
| 60 public: | 61 public: |
| 61 class Observer { | |
| 62 public: | |
| 63 // Called when a request begins. Return false to abort the request. | |
| 64 virtual bool ShouldBeginRequest( | |
| 65 int child_id, int route_id, | |
| 66 const ResourceHostMsg_Request& request_data, | |
| 67 const content::ResourceContext& resource_context, | |
| 68 const GURL& referrer) = 0; | |
| 69 | |
| 70 // Called after ShouldBeginRequest when all the resource handlers from the | |
| 71 // content layer have been added. | |
| 72 virtual void RequestBeginning(ResourceHandler** handler, | |
| 73 net::URLRequest* request, | |
| 74 bool is_subresource, | |
| 75 int child_id, | |
| 76 int route_id) = 0; | |
| 77 | |
| 78 // Called when a download is starting, after the resource handles from the | |
| 79 // content layer have been added. | |
| 80 virtual void DownloadStarting(ResourceHandler** handler, | |
| 81 int child_id, | |
| 82 int route_id) = 0; | |
| 83 | |
| 84 // Called to determine whether a request's start should be deferred. This | |
| 85 // is only called if the ResourceHandler associated with the request does | |
| 86 // not ask for a deferral. A return value of true will defer the start of | |
| 87 // the request, false will continue the request. | |
| 88 virtual bool ShouldDeferStart( | |
| 89 net::URLRequest* request, | |
| 90 const content::ResourceContext& resource_context) = 0; | |
| 91 | |
| 92 // Called when an SSL Client Certificate is requested. If false is returned, | |
| 93 // the request is canceled. Otherwise, the certificate is chosen. | |
| 94 virtual bool AcceptSSLClientCertificateRequest( | |
| 95 net::URLRequest* request, | |
| 96 net::SSLCertRequestInfo* cert_request_info) = 0; | |
| 97 | |
| 98 // Called when authentication is required and credentials are needed. If | |
| 99 // false is returned, CancelAuth() is called on the URLRequest and the error | |
| 100 // page is shown. If true is returned, the user will be prompted for | |
| 101 // authentication credentials. | |
| 102 virtual bool AcceptAuthRequest(net::URLRequest* request, | |
| 103 net::AuthChallengeInfo* auth_info) = 0; | |
| 104 | |
| 105 protected: | |
| 106 Observer() {} | |
| 107 virtual ~Observer() {} | |
| 108 }; | |
| 109 | |
| 110 explicit ResourceDispatcherHost( | 62 explicit ResourceDispatcherHost( |
| 111 const ResourceQueue::DelegateSet& resource_queue_delegates); | 63 const ResourceQueue::DelegateSet& resource_queue_delegates); |
| 112 virtual ~ResourceDispatcherHost(); | 64 virtual ~ResourceDispatcherHost(); |
| 113 | 65 |
| 114 void Initialize(); | 66 void Initialize(); |
| 115 | 67 |
| 116 // Puts the resource dispatcher host in an inactive state (unable to begin | 68 // Puts the resource dispatcher host in an inactive state (unable to begin |
| 117 // new requests). Cancels all pending requests. | 69 // new requests). Cancels all pending requests. |
| 118 void Shutdown(); | 70 void Shutdown(); |
| 119 | 71 |
| (...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 // Controls if we launch or squash prefetch requests as they arrive | 238 // Controls if we launch or squash prefetch requests as they arrive |
| 287 // from renderers. | 239 // from renderers. |
| 288 static bool is_prefetch_enabled(); | 240 static bool is_prefetch_enabled(); |
| 289 static void set_is_prefetch_enabled(bool value); | 241 static void set_is_prefetch_enabled(bool value); |
| 290 | 242 |
| 291 // Controls whether third-party sub-content can pop-up HTTP basic auth | 243 // Controls whether third-party sub-content can pop-up HTTP basic auth |
| 292 // dialog boxes. | 244 // dialog boxes. |
| 293 bool allow_cross_origin_auth_prompt(); | 245 bool allow_cross_origin_auth_prompt(); |
| 294 void set_allow_cross_origin_auth_prompt(bool value); | 246 void set_allow_cross_origin_auth_prompt(bool value); |
| 295 | 247 |
| 296 // This does not take ownership of the observer. It is expected that the | 248 // This does not take ownership of the delegate. It is expected that the |
| 297 // observer have a longer lifetime than the ResourceDispatcherHost. | 249 // delegate have a longer lifetime than the ResourceDispatcherHost. |
| 298 void set_observer(Observer* observer) { observer_ = observer; } | 250 void set_delegate(ResourceDispatcherHostDelegate* delegate) { |
| 251 delegate_ = delegate; |
| 252 } |
| 299 | 253 |
| 300 private: | 254 private: |
| 301 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 255 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 302 TestBlockedRequestsProcessDies); | 256 TestBlockedRequestsProcessDies); |
| 303 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 257 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 304 IncrementOutstandingRequestsMemoryCost); | 258 IncrementOutstandingRequestsMemoryCost); |
| 305 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 259 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 306 CalculateApproximateMemoryCost); | 260 CalculateApproximateMemoryCost); |
| 307 | 261 |
| 308 class ShutdownTask; | 262 class ShutdownTask; |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 // individual requests is given by CalculateApproximateMemoryCost). | 481 // individual requests is given by CalculateApproximateMemoryCost). |
| 528 // The total number of outstanding requests is roughly: | 482 // The total number of outstanding requests is roughly: |
| 529 // (max_outstanding_requests_cost_per_process_ / | 483 // (max_outstanding_requests_cost_per_process_ / |
| 530 // kAvgBytesPerOutstandingRequest) | 484 // kAvgBytesPerOutstandingRequest) |
| 531 int max_outstanding_requests_cost_per_process_; | 485 int max_outstanding_requests_cost_per_process_; |
| 532 | 486 |
| 533 // Used during IPC message dispatching so that the handlers can get a pointer | 487 // Used during IPC message dispatching so that the handlers can get a pointer |
| 534 // to the source of the message. | 488 // to the source of the message. |
| 535 ResourceMessageFilter* filter_; | 489 ResourceMessageFilter* filter_; |
| 536 | 490 |
| 537 Observer* observer_; | 491 ResourceDispatcherHostDelegate* delegate_; |
| 538 | 492 |
| 539 static bool is_prefetch_enabled_; | 493 static bool is_prefetch_enabled_; |
| 540 bool allow_cross_origin_auth_prompt_; | 494 bool allow_cross_origin_auth_prompt_; |
| 541 | 495 |
| 542 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); | 496 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); |
| 543 }; | 497 }; |
| 544 | 498 |
| 545 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ | 499 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ |
| OLD | NEW |