| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 class CookieList; | 52 class CookieList; |
| 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 CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { | 60 class CONTENT_EXPORT ResourceDispatcherHost : public net::URLRequest::Delegate { |
| 61 public: | 61 public: |
| 62 explicit ResourceDispatcherHost( | 62 ResourceDispatcherHost(); |
| 63 const ResourceQueue::DelegateSet& resource_queue_delegates); | |
| 64 virtual ~ResourceDispatcherHost(); | 63 virtual ~ResourceDispatcherHost(); |
| 65 | 64 |
| 66 void Initialize(); | 65 // Returns the current ResourceDispatcherHost. May return NULL if it hasn't |
| 66 // been created yet. |
| 67 static ResourceDispatcherHost* Get(); |
| 67 | 68 |
| 68 // Puts the resource dispatcher host in an inactive state (unable to begin | 69 // Puts the resource dispatcher host in an inactive state (unable to begin |
| 69 // new requests). Cancels all pending requests. | 70 // new requests). Cancels all pending requests. |
| 70 void Shutdown(); | 71 void Shutdown(); |
| 71 | 72 |
| 73 // Adds a delegate that can delay requests. This should be called early, i.e. |
| 74 // in the ContentBrowserClient::ResourceDispatcherHostCreated callback. |
| 75 void AddResourceQueueDelegate(ResourceQueueDelegate* delegate); |
| 76 |
| 72 // Returns true if the message was a resource message that was processed. | 77 // Returns true if the message was a resource message that was processed. |
| 73 // If it was, message_was_ok will be false iff the message was corrupt. | 78 // If it was, message_was_ok will be false iff the message was corrupt. |
| 74 bool OnMessageReceived(const IPC::Message& message, | 79 bool OnMessageReceived(const IPC::Message& message, |
| 75 ResourceMessageFilter* filter, | 80 ResourceMessageFilter* filter, |
| 76 bool* message_was_ok); | 81 bool* message_was_ok); |
| 77 | 82 |
| 78 // Initiates a download by explicit request of the renderer, e.g. due to | 83 // Initiates a download by explicit request of the renderer, e.g. due to |
| 79 // alt-clicking a link. If |request| is malformed or not permitted or the RDH | 84 // alt-clicking a link. If |request| is malformed or not permitted or the RDH |
| 80 // is shutting down, then |started_cb| will be called immediately. There is no | 85 // is shutting down, then |started_cb| will be called immediately. There is no |
| 81 // situation in which |started_cb| will never be called. | 86 // situation in which |started_cb| will never be called. |
| (...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 RegisteredTempFiles; // key is child process id | 460 RegisteredTempFiles; // key is child process id |
| 456 RegisteredTempFiles registered_temp_files_; | 461 RegisteredTempFiles registered_temp_files_; |
| 457 | 462 |
| 458 // A timer that periodically calls UpdateLoadStates while pending_requests_ | 463 // A timer that periodically calls UpdateLoadStates while pending_requests_ |
| 459 // is not empty. | 464 // is not empty. |
| 460 base::RepeatingTimer<ResourceDispatcherHost> update_load_states_timer_; | 465 base::RepeatingTimer<ResourceDispatcherHost> update_load_states_timer_; |
| 461 | 466 |
| 462 // Handles the resource requests from the moment we want to start them. | 467 // Handles the resource requests from the moment we want to start them. |
| 463 ResourceQueue resource_queue_; | 468 ResourceQueue resource_queue_; |
| 464 | 469 |
| 470 // Used temporarily during construction. |
| 471 ResourceQueue::DelegateSet* temporarily_delegate_set_; |
| 472 |
| 465 // We own the download file writing thread and manager | 473 // We own the download file writing thread and manager |
| 466 scoped_refptr<DownloadFileManager> download_file_manager_; | 474 scoped_refptr<DownloadFileManager> download_file_manager_; |
| 467 | 475 |
| 468 // We own the save file manager. | 476 // We own the save file manager. |
| 469 scoped_refptr<SaveFileManager> save_file_manager_; | 477 scoped_refptr<SaveFileManager> save_file_manager_; |
| 470 | 478 |
| 471 // Request ID for browser initiated requests. request_ids generated by | 479 // Request ID for browser initiated requests. request_ids generated by |
| 472 // child processes are counted up from 0, while browser created requests | 480 // child processes are counted up from 0, while browser created requests |
| 473 // start at -2 and go down from there. (We need to start at -2 because -1 is | 481 // start at -2 and go down from there. (We need to start at -2 because -1 is |
| 474 // used as a special value all over the resource_dispatcher_host for | 482 // used as a special value all over the resource_dispatcher_host for |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 // Maps the request ID of request that is being transferred to a new RVH | 527 // Maps the request ID of request that is being transferred to a new RVH |
| 520 // to the respective request. | 528 // to the respective request. |
| 521 typedef std::map<content::GlobalRequestID, net::URLRequest*> | 529 typedef std::map<content::GlobalRequestID, net::URLRequest*> |
| 522 TransferredNavigations; | 530 TransferredNavigations; |
| 523 TransferredNavigations transferred_navigations_; | 531 TransferredNavigations transferred_navigations_; |
| 524 | 532 |
| 525 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); | 533 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); |
| 526 }; | 534 }; |
| 527 | 535 |
| 528 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ | 536 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ |
| OLD | NEW |