| 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> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 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 { | 26 namespace webkit_glue { |
| 27 class ResourceLoaderBridge; | 27 class ResourceLoaderBridge; |
| 28 struct ResourceResponseInfo; | 28 struct ResourceResponseInfo; |
| 29 } | 29 } |
| 30 | 30 |
| 31 namespace content { | 31 namespace content { |
| 32 class HighPriorityResourceFilter; |
| 32 class RequestPeer; | 33 class RequestPeer; |
| 33 class ResourceDispatcherDelegate; | 34 class ResourceDispatcherDelegate; |
| 34 struct RequestInfo; | 35 struct RequestInfo; |
| 35 struct ResourceResponseHead; | 36 struct ResourceResponseHead; |
| 36 struct SiteIsolationResponseMetaData; | 37 struct SiteIsolationResponseMetaData; |
| 37 | 38 |
| 38 // This class serves as a communication interface between the | 39 // This class serves as a communication interface between the |
| 39 // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in | 40 // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in |
| 40 // the child process. It can be used from any child process. | 41 // the child process. It can be used from any child process. |
| 41 class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { | 42 class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 int intra_priority_value); | 78 int intra_priority_value); |
| 78 | 79 |
| 79 IPC::Sender* message_sender() const { return message_sender_; } | 80 IPC::Sender* message_sender() const { return message_sender_; } |
| 80 | 81 |
| 81 // This does not take ownership of the delegate. It is expected that the | 82 // This does not take ownership of the delegate. It is expected that the |
| 82 // delegate have a longer lifetime than the ResourceDispatcher. | 83 // delegate have a longer lifetime than the ResourceDispatcher. |
| 83 void set_delegate(ResourceDispatcherDelegate* delegate) { | 84 void set_delegate(ResourceDispatcherDelegate* delegate) { |
| 84 delegate_ = delegate; | 85 delegate_ = delegate; |
| 85 } | 86 } |
| 86 | 87 |
| 88 void set_high_priority_resource_filter( |
| 89 HighPriorityResourceFilter* high_priority_resource_filter) { |
| 90 high_priority_resource_filter_ = high_priority_resource_filter; |
| 91 } |
| 92 |
| 87 // Remembers IO thread timestamp for next resource message. | 93 // Remembers IO thread timestamp for next resource message. |
| 88 void set_io_timestamp(base::TimeTicks io_timestamp) { | 94 void set_io_timestamp(base::TimeTicks io_timestamp) { |
| 89 io_timestamp_ = io_timestamp; | 95 io_timestamp_ = io_timestamp; |
| 90 } | 96 } |
| 91 | 97 |
| 98 // Returns true if the message passed in is a resource related message. |
| 99 static bool IsResourceDispatcherMessage(const IPC::Message& message); |
| 100 |
| 92 private: | 101 private: |
| 93 friend class ResourceDispatcherTest; | 102 friend class ResourceDispatcherTest; |
| 94 | 103 |
| 95 typedef std::deque<IPC::Message*> MessageQueue; | 104 typedef std::deque<IPC::Message*> MessageQueue; |
| 96 struct PendingRequestInfo { | 105 struct PendingRequestInfo { |
| 97 PendingRequestInfo(); | 106 PendingRequestInfo(); |
| 98 | 107 |
| 99 PendingRequestInfo(RequestPeer* peer, | 108 PendingRequestInfo(RequestPeer* peer, |
| 100 ResourceType::Type resource_type, | 109 ResourceType::Type resource_type, |
| 101 int origin_pid, | 110 int origin_pid, |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 182 |
| 174 base::TimeTicks ToRendererCompletionTime( | 183 base::TimeTicks ToRendererCompletionTime( |
| 175 const PendingRequestInfo& request_info, | 184 const PendingRequestInfo& request_info, |
| 176 const base::TimeTicks& browser_completion_time) const; | 185 const base::TimeTicks& browser_completion_time) const; |
| 177 | 186 |
| 178 // Returns timestamp provided by IO thread. If no timestamp is supplied, | 187 // Returns timestamp provided by IO thread. If no timestamp is supplied, |
| 179 // then current time is returned. Saved timestamp is reset, so following | 188 // then current time is returned. Saved timestamp is reset, so following |
| 180 // invocations will return current time until set_io_timestamp is called. | 189 // invocations will return current time until set_io_timestamp is called. |
| 181 base::TimeTicks ConsumeIOTimestamp(); | 190 base::TimeTicks ConsumeIOTimestamp(); |
| 182 | 191 |
| 183 // Returns true if the message passed in is a resource related message. | |
| 184 static bool IsResourceDispatcherMessage(const IPC::Message& message); | |
| 185 | |
| 186 // ViewHostMsg_Resource_DataReceived is not POD, it has a shared memory | 192 // ViewHostMsg_Resource_DataReceived is not POD, it has a shared memory |
| 187 // handle in it that we should cleanup it up nicely. This method accepts any | 193 // handle in it that we should cleanup it up nicely. This method accepts any |
| 188 // message and determine whether the message is | 194 // message and determine whether the message is |
| 189 // ViewHostMsg_Resource_DataReceived and clean up the shared memory handle. | 195 // ViewHostMsg_Resource_DataReceived and clean up the shared memory handle. |
| 190 static void ReleaseResourcesInDataMessage(const IPC::Message& message); | 196 static void ReleaseResourcesInDataMessage(const IPC::Message& message); |
| 191 | 197 |
| 192 // Iterate through a message queue and clean up the messages by calling | 198 // Iterate through a message queue and clean up the messages by calling |
| 193 // ReleaseResourcesInDataMessage and removing them from the queue. Intended | 199 // ReleaseResourcesInDataMessage and removing them from the queue. Intended |
| 194 // for use on deferred message queues that are no longer needed. | 200 // for use on deferred message queues that are no longer needed. |
| 195 static void ReleaseResourcesInMessageQueue(MessageQueue* queue); | 201 static void ReleaseResourcesInMessageQueue(MessageQueue* queue); |
| 196 | 202 |
| 197 IPC::Sender* message_sender_; | 203 IPC::Sender* message_sender_; |
| 198 | 204 |
| 199 // All pending requests issued to the host | 205 // All pending requests issued to the host |
| 200 PendingRequestList pending_requests_; | 206 PendingRequestList pending_requests_; |
| 201 | 207 |
| 202 base::WeakPtrFactory<ResourceDispatcher> weak_factory_; | 208 base::WeakPtrFactory<ResourceDispatcher> weak_factory_; |
| 203 | 209 |
| 204 ResourceDispatcherDelegate* delegate_; | 210 ResourceDispatcherDelegate* delegate_; |
| 205 | 211 |
| 212 HighPriorityResourceFilter* high_priority_resource_filter_; |
| 213 |
| 206 // IO thread timestamp for ongoing IPC message. | 214 // IO thread timestamp for ongoing IPC message. |
| 207 base::TimeTicks io_timestamp_; | 215 base::TimeTicks io_timestamp_; |
| 208 | 216 |
| 209 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); | 217 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); |
| 210 }; | 218 }; |
| 211 | 219 |
| 212 } // namespace content | 220 } // namespace content |
| 213 | 221 |
| 214 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ | 222 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ |
| OLD | NEW |