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, creating it if necessary. The |
| 66 // first time this is called must be on the UI thread, but after that it can |
| 67 // be called from the IO thread as well. |
| 68 static ResourceDispatcherHost* Get(); |
| 69 |
| 70 // Returns true if the ResourceDispatcherHost has been created (i.e. Get() has |
| 71 // been called). |
| 72 static bool IsCreated(); |
67 | 73 |
68 // Puts the resource dispatcher host in an inactive state (unable to begin | 74 // Puts the resource dispatcher host in an inactive state (unable to begin |
69 // new requests). Cancels all pending requests. | 75 // new requests). Cancels all pending requests. |
70 void Shutdown(); | 76 void Shutdown(); |
71 | 77 |
| 78 // Destructs the current ResourceDispatcherHost. |
| 79 void Destruct(); |
| 80 |
| 81 // Adds a delegate that can delay requests. This should be called early, i.e. |
| 82 // in the ContentBrowserClient::ResourceDispatcherHostCreated callback. |
| 83 void AddResourceQueueDelegate(ResourceQueueDelegate* delegate); |
| 84 |
72 // Returns true if the message was a resource message that was processed. | 85 // 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. | 86 // If it was, message_was_ok will be false iff the message was corrupt. |
74 bool OnMessageReceived(const IPC::Message& message, | 87 bool OnMessageReceived(const IPC::Message& message, |
75 ResourceMessageFilter* filter, | 88 ResourceMessageFilter* filter, |
76 bool* message_was_ok); | 89 bool* message_was_ok); |
77 | 90 |
78 // Initiates a download by explicit request of the renderer, e.g. due to | 91 // 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 | 92 // 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 | 93 // is shutting down, then |started_cb| will be called immediately. There is no |
81 // situation in which |started_cb| will never be called. | 94 // 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 | 468 RegisteredTempFiles; // key is child process id |
456 RegisteredTempFiles registered_temp_files_; | 469 RegisteredTempFiles registered_temp_files_; |
457 | 470 |
458 // A timer that periodically calls UpdateLoadStates while pending_requests_ | 471 // A timer that periodically calls UpdateLoadStates while pending_requests_ |
459 // is not empty. | 472 // is not empty. |
460 base::RepeatingTimer<ResourceDispatcherHost> update_load_states_timer_; | 473 base::RepeatingTimer<ResourceDispatcherHost> update_load_states_timer_; |
461 | 474 |
462 // Handles the resource requests from the moment we want to start them. | 475 // Handles the resource requests from the moment we want to start them. |
463 ResourceQueue resource_queue_; | 476 ResourceQueue resource_queue_; |
464 | 477 |
| 478 // Used temporarily during construction. |
| 479 ResourceQueue::DelegateSet* temporarily_delegate_set_; |
| 480 |
465 // We own the download file writing thread and manager | 481 // We own the download file writing thread and manager |
466 scoped_refptr<DownloadFileManager> download_file_manager_; | 482 scoped_refptr<DownloadFileManager> download_file_manager_; |
467 | 483 |
468 // We own the save file manager. | 484 // We own the save file manager. |
469 scoped_refptr<SaveFileManager> save_file_manager_; | 485 scoped_refptr<SaveFileManager> save_file_manager_; |
470 | 486 |
471 // Request ID for browser initiated requests. request_ids generated by | 487 // Request ID for browser initiated requests. request_ids generated by |
472 // child processes are counted up from 0, while browser created requests | 488 // 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 | 489 // 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 | 490 // 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 | 535 // Maps the request ID of request that is being transferred to a new RVH |
520 // to the respective request. | 536 // to the respective request. |
521 typedef std::map<content::GlobalRequestID, net::URLRequest*> | 537 typedef std::map<content::GlobalRequestID, net::URLRequest*> |
522 TransferredNavigations; | 538 TransferredNavigations; |
523 TransferredNavigations transferred_navigations_; | 539 TransferredNavigations transferred_navigations_; |
524 | 540 |
525 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); | 541 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHost); |
526 }; | 542 }; |
527 | 543 |
528 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ | 544 #endif // CONTENT_BROWSER_RENDERER_HOST_RESOURCE_DISPATCHER_HOST_H_ |
OLD | NEW |