| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 namespace net { | 52 namespace net { |
| 53 class URLRequestJobFactory; | 53 class URLRequestJobFactory; |
| 54 } // namespace net | 54 } // namespace net |
| 55 | 55 |
| 56 namespace webkit_blob { | 56 namespace webkit_blob { |
| 57 class DeletableFileReference; | 57 class DeletableFileReference; |
| 58 } | 58 } |
| 59 | 59 |
| 60 class ResourceDispatcherHost : public net::URLRequest::Delegate { | 60 class ResourceDispatcherHost : public net::URLRequest::Delegate { |
| 61 public: | 61 public: |
| 62 class Observer { |
| 63 public: |
| 64 virtual bool ShouldBeginRequest(int child_id, int route_id, |
| 65 const ResourceHostMsg_Request& request_data, |
| 66 const content::ResourceContext& resource_context, |
| 67 const GURL& referrer) = 0; |
| 68 |
| 69 virtual void MutateLoadFlags(int child_id, int route_id, |
| 70 int* load_flags) = 0; |
| 71 protected: |
| 72 Observer() {} |
| 73 virtual ~Observer() {} |
| 74 }; |
| 75 |
| 62 explicit ResourceDispatcherHost( | 76 explicit ResourceDispatcherHost( |
| 63 const ResourceQueue::DelegateSet& resource_queue_delegates); | 77 const ResourceQueue::DelegateSet& resource_queue_delegates); |
| 64 ~ResourceDispatcherHost(); | 78 ~ResourceDispatcherHost(); |
| 65 | 79 |
| 66 void Initialize(); | 80 void Initialize(); |
| 67 | 81 |
| 68 // Puts the resource dispatcher host in an inactive state (unable to begin | 82 // Puts the resource dispatcher host in an inactive state (unable to begin |
| 69 // new requests). Cancels all pending requests. | 83 // new requests). Cancels all pending requests. |
| 70 void Shutdown(); | 84 void Shutdown(); |
| 71 | 85 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 void UnregisterDownloadedTempFile(int child_id, int request_id); | 251 void UnregisterDownloadedTempFile(int child_id, int request_id); |
| 238 | 252 |
| 239 // Needed for the sync IPC message dispatcher macros. | 253 // Needed for the sync IPC message dispatcher macros. |
| 240 bool Send(IPC::Message* message); | 254 bool Send(IPC::Message* message); |
| 241 | 255 |
| 242 // Controls if we launch or squash prefetch requests as they arrive | 256 // Controls if we launch or squash prefetch requests as they arrive |
| 243 // from renderers. | 257 // from renderers. |
| 244 static bool is_prefetch_enabled(); | 258 static bool is_prefetch_enabled(); |
| 245 static void set_is_prefetch_enabled(bool value); | 259 static void set_is_prefetch_enabled(bool value); |
| 246 | 260 |
| 261 void set_observer(Observer* observer) { observer_ = observer; } |
| 262 |
| 247 private: | 263 private: |
| 248 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 264 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 249 TestBlockedRequestsProcessDies); | 265 TestBlockedRequestsProcessDies); |
| 250 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 266 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 251 IncrementOutstandingRequestsMemoryCost); | 267 IncrementOutstandingRequestsMemoryCost); |
| 252 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, | 268 FRIEND_TEST_ALL_PREFIXES(ResourceDispatcherHostTest, |
| 253 CalculateApproximateMemoryCost); | 269 CalculateApproximateMemoryCost); |
| 254 | 270 |
| 255 class ShutdownTask; | 271 class ShutdownTask; |
| 256 | 272 |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 // individual requests is given by CalculateApproximateMemoryCost). | 485 // individual requests is given by CalculateApproximateMemoryCost). |
| 470 // The total number of outstanding requests is roughly: | 486 // The total number of outstanding requests is roughly: |
| 471 // (max_outstanding_requests_cost_per_process_ / | 487 // (max_outstanding_requests_cost_per_process_ / |
| 472 // kAvgBytesPerOutstandingRequest) | 488 // kAvgBytesPerOutstandingRequest) |
| 473 int max_outstanding_requests_cost_per_process_; | 489 int max_outstanding_requests_cost_per_process_; |
| 474 | 490 |
| 475 // Used during IPC message dispatching so that the handlers can get a pointer | 491 // Used during IPC message dispatching so that the handlers can get a pointer |
| 476 // to the source of the message. | 492 // to the source of the message. |
| 477 ResourceMessageFilter* filter_; | 493 ResourceMessageFilter* filter_; |
| 478 | 494 |
| 495 Observer* observer_; |
| 496 |
| 479 static bool is_prefetch_enabled_; | 497 static bool is_prefetch_enabled_; |
| 480 | 498 |
| 481 | |
| 482 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); | 499 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); |
| 483 }; | 500 }; |
| 484 | 501 |
| 485 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ | 502 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ |
| OLD | NEW |