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 "ipc/ipc_listener.h" | 19 #include "ipc/ipc_listener.h" |
20 #include "ipc/ipc_sender.h" | 20 #include "ipc/ipc_sender.h" |
21 #include "webkit/child/resource_loader_bridge.h" | 21 #include "net/base/request_priority.h" |
22 #include "webkit/common/resource_type.h" | 22 #include "webkit/common/resource_type.h" |
23 | 23 |
24 struct ResourceMsg_RequestCompleteData; | 24 struct ResourceMsg_RequestCompleteData; |
25 | 25 |
| 26 namespace webkit_glue { |
| 27 class ResourceLoaderBridge; |
| 28 struct ResourceResponseInfo; |
| 29 } |
| 30 |
26 namespace content { | 31 namespace content { |
| 32 class RequestPeer; |
27 class ResourceDispatcherDelegate; | 33 class ResourceDispatcherDelegate; |
28 struct RequestInfo; | 34 struct RequestInfo; |
29 struct ResourceResponseHead; | 35 struct ResourceResponseHead; |
30 struct SiteIsolationResponseMetaData; | 36 struct SiteIsolationResponseMetaData; |
31 | 37 |
32 // This class serves as a communication interface between the | 38 // This class serves as a communication interface between the |
33 // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in | 39 // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in |
34 // the child process. It can be used from any child process. | 40 // the child process. It can be used from any child process. |
35 class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { | 41 class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { |
36 public: | 42 public: |
37 explicit ResourceDispatcher(IPC::Sender* sender); | 43 explicit ResourceDispatcher(IPC::Sender* sender); |
38 virtual ~ResourceDispatcher(); | 44 virtual ~ResourceDispatcher(); |
39 | 45 |
40 // IPC::Listener implementation. | 46 // IPC::Listener implementation. |
41 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 47 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
42 | 48 |
43 // Creates a ResourceLoaderBridge for this type of dispatcher, this is so | 49 // Creates a ResourceLoaderBridge for this type of dispatcher, this is so |
44 // this can be tested regardless of the ResourceLoaderBridge::Create | 50 // this can be tested regardless of the ResourceLoaderBridge::Create |
45 // implementation. | 51 // implementation. |
46 webkit_glue::ResourceLoaderBridge* CreateBridge( | 52 webkit_glue::ResourceLoaderBridge* CreateBridge( |
47 const RequestInfo& request_info); | 53 const RequestInfo& request_info); |
48 | 54 |
49 // Adds a request from the pending_requests_ list, returning the new | 55 // Adds a request from the pending_requests_ list, returning the new |
50 // requests' ID | 56 // requests' ID |
51 int AddPendingRequest(webkit_glue::ResourceLoaderBridge::Peer* callback, | 57 int AddPendingRequest(RequestPeer* callback, |
52 ResourceType::Type resource_type, | 58 ResourceType::Type resource_type, |
53 int origin_pid, | 59 int origin_pid, |
54 const GURL& frame_origin, | 60 const GURL& frame_origin, |
55 const GURL& request_url); | 61 const GURL& request_url); |
56 | 62 |
57 // Removes a request from the pending_requests_ list, returning true if the | 63 // Removes a request from the pending_requests_ list, returning true if the |
58 // request was found and removed. | 64 // request was found and removed. |
59 bool RemovePendingRequest(int request_id); | 65 bool RemovePendingRequest(int request_id); |
60 | 66 |
61 // Cancels a request in the pending_requests_ list. | 67 // Cancels a request in the pending_requests_ list. |
(...skipping 21 matching lines...) Expand all Loading... |
83 io_timestamp_ = io_timestamp; | 89 io_timestamp_ = io_timestamp; |
84 } | 90 } |
85 | 91 |
86 private: | 92 private: |
87 friend class ResourceDispatcherTest; | 93 friend class ResourceDispatcherTest; |
88 | 94 |
89 typedef std::deque<IPC::Message*> MessageQueue; | 95 typedef std::deque<IPC::Message*> MessageQueue; |
90 struct PendingRequestInfo { | 96 struct PendingRequestInfo { |
91 PendingRequestInfo(); | 97 PendingRequestInfo(); |
92 | 98 |
93 PendingRequestInfo(webkit_glue::ResourceLoaderBridge::Peer* peer, | 99 PendingRequestInfo(RequestPeer* peer, |
94 ResourceType::Type resource_type, | 100 ResourceType::Type resource_type, |
95 int origin_pid, | 101 int origin_pid, |
96 const GURL& frame_origin, | 102 const GURL& frame_origin, |
97 const GURL& request_url); | 103 const GURL& request_url); |
98 | 104 |
99 ~PendingRequestInfo(); | 105 ~PendingRequestInfo(); |
100 | 106 |
101 webkit_glue::ResourceLoaderBridge::Peer* peer; | 107 RequestPeer* peer; |
102 ResourceType::Type resource_type; | 108 ResourceType::Type resource_type; |
103 // The PID of the original process which issued this request. This gets | 109 // The PID of the original process which issued this request. This gets |
104 // non-zero only for a request proxied by another renderer, particularly | 110 // non-zero only for a request proxied by another renderer, particularly |
105 // requests from plugins. | 111 // requests from plugins. |
106 int origin_pid; | 112 int origin_pid; |
107 MessageQueue deferred_message_queue; | 113 MessageQueue deferred_message_queue; |
108 bool is_deferred; | 114 bool is_deferred; |
109 // Original requested url. | 115 // Original requested url. |
110 GURL url; | 116 GURL url; |
111 // The security origin of the frame that initiates this request. | 117 // The security origin of the frame that initiates this request. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 | 211 |
206 // IO thread timestamp for ongoing IPC message. | 212 // IO thread timestamp for ongoing IPC message. |
207 base::TimeTicks io_timestamp_; | 213 base::TimeTicks io_timestamp_; |
208 | 214 |
209 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); | 215 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); |
210 }; | 216 }; |
211 | 217 |
212 } // namespace content | 218 } // namespace content |
213 | 219 |
214 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ | 220 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ |
OLD | NEW |