| 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 <stdint.h> | 10 #include <stdint.h> |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 #include "base/memory/weak_ptr.h" | 21 #include "base/memory/weak_ptr.h" |
| 22 #include "base/single_thread_task_runner.h" | 22 #include "base/single_thread_task_runner.h" |
| 23 #include "base/time/time.h" | 23 #include "base/time/time.h" |
| 24 #include "content/common/content_export.h" | 24 #include "content/common/content_export.h" |
| 25 #include "content/public/common/resource_type.h" | 25 #include "content/public/common/resource_type.h" |
| 26 #include "ipc/ipc_listener.h" | 26 #include "ipc/ipc_listener.h" |
| 27 #include "ipc/ipc_sender.h" | 27 #include "ipc/ipc_sender.h" |
| 28 #include "net/base/request_priority.h" | 28 #include "net/base/request_priority.h" |
| 29 #include "url/gurl.h" | 29 #include "url/gurl.h" |
| 30 | 30 |
| 31 struct ResourceHostMsg_Request; | |
| 32 struct ResourceMsg_RequestCompleteData; | |
| 33 | |
| 34 namespace net { | 31 namespace net { |
| 35 struct RedirectInfo; | 32 struct RedirectInfo; |
| 36 } | 33 } |
| 37 | 34 |
| 38 namespace content { | 35 namespace content { |
| 39 class RequestPeer; | 36 class RequestPeer; |
| 40 class ResourceDispatcherDelegate; | 37 class ResourceDispatcherDelegate; |
| 41 class ResourceRequestBody; | 38 class ResourceRequestBody; |
| 42 class ResourceSchedulingFilter; | 39 class ResourceSchedulingFilter; |
| 43 struct ResourceResponseInfo; | 40 struct ResourceResponseInfo; |
| 44 struct RequestInfo; | 41 struct RequestInfo; |
| 42 struct ResourceRequest; |
| 43 struct ResourceRequestCompletionStatus; |
| 45 struct ResourceResponseHead; | 44 struct ResourceResponseHead; |
| 46 class SharedMemoryReceivedDataFactory; | 45 class SharedMemoryReceivedDataFactory; |
| 47 struct SiteIsolationResponseMetaData; | 46 struct SiteIsolationResponseMetaData; |
| 48 struct SyncLoadResponse; | 47 struct SyncLoadResponse; |
| 49 | 48 |
| 50 // This class serves as a communication interface to the ResourceDispatcherHost | 49 // This class serves as a communication interface to the ResourceDispatcherHost |
| 51 // in the browser process. It can be used from any child process. | 50 // in the browser process. It can be used from any child process. |
| 52 // Virtual methods are for tests. | 51 // Virtual methods are for tests. |
| 53 class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { | 52 class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { |
| 54 public: | 53 public: |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 void OnReceivedInlinedDataChunk(int request_id, | 179 void OnReceivedInlinedDataChunk(int request_id, |
| 181 const std::vector<char>& data, | 180 const std::vector<char>& data, |
| 182 int encoded_data_length); | 181 int encoded_data_length); |
| 183 void OnReceivedData(int request_id, | 182 void OnReceivedData(int request_id, |
| 184 int data_offset, | 183 int data_offset, |
| 185 int data_length, | 184 int data_length, |
| 186 int encoded_data_length); | 185 int encoded_data_length); |
| 187 void OnDownloadedData(int request_id, int data_len, int encoded_data_length); | 186 void OnDownloadedData(int request_id, int data_len, int encoded_data_length); |
| 188 void OnRequestComplete( | 187 void OnRequestComplete( |
| 189 int request_id, | 188 int request_id, |
| 190 const ResourceMsg_RequestCompleteData& request_complete_data); | 189 const ResourceRequestCompletionStatus& request_complete_data); |
| 191 | 190 |
| 192 // Dispatch the message to one of the message response handlers. | 191 // Dispatch the message to one of the message response handlers. |
| 193 void DispatchMessage(const IPC::Message& message); | 192 void DispatchMessage(const IPC::Message& message); |
| 194 | 193 |
| 195 // Dispatch any deferred messages for the given request, provided it is not | 194 // Dispatch any deferred messages for the given request, provided it is not |
| 196 // again in the deferred state. This method may mutate |pending_requests_|. | 195 // again in the deferred state. This method may mutate |pending_requests_|. |
| 197 void FlushDeferredMessages(int request_id); | 196 void FlushDeferredMessages(int request_id); |
| 198 | 197 |
| 199 void ToResourceResponseInfo(const PendingRequestInfo& request_info, | 198 void ToResourceResponseInfo(const PendingRequestInfo& request_info, |
| 200 const ResourceResponseHead& browser_info, | 199 const ResourceResponseHead& browser_info, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 216 // handle in it that we should cleanup it up nicely. This method accepts any | 215 // handle in it that we should cleanup it up nicely. This method accepts any |
| 217 // message and determine whether the message is | 216 // message and determine whether the message is |
| 218 // ViewHostMsg_Resource_DataReceived and clean up the shared memory handle. | 217 // ViewHostMsg_Resource_DataReceived and clean up the shared memory handle. |
| 219 static void ReleaseResourcesInDataMessage(const IPC::Message& message); | 218 static void ReleaseResourcesInDataMessage(const IPC::Message& message); |
| 220 | 219 |
| 221 // Iterate through a message queue and clean up the messages by calling | 220 // Iterate through a message queue and clean up the messages by calling |
| 222 // ReleaseResourcesInDataMessage and removing them from the queue. Intended | 221 // ReleaseResourcesInDataMessage and removing them from the queue. Intended |
| 223 // for use on deferred message queues that are no longer needed. | 222 // for use on deferred message queues that are no longer needed. |
| 224 static void ReleaseResourcesInMessageQueue(MessageQueue* queue); | 223 static void ReleaseResourcesInMessageQueue(MessageQueue* queue); |
| 225 | 224 |
| 226 std::unique_ptr<ResourceHostMsg_Request> CreateRequest( | 225 std::unique_ptr<ResourceRequest> CreateRequest( |
| 227 const RequestInfo& request_info, | 226 const RequestInfo& request_info, |
| 228 ResourceRequestBody* request_body, | 227 ResourceRequestBody* request_body, |
| 229 GURL* frame_origin); | 228 GURL* frame_origin); |
| 230 | 229 |
| 231 IPC::Sender* message_sender_; | 230 IPC::Sender* message_sender_; |
| 232 | 231 |
| 233 // All pending requests issued to the host | 232 // All pending requests issued to the host |
| 234 PendingRequestMap pending_requests_; | 233 PendingRequestMap pending_requests_; |
| 235 | 234 |
| 236 ResourceDispatcherDelegate* delegate_; | 235 ResourceDispatcherDelegate* delegate_; |
| 237 | 236 |
| 238 // IO thread timestamp for ongoing IPC message. | 237 // IO thread timestamp for ongoing IPC message. |
| 239 base::TimeTicks io_timestamp_; | 238 base::TimeTicks io_timestamp_; |
| 240 | 239 |
| 241 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 240 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 242 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter_; | 241 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter_; |
| 243 | 242 |
| 244 base::WeakPtrFactory<ResourceDispatcher> weak_factory_; | 243 base::WeakPtrFactory<ResourceDispatcher> weak_factory_; |
| 245 | 244 |
| 246 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); | 245 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); |
| 247 }; | 246 }; |
| 248 | 247 |
| 249 } // namespace content | 248 } // namespace content |
| 250 | 249 |
| 251 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ | 250 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ |
| OLD | NEW |