| 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 17 matching lines...) Expand all Loading... |
| 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 namespace net { | 31 namespace net { |
| 32 struct RedirectInfo; | 32 struct RedirectInfo; |
| 33 } | 33 } |
| 34 | 34 |
| 35 namespace content { | 35 namespace content { |
| 36 class RequestPeer; | 36 class RequestPeer; |
| 37 class ResourceDispatcherDelegate; | 37 class ResourceDispatcherDelegate; |
| 38 class ResourceRequestBody; | 38 class ResourceRequestBodyImpl; |
| 39 class ResourceSchedulingFilter; | 39 class ResourceSchedulingFilter; |
| 40 struct ResourceResponseInfo; | 40 struct ResourceResponseInfo; |
| 41 struct RequestInfo; | 41 struct RequestInfo; |
| 42 struct ResourceRequest; | 42 struct ResourceRequest; |
| 43 struct ResourceRequestCompletionStatus; | 43 struct ResourceRequestCompletionStatus; |
| 44 struct ResourceResponseHead; | 44 struct ResourceResponseHead; |
| 45 class SharedMemoryReceivedDataFactory; | 45 class SharedMemoryReceivedDataFactory; |
| 46 struct SiteIsolationResponseMetaData; | 46 struct SiteIsolationResponseMetaData; |
| 47 struct SyncLoadResponse; | 47 struct SyncLoadResponse; |
| 48 | 48 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 60 bool OnMessageReceived(const IPC::Message& message) override; | 60 bool OnMessageReceived(const IPC::Message& message) override; |
| 61 | 61 |
| 62 // Call this method to load the resource synchronously (i.e., in one shot). | 62 // Call this method to load the resource synchronously (i.e., in one shot). |
| 63 // This is an alternative to the StartAsync method. Be warned that this method | 63 // This is an alternative to the StartAsync method. Be warned that this method |
| 64 // will block the calling thread until the resource is fully downloaded or an | 64 // will block the calling thread until the resource is fully downloaded or an |
| 65 // error occurs. It could block the calling thread for a long time, so only | 65 // error occurs. It could block the calling thread for a long time, so only |
| 66 // use this if you really need it! There is also no way for the caller to | 66 // use this if you really need it! There is also no way for the caller to |
| 67 // interrupt this method. Errors are reported via the status field of the | 67 // interrupt this method. Errors are reported via the status field of the |
| 68 // response parameter. | 68 // response parameter. |
| 69 void StartSync(const RequestInfo& request_info, | 69 void StartSync(const RequestInfo& request_info, |
| 70 ResourceRequestBody* request_body, | 70 ResourceRequestBodyImpl* request_body, |
| 71 SyncLoadResponse* response); | 71 SyncLoadResponse* response); |
| 72 | 72 |
| 73 // Call this method to initiate the request. If this method succeeds, then | 73 // Call this method to initiate the request. If this method succeeds, then |
| 74 // the peer's methods will be called asynchronously to report various events. | 74 // the peer's methods will be called asynchronously to report various events. |
| 75 // Returns the request id. | 75 // Returns the request id. |
| 76 virtual int StartAsync(const RequestInfo& request_info, | 76 virtual int StartAsync(const RequestInfo& request_info, |
| 77 ResourceRequestBody* request_body, | 77 ResourceRequestBodyImpl* request_body, |
| 78 std::unique_ptr<RequestPeer> peer); | 78 std::unique_ptr<RequestPeer> peer); |
| 79 | 79 |
| 80 // Removes a request from the |pending_requests_| list, returning true if the | 80 // Removes a request from the |pending_requests_| list, returning true if the |
| 81 // request was found and removed. | 81 // request was found and removed. |
| 82 bool RemovePendingRequest(int request_id); | 82 bool RemovePendingRequest(int request_id); |
| 83 | 83 |
| 84 // Cancels a request in the |pending_requests_| list. The request will be | 84 // Cancels a request in the |pending_requests_| list. The request will be |
| 85 // removed from the dispatcher as well. | 85 // removed from the dispatcher as well. |
| 86 virtual void Cancel(int request_id); | 86 virtual void Cancel(int request_id); |
| 87 | 87 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // ViewHostMsg_Resource_DataReceived and clean up the shared memory handle. | 217 // ViewHostMsg_Resource_DataReceived and clean up the shared memory handle. |
| 218 static void ReleaseResourcesInDataMessage(const IPC::Message& message); | 218 static void ReleaseResourcesInDataMessage(const IPC::Message& message); |
| 219 | 219 |
| 220 // 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 |
| 221 // ReleaseResourcesInDataMessage and removing them from the queue. Intended | 221 // ReleaseResourcesInDataMessage and removing them from the queue. Intended |
| 222 // for use on deferred message queues that are no longer needed. | 222 // for use on deferred message queues that are no longer needed. |
| 223 static void ReleaseResourcesInMessageQueue(MessageQueue* queue); | 223 static void ReleaseResourcesInMessageQueue(MessageQueue* queue); |
| 224 | 224 |
| 225 std::unique_ptr<ResourceRequest> CreateRequest( | 225 std::unique_ptr<ResourceRequest> CreateRequest( |
| 226 const RequestInfo& request_info, | 226 const RequestInfo& request_info, |
| 227 ResourceRequestBody* request_body, | 227 ResourceRequestBodyImpl* request_body, |
| 228 GURL* frame_origin); | 228 GURL* frame_origin); |
| 229 | 229 |
| 230 IPC::Sender* message_sender_; | 230 IPC::Sender* message_sender_; |
| 231 | 231 |
| 232 // All pending requests issued to the host | 232 // All pending requests issued to the host |
| 233 PendingRequestMap pending_requests_; | 233 PendingRequestMap pending_requests_; |
| 234 | 234 |
| 235 ResourceDispatcherDelegate* delegate_; | 235 ResourceDispatcherDelegate* delegate_; |
| 236 | 236 |
| 237 // IO thread timestamp for ongoing IPC message. | 237 // IO thread timestamp for ongoing IPC message. |
| 238 base::TimeTicks io_timestamp_; | 238 base::TimeTicks io_timestamp_; |
| 239 | 239 |
| 240 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 240 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 241 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter_; | 241 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter_; |
| 242 | 242 |
| 243 base::WeakPtrFactory<ResourceDispatcher> weak_factory_; | 243 base::WeakPtrFactory<ResourceDispatcher> weak_factory_; |
| 244 | 244 |
| 245 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); | 245 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); |
| 246 }; | 246 }; |
| 247 | 247 |
| 248 } // namespace content | 248 } // namespace content |
| 249 | 249 |
| 250 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ | 250 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ |
| OLD | NEW |