| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 ResourceDispatcherHostImpl(); | 84 ResourceDispatcherHostImpl(); |
| 85 ~ResourceDispatcherHostImpl() override; | 85 ~ResourceDispatcherHostImpl() override; |
| 86 | 86 |
| 87 // Returns the current ResourceDispatcherHostImpl. May return NULL if it | 87 // Returns the current ResourceDispatcherHostImpl. May return NULL if it |
| 88 // hasn't been created yet. | 88 // hasn't been created yet. |
| 89 static ResourceDispatcherHostImpl* Get(); | 89 static ResourceDispatcherHostImpl* Get(); |
| 90 | 90 |
| 91 // ResourceDispatcherHost implementation: | 91 // ResourceDispatcherHost implementation: |
| 92 void SetDelegate(ResourceDispatcherHostDelegate* delegate) override; | 92 void SetDelegate(ResourceDispatcherHostDelegate* delegate) override; |
| 93 void SetAllowCrossOriginAuthPrompt(bool value) override; | 93 void SetAllowCrossOriginAuthPrompt(bool value) override; |
| 94 DownloadInterruptReason BeginDownload( | |
| 95 scoped_ptr<net::URLRequest> request, | |
| 96 const Referrer& referrer, | |
| 97 bool is_content_initiated, | |
| 98 ResourceContext* context, | |
| 99 int child_id, | |
| 100 int render_view_route_id, | |
| 101 int render_frame_route_id, | |
| 102 bool prefer_cache, | |
| 103 bool do_not_prompt_for_login, | |
| 104 scoped_ptr<DownloadSaveInfo> save_info, | |
| 105 uint32_t download_id, | |
| 106 const DownloadStartedCallback& started_callback) override; | |
| 107 void ClearLoginDelegateForRequest(net::URLRequest* request) override; | 94 void ClearLoginDelegateForRequest(net::URLRequest* request) override; |
| 108 void BlockRequestsForRoute(int child_id, int route_id) override; | 95 void BlockRequestsForRoute(int child_id, int route_id) override; |
| 109 void ResumeBlockedRequestsForRoute(int child_id, int route_id) override; | 96 void ResumeBlockedRequestsForRoute(int child_id, int route_id) override; |
| 110 | 97 |
| 111 // Puts the resource dispatcher host in an inactive state (unable to begin | 98 // Puts the resource dispatcher host in an inactive state (unable to begin |
| 112 // new requests). Cancels all pending requests. | 99 // new requests). Cancels all pending requests. |
| 113 void Shutdown(); | 100 void Shutdown(); |
| 114 | 101 |
| 115 // Notify the ResourceDispatcherHostImpl of a new resource context. | 102 // Notify the ResourceDispatcherHostImpl of a new resource context. |
| 116 void AddResourceContext(ResourceContext* context); | 103 void AddResourceContext(ResourceContext* context); |
| 117 | 104 |
| 118 // Notify the ResourceDispatcherHostImpl of a resource context destruction. | 105 // Notify the ResourceDispatcherHostImpl of a resource context destruction. |
| 119 void RemoveResourceContext(ResourceContext* context); | 106 void RemoveResourceContext(ResourceContext* context); |
| 120 | 107 |
| 121 // Force cancels any pending requests for the given |context|. This is | 108 // Force cancels any pending requests for the given |context|. This is |
| 122 // necessary to ensure that before |context| goes away, all requests | 109 // necessary to ensure that before |context| goes away, all requests |
| 123 // for it are dead. | 110 // for it are dead. |
| 124 void CancelRequestsForContext(ResourceContext* context); | 111 void CancelRequestsForContext(ResourceContext* context); |
| 125 | 112 |
| 126 // Returns true if the message was a resource message that was processed. | 113 // Returns true if the message was a resource message that was processed. |
| 127 bool OnMessageReceived(const IPC::Message& message, | 114 bool OnMessageReceived(const IPC::Message& message, |
| 128 ResourceMessageFilter* filter); | 115 ResourceMessageFilter* filter); |
| 129 | 116 |
| 117 DownloadInterruptReason BeginDownload(scoped_ptr<net::URLRequest> request, |
| 118 const Referrer& referrer, |
| 119 bool is_content_initiated, |
| 120 ResourceContext* context, |
| 121 int child_id, |
| 122 int render_view_route_id, |
| 123 int render_frame_route_id, |
| 124 bool do_not_prompt_for_login); |
| 125 |
| 130 // Initiates a save file from the browser process (as opposed to a resource | 126 // Initiates a save file from the browser process (as opposed to a resource |
| 131 // request from the renderer or another child process). | 127 // request from the renderer or another child process). |
| 132 void BeginSaveFile(const GURL& url, | 128 void BeginSaveFile(const GURL& url, |
| 133 const Referrer& referrer, | 129 const Referrer& referrer, |
| 134 SaveItemId save_item_id, | 130 SaveItemId save_item_id, |
| 135 SavePackageId save_package_id, | 131 SavePackageId save_package_id, |
| 136 int child_id, | 132 int child_id, |
| 137 int render_view_route_id, | 133 int render_view_route_id, |
| 138 int render_frame_route_id, | 134 int render_frame_route_id, |
| 139 ResourceContext* context); | 135 ResourceContext* context); |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 return delegate_; | 217 return delegate_; |
| 222 } | 218 } |
| 223 | 219 |
| 224 // Must be called after the ResourceRequestInfo has been created | 220 // Must be called after the ResourceRequestInfo has been created |
| 225 // and associated with the request. | 221 // and associated with the request. |
| 226 // |id| should be |content::DownloadItem::kInvalidId| to request automatic | 222 // |id| should be |content::DownloadItem::kInvalidId| to request automatic |
| 227 // assignment. This is marked virtual so it can be overriden in testing. | 223 // assignment. This is marked virtual so it can be overriden in testing. |
| 228 virtual scoped_ptr<ResourceHandler> CreateResourceHandlerForDownload( | 224 virtual scoped_ptr<ResourceHandler> CreateResourceHandlerForDownload( |
| 229 net::URLRequest* request, | 225 net::URLRequest* request, |
| 230 bool is_content_initiated, | 226 bool is_content_initiated, |
| 231 bool must_download, | 227 bool must_download); |
| 232 uint32_t id, | |
| 233 scoped_ptr<DownloadSaveInfo> save_info, | |
| 234 const DownloadUrlParameters::OnStartedCallback& started_cb); | |
| 235 | 228 |
| 236 // Called to determine whether the response to |request| should be intercepted | 229 // Called to determine whether the response to |request| should be intercepted |
| 237 // and handled as a stream. Streams are used to pass direct access to a | 230 // and handled as a stream. Streams are used to pass direct access to a |
| 238 // resource response to another application (e.g. a web page) without being | 231 // resource response to another application (e.g. a web page) without being |
| 239 // handled by the browser itself. If the request should be intercepted as a | 232 // handled by the browser itself. If the request should be intercepted as a |
| 240 // stream, a StreamResourceHandler is returned which provides access to the | 233 // stream, a StreamResourceHandler is returned which provides access to the |
| 241 // response. |plugin_path| is the path to the plugin which is handling the | 234 // response. |plugin_path| is the path to the plugin which is handling the |
| 242 // URL request. This may be empty if there is no plugin handling the request. | 235 // URL request. This may be empty if there is no plugin handling the request. |
| 243 // | 236 // |
| 244 // This function must be called after the ResourceRequestInfo has been created | 237 // This function must be called after the ResourceRequestInfo has been created |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 600 DelegateMap delegate_map_; | 593 DelegateMap delegate_map_; |
| 601 | 594 |
| 602 scoped_ptr<ResourceScheduler> scheduler_; | 595 scoped_ptr<ResourceScheduler> scheduler_; |
| 603 | 596 |
| 604 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 597 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
| 605 }; | 598 }; |
| 606 | 599 |
| 607 } // namespace content | 600 } // namespace content |
| 608 | 601 |
| 609 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 602 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
| OLD | NEW |