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_COMMON_RESOURCE_DISPATCHER_H_ | 7 #ifndef CONTENT_COMMON_RESOURCE_DISPATCHER_H_ |
8 #define CONTENT_COMMON_RESOURCE_DISPATCHER_H_ | 8 #define CONTENT_COMMON_RESOURCE_DISPATCHER_H_ |
9 | 9 |
10 #include <deque> | 10 #include <deque> |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 // Indicates the priority of the specified request changed. | 64 // Indicates the priority of the specified request changed. |
65 void DidChangePriority(int routing_id, int request_id, | 65 void DidChangePriority(int routing_id, int request_id, |
66 net::RequestPriority new_priority); | 66 net::RequestPriority new_priority); |
67 | 67 |
68 // This does not take ownership of the delegate. It is expected that the | 68 // This does not take ownership of the delegate. It is expected that the |
69 // delegate have a longer lifetime than the ResourceDispatcher. | 69 // delegate have a longer lifetime than the ResourceDispatcher. |
70 void set_delegate(ResourceDispatcherDelegate* delegate) { | 70 void set_delegate(ResourceDispatcherDelegate* delegate) { |
71 delegate_ = delegate; | 71 delegate_ = delegate; |
72 } | 72 } |
73 | 73 |
| 74 // Remembers IO thread timestamp for next resource message. |
| 75 void set_io_timestamp(base::TimeTicks io_timestamp) { |
| 76 io_timestamp_ = io_timestamp; |
| 77 } |
| 78 |
74 private: | 79 private: |
75 friend class ResourceDispatcherTest; | 80 friend class ResourceDispatcherTest; |
76 | 81 |
77 typedef std::deque<IPC::Message*> MessageQueue; | 82 typedef std::deque<IPC::Message*> MessageQueue; |
78 struct PendingRequestInfo { | 83 struct PendingRequestInfo { |
79 PendingRequestInfo(); | 84 PendingRequestInfo(); |
80 | 85 |
81 PendingRequestInfo(webkit_glue::ResourceLoaderBridge::Peer* peer, | 86 PendingRequestInfo(webkit_glue::ResourceLoaderBridge::Peer* peer, |
82 ResourceType::Type resource_type, | 87 ResourceType::Type resource_type, |
83 const GURL& request_url); | 88 const GURL& request_url); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 | 155 |
151 void ToResourceResponseInfo( | 156 void ToResourceResponseInfo( |
152 const PendingRequestInfo& request_info, | 157 const PendingRequestInfo& request_info, |
153 const ResourceResponseHead& browser_info, | 158 const ResourceResponseHead& browser_info, |
154 webkit_glue::ResourceResponseInfo* renderer_info) const; | 159 webkit_glue::ResourceResponseInfo* renderer_info) const; |
155 | 160 |
156 base::TimeTicks ToRendererCompletionTime( | 161 base::TimeTicks ToRendererCompletionTime( |
157 const PendingRequestInfo& request_info, | 162 const PendingRequestInfo& request_info, |
158 const base::TimeTicks& browser_completion_time) const; | 163 const base::TimeTicks& browser_completion_time) const; |
159 | 164 |
| 165 // Returns timestamp provided by IO thread. If no timestamp is supplied, |
| 166 // then current time is returned. Saved timestamp is reset, so follofing |
| 167 // invocations will return current time until set_io_timestamp is called. |
| 168 base::TimeTicks consume_io_timestamp(); |
| 169 |
160 // Returns true if the message passed in is a resource related message. | 170 // Returns true if the message passed in is a resource related message. |
161 static bool IsResourceDispatcherMessage(const IPC::Message& message); | 171 static bool IsResourceDispatcherMessage(const IPC::Message& message); |
162 | 172 |
163 // ViewHostMsg_Resource_DataReceived is not POD, it has a shared memory | 173 // ViewHostMsg_Resource_DataReceived is not POD, it has a shared memory |
164 // handle in it that we should cleanup it up nicely. This method accepts any | 174 // handle in it that we should cleanup it up nicely. This method accepts any |
165 // message and determine whether the message is | 175 // message and determine whether the message is |
166 // ViewHostMsg_Resource_DataReceived and clean up the shared memory handle. | 176 // ViewHostMsg_Resource_DataReceived and clean up the shared memory handle. |
167 static void ReleaseResourcesInDataMessage(const IPC::Message& message); | 177 static void ReleaseResourcesInDataMessage(const IPC::Message& message); |
168 | 178 |
169 // Iterate through a message queue and clean up the messages by calling | 179 // Iterate through a message queue and clean up the messages by calling |
170 // ReleaseResourcesInDataMessage and removing them from the queue. Intended | 180 // ReleaseResourcesInDataMessage and removing them from the queue. Intended |
171 // for use on deferred message queues that are no longer needed. | 181 // for use on deferred message queues that are no longer needed. |
172 static void ReleaseResourcesInMessageQueue(MessageQueue* queue); | 182 static void ReleaseResourcesInMessageQueue(MessageQueue* queue); |
173 | 183 |
174 IPC::Sender* message_sender_; | 184 IPC::Sender* message_sender_; |
175 | 185 |
176 // All pending requests issued to the host | 186 // All pending requests issued to the host |
177 PendingRequestList pending_requests_; | 187 PendingRequestList pending_requests_; |
178 | 188 |
179 base::WeakPtrFactory<ResourceDispatcher> weak_factory_; | 189 base::WeakPtrFactory<ResourceDispatcher> weak_factory_; |
180 | 190 |
181 ResourceDispatcherDelegate* delegate_; | 191 ResourceDispatcherDelegate* delegate_; |
182 | 192 |
| 193 // IO thread timestamp for ongoing IPC message. |
| 194 base::TimeTicks io_timestamp_; |
| 195 |
183 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); | 196 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); |
184 }; | 197 }; |
185 | 198 |
186 } // namespace content | 199 } // namespace content |
187 | 200 |
188 #endif // CONTENT_COMMON_RESOURCE_DISPATCHER_H_ | 201 #endif // CONTENT_COMMON_RESOURCE_DISPATCHER_H_ |
OLD | NEW |