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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 #include "net/url_request/url_request.h" | 42 #include "net/url_request/url_request.h" |
43 #include "webkit/common/resource_type.h" | 43 #include "webkit/common/resource_type.h" |
44 | 44 |
45 class ResourceHandler; | 45 class ResourceHandler; |
46 struct ResourceHostMsg_Request; | 46 struct ResourceHostMsg_Request; |
47 | 47 |
48 namespace net { | 48 namespace net { |
49 class URLRequestJobFactory; | 49 class URLRequestJobFactory; |
50 } | 50 } |
51 | 51 |
52 namespace webkit_blob { | |
53 class ShareableFileReference; | |
54 } | |
55 | |
56 namespace content { | 52 namespace content { |
57 class ResourceContext; | 53 class ResourceContext; |
58 class ResourceDispatcherHostDelegate; | 54 class ResourceDispatcherHostDelegate; |
59 class ResourceMessageDelegate; | 55 class ResourceMessageDelegate; |
60 class ResourceMessageFilter; | 56 class ResourceMessageFilter; |
61 class ResourceRequestInfoImpl; | 57 class ResourceRequestInfoImpl; |
62 class SaveFileManager; | 58 class SaveFileManager; |
| 59 class TemporaryFileManager; |
63 class WebContentsImpl; | 60 class WebContentsImpl; |
64 struct DownloadSaveInfo; | 61 struct DownloadSaveInfo; |
65 struct Referrer; | 62 struct Referrer; |
66 | 63 |
67 class CONTENT_EXPORT ResourceDispatcherHostImpl | 64 class CONTENT_EXPORT ResourceDispatcherHostImpl |
68 : public ResourceDispatcherHost, | 65 : public ResourceDispatcherHost, |
69 public ResourceLoaderDelegate { | 66 public ResourceLoaderDelegate { |
70 public: | 67 public: |
71 ResourceDispatcherHostImpl(); | 68 ResourceDispatcherHostImpl(); |
72 virtual ~ResourceDispatcherHostImpl(); | 69 virtual ~ResourceDispatcherHostImpl(); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 void OnUserGesture(WebContentsImpl* contents); | 170 void OnUserGesture(WebContentsImpl* contents); |
174 | 171 |
175 // Retrieves a net::URLRequest. Must be called from the IO thread. | 172 // Retrieves a net::URLRequest. Must be called from the IO thread. |
176 net::URLRequest* GetURLRequest(const GlobalRequestID& request_id); | 173 net::URLRequest* GetURLRequest(const GlobalRequestID& request_id); |
177 | 174 |
178 void RemovePendingRequest(int child_id, int request_id); | 175 void RemovePendingRequest(int child_id, int request_id); |
179 | 176 |
180 // Cancels any blocked request for the specified route id. | 177 // Cancels any blocked request for the specified route id. |
181 void CancelBlockedRequestsForRoute(int child_id, int route_id); | 178 void CancelBlockedRequestsForRoute(int child_id, int route_id); |
182 | 179 |
183 // Maintains a collection of temp files created in support of | |
184 // the download_to_file capability. Used to grant access to the | |
185 // child process and to defer deletion of the file until it's | |
186 // no longer needed. | |
187 void RegisterDownloadedTempFile( | |
188 int child_id, int request_id, | |
189 webkit_blob::ShareableFileReference* reference); | |
190 void UnregisterDownloadedTempFile(int child_id, int request_id); | |
191 | |
192 // Needed for the sync IPC message dispatcher macros. | 180 // Needed for the sync IPC message dispatcher macros. |
193 bool Send(IPC::Message* message); | 181 bool Send(IPC::Message* message); |
194 | 182 |
195 // Indicates whether third-party sub-content can pop-up HTTP basic auth | 183 // Indicates whether third-party sub-content can pop-up HTTP basic auth |
196 // dialog boxes. | 184 // dialog boxes. |
197 bool allow_cross_origin_auth_prompt(); | 185 bool allow_cross_origin_auth_prompt(); |
198 | 186 |
199 ResourceDispatcherHostDelegate* delegate() { | 187 ResourceDispatcherHostDelegate* delegate() { |
200 return delegate_; | 188 return delegate_; |
201 } | 189 } |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
413 ResourceMessageDelegate* delegate); | 401 ResourceMessageDelegate* delegate); |
414 void UnregisterResourceMessageDelegate(const GlobalRequestID& id, | 402 void UnregisterResourceMessageDelegate(const GlobalRequestID& id, |
415 ResourceMessageDelegate* delegate); | 403 ResourceMessageDelegate* delegate); |
416 | 404 |
417 int BuildLoadFlagsForRequest(const ResourceHostMsg_Request& request_data, | 405 int BuildLoadFlagsForRequest(const ResourceHostMsg_Request& request_data, |
418 int child_id, | 406 int child_id, |
419 bool is_sync_load); | 407 bool is_sync_load); |
420 | 408 |
421 LoaderMap pending_loaders_; | 409 LoaderMap pending_loaders_; |
422 | 410 |
423 // Collection of temp files downloaded for child processes via | |
424 // the download_to_file mechanism. We avoid deleting them until | |
425 // the client no longer needs them. | |
426 typedef std::map<int, scoped_refptr<webkit_blob::ShareableFileReference> > | |
427 DeletableFilesMap; // key is request id | |
428 typedef std::map<int, DeletableFilesMap> | |
429 RegisteredTempFiles; // key is child process id | |
430 RegisteredTempFiles registered_temp_files_; | |
431 | |
432 // A timer that periodically calls UpdateLoadStates while pending_requests_ | 411 // A timer that periodically calls UpdateLoadStates while pending_requests_ |
433 // is not empty. | 412 // is not empty. |
434 scoped_ptr<base::RepeatingTimer<ResourceDispatcherHostImpl> > | 413 scoped_ptr<base::RepeatingTimer<ResourceDispatcherHostImpl> > |
435 update_load_states_timer_; | 414 update_load_states_timer_; |
436 | 415 |
437 // We own the save file manager. | 416 // We own the save file manager. |
438 scoped_refptr<SaveFileManager> save_file_manager_; | 417 scoped_refptr<SaveFileManager> save_file_manager_; |
439 | 418 |
440 // Request ID for browser initiated requests. request_ids generated by | 419 // Request ID for browser initiated requests. request_ids generated by |
441 // child processes are counted up from 0, while browser created requests | 420 // child processes are counted up from 0, while browser created requests |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 // http://crbug.com/90971 - Assists in tracking down use-after-frees on | 478 // http://crbug.com/90971 - Assists in tracking down use-after-frees on |
500 // shutdown. | 479 // shutdown. |
501 std::set<const ResourceContext*> active_resource_contexts_; | 480 std::set<const ResourceContext*> active_resource_contexts_; |
502 | 481 |
503 typedef std::map<GlobalRequestID, | 482 typedef std::map<GlobalRequestID, |
504 ObserverList<ResourceMessageDelegate>*> DelegateMap; | 483 ObserverList<ResourceMessageDelegate>*> DelegateMap; |
505 DelegateMap delegate_map_; | 484 DelegateMap delegate_map_; |
506 | 485 |
507 scoped_ptr<ResourceScheduler> scheduler_; | 486 scoped_ptr<ResourceScheduler> scheduler_; |
508 | 487 |
| 488 scoped_ptr<TemporaryFileManager> temporary_file_manager_; |
| 489 |
509 typedef std::map<GlobalRoutingID, OfflinePolicy*> OfflineMap; | 490 typedef std::map<GlobalRoutingID, OfflinePolicy*> OfflineMap; |
510 | 491 |
511 OfflineMap offline_policy_map_; | 492 OfflineMap offline_policy_map_; |
512 | 493 |
513 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 494 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
514 }; | 495 }; |
515 | 496 |
516 } // namespace content | 497 } // namespace content |
517 | 498 |
518 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 499 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
OLD | NEW |