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 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading | 5 // See http://dev.chromium.org/developers/design-documents/multi-process-resourc
e-loading |
6 | 6 |
7 #ifndef CONTENT_CHILD_RESOURCE_DISPATCHER_H_ | 7 #ifndef CONTENT_CHILD_RESOURCE_DISPATCHER_H_ |
8 #define CONTENT_CHILD_RESOURCE_DISPATCHER_H_ | 8 #define CONTENT_CHILD_RESOURCE_DISPATCHER_H_ |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
11 #include <string> | 11 #include <string> |
12 | 12 |
13 #include "base/containers/hash_tables.h" | 13 #include "base/containers/hash_tables.h" |
14 #include "base/memory/linked_ptr.h" | 14 #include "base/memory/linked_ptr.h" |
15 #include "base/memory/shared_memory.h" | 15 #include "base/memory/shared_memory.h" |
16 #include "base/memory/weak_ptr.h" | 16 #include "base/memory/weak_ptr.h" |
17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
18 #include "content/common/content_export.h" | 18 #include "content/common/content_export.h" |
| 19 #include "content/public/child/resource_loader_bridge.h" |
19 #include "ipc/ipc_listener.h" | 20 #include "ipc/ipc_listener.h" |
20 #include "ipc/ipc_sender.h" | 21 #include "ipc/ipc_sender.h" |
21 #include "webkit/child/resource_loader_bridge.h" | |
22 | 22 |
23 struct ResourceMsg_RequestCompleteData; | 23 struct ResourceMsg_RequestCompleteData; |
24 | 24 |
25 namespace content { | 25 namespace content { |
26 class ResourceDispatcherDelegate; | 26 class ResourceDispatcherDelegate; |
27 struct ResourceResponseHead; | 27 struct ResourceResponseHead; |
28 | 28 |
29 // This class serves as a communication interface between the | 29 // This class serves as a communication interface between the |
30 // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in | 30 // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in |
31 // the child process. It can be used from any child process. | 31 // the child process. It can be used from any child process. |
32 class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { | 32 class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { |
33 public: | 33 public: |
34 explicit ResourceDispatcher(IPC::Sender* sender); | 34 explicit ResourceDispatcher(IPC::Sender* sender); |
35 virtual ~ResourceDispatcher(); | 35 virtual ~ResourceDispatcher(); |
36 | 36 |
37 // IPC::Listener implementation. | 37 // IPC::Listener implementation. |
38 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 38 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
39 | 39 |
40 // Creates a ResourceLoaderBridge for this type of dispatcher, this is so | 40 // Creates a ResourceLoaderBridge for this type of dispatcher, this is so |
41 // this can be tested regardless of the ResourceLoaderBridge::Create | 41 // this can be tested regardless of the ResourceLoaderBridge::Create |
42 // implementation. | 42 // implementation. |
43 webkit_glue::ResourceLoaderBridge* CreateBridge( | 43 ResourceLoaderBridge* CreateBridge( |
44 const webkit_glue::ResourceLoaderBridge::RequestInfo& request_info); | 44 const ResourceLoaderBridge::RequestInfo& request_info); |
45 | 45 |
46 // Adds a request from the pending_requests_ list, returning the new | 46 // Adds a request from the pending_requests_ list, returning the new |
47 // requests' ID | 47 // requests' ID |
48 int AddPendingRequest(webkit_glue::ResourceLoaderBridge::Peer* callback, | 48 int AddPendingRequest(ResourceLoaderBridge::Peer* callback, |
49 ResourceType::Type resource_type, | 49 ResourceType::Type resource_type, |
50 int origin_pid, | 50 int origin_pid, |
51 const GURL& frame_origin, | 51 const GURL& frame_origin, |
52 const GURL& request_url); | 52 const GURL& request_url); |
53 | 53 |
54 // Removes a request from the pending_requests_ list, returning true if the | 54 // Removes a request from the pending_requests_ list, returning true if the |
55 // request was found and removed. | 55 // request was found and removed. |
56 bool RemovePendingRequest(int request_id); | 56 bool RemovePendingRequest(int request_id); |
57 | 57 |
58 // Cancels a request in the pending_requests_ list. | 58 // Cancels a request in the pending_requests_ list. |
(...skipping 21 matching lines...) Expand all Loading... |
80 io_timestamp_ = io_timestamp; | 80 io_timestamp_ = io_timestamp; |
81 } | 81 } |
82 | 82 |
83 private: | 83 private: |
84 friend class ResourceDispatcherTest; | 84 friend class ResourceDispatcherTest; |
85 | 85 |
86 typedef std::deque<IPC::Message*> MessageQueue; | 86 typedef std::deque<IPC::Message*> MessageQueue; |
87 struct PendingRequestInfo { | 87 struct PendingRequestInfo { |
88 PendingRequestInfo(); | 88 PendingRequestInfo(); |
89 | 89 |
90 PendingRequestInfo(webkit_glue::ResourceLoaderBridge::Peer* peer, | 90 PendingRequestInfo(ResourceLoaderBridge::Peer* peer, |
91 ResourceType::Type resource_type, | 91 ResourceType::Type resource_type, |
92 int origin_pid, | 92 int origin_pid, |
93 const GURL& frame_origin, | 93 const GURL& frame_origin, |
94 const GURL& request_url); | 94 const GURL& request_url); |
95 | 95 |
96 ~PendingRequestInfo(); | 96 ~PendingRequestInfo(); |
97 | 97 |
98 webkit_glue::ResourceLoaderBridge::Peer* peer; | 98 ResourceLoaderBridge::Peer* peer; |
99 ResourceType::Type resource_type; | 99 ResourceType::Type resource_type; |
100 // The PID of the original process which issued this request. This gets | 100 // The PID of the original process which issued this request. This gets |
101 // non-zero only for a request proxied by another renderer, particularly | 101 // non-zero only for a request proxied by another renderer, particularly |
102 // requests from plugins. | 102 // requests from plugins. |
103 int origin_pid; | 103 int origin_pid; |
104 MessageQueue deferred_message_queue; | 104 MessageQueue deferred_message_queue; |
105 bool is_deferred; | 105 bool is_deferred; |
106 // Original requested url. | 106 // Original requested url. |
107 GURL url; | 107 GURL url; |
108 // The security origin of the frame that initiates this request. | 108 // The security origin of the frame that initiates this request. |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 | 200 |
201 // IO thread timestamp for ongoing IPC message. | 201 // IO thread timestamp for ongoing IPC message. |
202 base::TimeTicks io_timestamp_; | 202 base::TimeTicks io_timestamp_; |
203 | 203 |
204 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); | 204 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); |
205 }; | 205 }; |
206 | 206 |
207 } // namespace content | 207 } // namespace content |
208 | 208 |
209 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ | 209 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ |
OLD | NEW |