| 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 |
| 11 | 11 |
| 12 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 12 #ifndef CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
| 13 #define CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 13 #define CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
| 14 | 14 |
| 15 #include <stdint.h> |
| 16 |
| 15 #include <map> | 17 #include <map> |
| 16 #include <set> | 18 #include <set> |
| 17 #include <string> | 19 #include <string> |
| 18 #include <vector> | 20 #include <vector> |
| 19 | 21 |
| 20 #include "base/basictypes.h" | |
| 21 #include "base/gtest_prod_util.h" | 22 #include "base/gtest_prod_util.h" |
| 23 #include "base/macros.h" |
| 22 #include "base/memory/linked_ptr.h" | 24 #include "base/memory/linked_ptr.h" |
| 23 #include "base/memory/scoped_ptr.h" | 25 #include "base/memory/scoped_ptr.h" |
| 24 #include "base/observer_list.h" | 26 #include "base/observer_list.h" |
| 25 #include "base/time/time.h" | 27 #include "base/time/time.h" |
| 26 #include "base/timer/timer.h" | 28 #include "base/timer/timer.h" |
| 27 #include "content/browser/download/download_resource_handler.h" | 29 #include "content/browser/download/download_resource_handler.h" |
| 28 #include "content/browser/loader/global_routing_id.h" | 30 #include "content/browser/loader/global_routing_id.h" |
| 29 #include "content/browser/loader/resource_loader.h" | 31 #include "content/browser/loader/resource_loader.h" |
| 30 #include "content/browser/loader/resource_loader_delegate.h" | 32 #include "content/browser/loader/resource_loader_delegate.h" |
| 31 #include "content/browser/loader/resource_scheduler.h" | 33 #include "content/browser/loader/resource_scheduler.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 scoped_ptr<net::URLRequest> request, | 95 scoped_ptr<net::URLRequest> request, |
| 94 const Referrer& referrer, | 96 const Referrer& referrer, |
| 95 bool is_content_initiated, | 97 bool is_content_initiated, |
| 96 ResourceContext* context, | 98 ResourceContext* context, |
| 97 int child_id, | 99 int child_id, |
| 98 int render_view_route_id, | 100 int render_view_route_id, |
| 99 int render_frame_route_id, | 101 int render_frame_route_id, |
| 100 bool prefer_cache, | 102 bool prefer_cache, |
| 101 bool do_not_prompt_for_login, | 103 bool do_not_prompt_for_login, |
| 102 scoped_ptr<DownloadSaveInfo> save_info, | 104 scoped_ptr<DownloadSaveInfo> save_info, |
| 103 uint32 download_id, | 105 uint32_t download_id, |
| 104 const DownloadStartedCallback& started_callback) override; | 106 const DownloadStartedCallback& started_callback) override; |
| 105 void ClearLoginDelegateForRequest(net::URLRequest* request) override; | 107 void ClearLoginDelegateForRequest(net::URLRequest* request) override; |
| 106 void BlockRequestsForRoute(int child_id, int route_id) override; | 108 void BlockRequestsForRoute(int child_id, int route_id) override; |
| 107 void ResumeBlockedRequestsForRoute(int child_id, int route_id) override; | 109 void ResumeBlockedRequestsForRoute(int child_id, int route_id) override; |
| 108 | 110 |
| 109 // Puts the resource dispatcher host in an inactive state (unable to begin | 111 // Puts the resource dispatcher host in an inactive state (unable to begin |
| 110 // new requests). Cancels all pending requests. | 112 // new requests). Cancels all pending requests. |
| 111 void Shutdown(); | 113 void Shutdown(); |
| 112 | 114 |
| 113 // Notify the ResourceDispatcherHostImpl of a new resource context. | 115 // Notify the ResourceDispatcherHostImpl of a new resource context. |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 } | 235 } |
| 234 | 236 |
| 235 // Must be called after the ResourceRequestInfo has been created | 237 // Must be called after the ResourceRequestInfo has been created |
| 236 // and associated with the request. | 238 // and associated with the request. |
| 237 // |id| should be |content::DownloadItem::kInvalidId| to request automatic | 239 // |id| should be |content::DownloadItem::kInvalidId| to request automatic |
| 238 // assignment. This is marked virtual so it can be overriden in testing. | 240 // assignment. This is marked virtual so it can be overriden in testing. |
| 239 virtual scoped_ptr<ResourceHandler> CreateResourceHandlerForDownload( | 241 virtual scoped_ptr<ResourceHandler> CreateResourceHandlerForDownload( |
| 240 net::URLRequest* request, | 242 net::URLRequest* request, |
| 241 bool is_content_initiated, | 243 bool is_content_initiated, |
| 242 bool must_download, | 244 bool must_download, |
| 243 uint32 id, | 245 uint32_t id, |
| 244 scoped_ptr<DownloadSaveInfo> save_info, | 246 scoped_ptr<DownloadSaveInfo> save_info, |
| 245 const DownloadUrlParameters::OnStartedCallback& started_cb); | 247 const DownloadUrlParameters::OnStartedCallback& started_cb); |
| 246 | 248 |
| 247 // Called to determine whether the response to |request| should be intercepted | 249 // Called to determine whether the response to |request| should be intercepted |
| 248 // and handled as a stream. Streams are used to pass direct access to a | 250 // and handled as a stream. Streams are used to pass direct access to a |
| 249 // resource response to another application (e.g. a web page) without being | 251 // resource response to another application (e.g. a web page) without being |
| 250 // handled by the browser itself. If the request should be intercepted as a | 252 // handled by the browser itself. If the request should be intercepted as a |
| 251 // stream, a StreamResourceHandler is returned which provides access to the | 253 // stream, a StreamResourceHandler is returned which provides access to the |
| 252 // response. |plugin_path| is the path to the plugin which is handling the | 254 // response. |plugin_path| is the path to the plugin which is handling the |
| 253 // URL request. This may be empty if there is no plugin handling the request. | 255 // URL request. This may be empty if there is no plugin handling the request. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 304 int num_requests; | 306 int num_requests; |
| 305 }; | 307 }; |
| 306 | 308 |
| 307 friend class ShutdownTask; | 309 friend class ShutdownTask; |
| 308 friend class ResourceMessageDelegate; | 310 friend class ResourceMessageDelegate; |
| 309 | 311 |
| 310 // Information about status of a ResourceLoader. | 312 // Information about status of a ResourceLoader. |
| 311 struct LoadInfo { | 313 struct LoadInfo { |
| 312 GURL url; | 314 GURL url; |
| 313 net::LoadStateWithParam load_state; | 315 net::LoadStateWithParam load_state; |
| 314 uint64 upload_position; | 316 uint64_t upload_position; |
| 315 uint64 upload_size; | 317 uint64_t upload_size; |
| 316 }; | 318 }; |
| 317 | 319 |
| 318 // Map from ProcessID+RouteID pair to the "most interesting" LoadState. | 320 // Map from ProcessID+RouteID pair to the "most interesting" LoadState. |
| 319 typedef std::map<GlobalRoutingID, LoadInfo> LoadInfoMap; | 321 typedef std::map<GlobalRoutingID, LoadInfo> LoadInfoMap; |
| 320 | 322 |
| 321 // ResourceLoaderDelegate implementation: | 323 // ResourceLoaderDelegate implementation: |
| 322 ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( | 324 ResourceDispatcherHostLoginDelegate* CreateLoginDelegate( |
| 323 ResourceLoader* loader, | 325 ResourceLoader* loader, |
| 324 net::AuthChallengeInfo* auth_info) override; | 326 net::AuthChallengeInfo* auth_info) override; |
| 325 bool HandleExternalProtocol(ResourceLoader* loader, const GURL& url) override; | 327 bool HandleExternalProtocol(ResourceLoader* loader, const GURL& url) override; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 608 DelegateMap delegate_map_; | 610 DelegateMap delegate_map_; |
| 609 | 611 |
| 610 scoped_ptr<ResourceScheduler> scheduler_; | 612 scoped_ptr<ResourceScheduler> scheduler_; |
| 611 | 613 |
| 612 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 614 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
| 613 }; | 615 }; |
| 614 | 616 |
| 615 } // namespace content | 617 } // namespace content |
| 616 | 618 |
| 617 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 619 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
| OLD | NEW |