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 <map> | 15 #include <map> |
16 #include <set> | 16 #include <set> |
17 #include <string> | 17 #include <string> |
18 #include <vector> | 18 #include <vector> |
19 | 19 |
20 #include "base/basictypes.h" | 20 #include "base/basictypes.h" |
21 #include "base/gtest_prod_util.h" | 21 #include "base/gtest_prod_util.h" |
22 #include "base/memory/linked_ptr.h" | 22 #include "base/memory/linked_ptr.h" |
23 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
24 #include "base/observer_list.h" | 24 #include "base/observer_list.h" |
25 #include "base/time.h" | 25 #include "base/time.h" |
26 #include "base/timer.h" | 26 #include "base/timer.h" |
27 #include "content/browser/download/download_resource_handler.h" | 27 #include "content/browser/download/download_resource_handler.h" |
| 28 #include "content/browser/loader/global_routing_id.h" |
| 29 #include "content/browser/loader/offline_policy.h" |
28 #include "content/browser/loader/render_view_host_tracker.h" | 30 #include "content/browser/loader/render_view_host_tracker.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" |
32 #include "content/common/content_export.h" | 34 #include "content/common/content_export.h" |
33 #include "content/public/browser/child_process_data.h" | 35 #include "content/public/browser/child_process_data.h" |
34 #include "content/public/browser/download_id.h" | 36 #include "content/public/browser/download_id.h" |
| 37 #include "content/public/browser/global_request_id.h" |
35 #include "content/public/browser/notification_types.h" | 38 #include "content/public/browser/notification_types.h" |
36 #include "content/public/browser/resource_dispatcher_host.h" | 39 #include "content/public/browser/resource_dispatcher_host.h" |
37 #include "ipc/ipc_message.h" | 40 #include "ipc/ipc_message.h" |
38 #include "net/cookies/canonical_cookie.h" | 41 #include "net/cookies/canonical_cookie.h" |
39 #include "net/url_request/url_request.h" | 42 #include "net/url_request/url_request.h" |
40 #include "webkit/glue/resource_type.h" | 43 #include "webkit/glue/resource_type.h" |
41 | 44 |
42 class ResourceHandler; | 45 class ResourceHandler; |
43 struct ResourceHostMsg_Request; | 46 struct ResourceHostMsg_Request; |
44 struct ViewMsg_SwapOut_Params; | 47 struct ViewMsg_SwapOut_Params; |
45 | 48 |
46 namespace net { | 49 namespace net { |
47 class URLRequestJobFactory; | 50 class URLRequestJobFactory; |
48 } | 51 } |
49 | 52 |
50 namespace webkit_blob { | 53 namespace webkit_blob { |
51 class ShareableFileReference; | 54 class ShareableFileReference; |
52 } | 55 } |
53 | 56 |
54 namespace content { | 57 namespace content { |
55 class ResourceContext; | 58 class ResourceContext; |
56 class ResourceDispatcherHostDelegate; | 59 class ResourceDispatcherHostDelegate; |
57 class ResourceMessageDelegate; | 60 class ResourceMessageDelegate; |
58 class ResourceMessageFilter; | 61 class ResourceMessageFilter; |
59 class ResourceRequestInfoImpl; | 62 class ResourceRequestInfoImpl; |
60 class SaveFileManager; | 63 class SaveFileManager; |
61 class WebContentsImpl; | 64 class WebContentsImpl; |
62 struct DownloadSaveInfo; | 65 struct DownloadSaveInfo; |
63 struct GlobalRequestID; | |
64 struct Referrer; | 66 struct Referrer; |
65 | 67 |
66 class CONTENT_EXPORT ResourceDispatcherHostImpl | 68 class CONTENT_EXPORT ResourceDispatcherHostImpl |
67 : public ResourceDispatcherHost, | 69 : public ResourceDispatcherHost, |
68 public ResourceLoaderDelegate { | 70 public ResourceLoaderDelegate { |
69 public: | 71 public: |
70 ResourceDispatcherHostImpl(); | 72 ResourceDispatcherHostImpl(); |
71 virtual ~ResourceDispatcherHostImpl(); | 73 virtual ~ResourceDispatcherHostImpl(); |
72 | 74 |
73 // Returns the current ResourceDispatcherHostImpl. May return NULL if it | 75 // Returns the current ResourceDispatcherHostImpl. May return NULL if it |
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 // used as a special value all over the resource_dispatcher_host for | 404 // used as a special value all over the resource_dispatcher_host for |
403 // uninitialized variables.) This way, we no longer have the unlikely (but | 405 // uninitialized variables.) This way, we no longer have the unlikely (but |
404 // observed in the real world!) event where we have two requests with the same | 406 // observed in the real world!) event where we have two requests with the same |
405 // request_id_. | 407 // request_id_. |
406 int request_id_; | 408 int request_id_; |
407 | 409 |
408 // True if the resource dispatcher host has been shut down. | 410 // True if the resource dispatcher host has been shut down. |
409 bool is_shutdown_; | 411 bool is_shutdown_; |
410 | 412 |
411 typedef std::vector<linked_ptr<ResourceLoader> > BlockedLoadersList; | 413 typedef std::vector<linked_ptr<ResourceLoader> > BlockedLoadersList; |
412 typedef std::pair<int, int> ProcessRouteIDs; | 414 typedef std::map<GlobalRoutingID, BlockedLoadersList*> BlockedLoadersMap; |
413 typedef std::map<ProcessRouteIDs, BlockedLoadersList*> BlockedLoadersMap; | |
414 BlockedLoadersMap blocked_loaders_map_; | 415 BlockedLoadersMap blocked_loaders_map_; |
415 | 416 |
416 // Maps the child_ids to the approximate number of bytes | 417 // Maps the child_ids to the approximate number of bytes |
417 // being used to service its resource requests. No entry implies 0 cost. | 418 // being used to service its resource requests. No entry implies 0 cost. |
418 typedef std::map<int, int> OutstandingRequestsMemoryCostMap; | 419 typedef std::map<int, int> OutstandingRequestsMemoryCostMap; |
419 OutstandingRequestsMemoryCostMap outstanding_requests_memory_cost_map_; | 420 OutstandingRequestsMemoryCostMap outstanding_requests_memory_cost_map_; |
420 | 421 |
421 // |max_outstanding_requests_cost_per_process_| is the upper bound on how | 422 // |max_outstanding_requests_cost_per_process_| is the upper bound on how |
422 // many outstanding requests can be issued per child process host. | 423 // many outstanding requests can be issued per child process host. |
423 // The constraint is expressed in terms of bytes (where the cost of | 424 // The constraint is expressed in terms of bytes (where the cost of |
(...skipping 21 matching lines...) Expand all Loading... |
445 std::set<const ResourceContext*> active_resource_contexts_; | 446 std::set<const ResourceContext*> active_resource_contexts_; |
446 | 447 |
447 typedef std::map<GlobalRequestID, | 448 typedef std::map<GlobalRequestID, |
448 ObserverList<ResourceMessageDelegate>*> DelegateMap; | 449 ObserverList<ResourceMessageDelegate>*> DelegateMap; |
449 DelegateMap delegate_map_; | 450 DelegateMap delegate_map_; |
450 | 451 |
451 scoped_ptr<ResourceScheduler> scheduler_; | 452 scoped_ptr<ResourceScheduler> scheduler_; |
452 | 453 |
453 RenderViewHostTracker tracker_; // Lives on UI thread. | 454 RenderViewHostTracker tracker_; // Lives on UI thread. |
454 | 455 |
| 456 typedef std::map<GlobalRoutingID, OfflinePolicy*> OfflineMap; |
| 457 |
| 458 OfflineMap offline_policy_map_; |
| 459 |
455 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); | 460 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcherHostImpl); |
456 }; | 461 }; |
457 | 462 |
458 } // namespace content | 463 } // namespace content |
459 | 464 |
460 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ | 465 #endif // CONTENT_BROWSER_LOADER_RESOURCE_DISPATCHER_HOST_IMPL_H_ |
OLD | NEW |