| 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 11 matching lines...) Expand all Loading... |
| 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/common/url_loader.mojom.h" | 25 #include "content/common/url_loader.mojom.h" |
| 26 #include "content/public/common/resource_type.h" | 26 #include "content/public/common/resource_type.h" |
| 27 #include "ipc/ipc_listener.h" | 27 #include "ipc/ipc_listener.h" |
| 28 #include "ipc/ipc_sender.h" | 28 #include "ipc/ipc_sender.h" |
| 29 #include "net/base/request_priority.h" | 29 #include "net/base/request_priority.h" |
| 30 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 30 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
| 31 #include "url/gurl.h" | 31 #include "url/gurl.h" |
| 32 #include "url/origin.h" |
| 32 | 33 |
| 33 namespace mojo { | 34 namespace mojo { |
| 34 class AssociatedGroup; | 35 class AssociatedGroup; |
| 35 } // namespace mojo | 36 } // namespace mojo |
| 36 | 37 |
| 37 namespace net { | 38 namespace net { |
| 38 struct RedirectInfo; | 39 struct RedirectInfo; |
| 39 } | 40 } |
| 40 | 41 |
| 41 namespace content { | 42 namespace content { |
| 42 class RequestPeer; | 43 class RequestPeer; |
| 43 class ResourceDispatcherDelegate; | 44 class ResourceDispatcherDelegate; |
| 44 class ResourceRequestBodyImpl; | |
| 45 class ResourceSchedulingFilter; | 45 class ResourceSchedulingFilter; |
| 46 struct ResourceResponseInfo; | 46 struct ResourceResponseInfo; |
| 47 struct RequestInfo; | |
| 48 struct ResourceRequest; | 47 struct ResourceRequest; |
| 49 struct ResourceRequestCompletionStatus; | 48 struct ResourceRequestCompletionStatus; |
| 50 struct ResourceResponseHead; | 49 struct ResourceResponseHead; |
| 51 class SharedMemoryReceivedDataFactory; | 50 class SharedMemoryReceivedDataFactory; |
| 52 struct SiteIsolationResponseMetaData; | 51 struct SiteIsolationResponseMetaData; |
| 53 struct SyncLoadResponse; | 52 struct SyncLoadResponse; |
| 54 | 53 |
| 55 namespace mojom { | 54 namespace mojom { |
| 56 class URLLoaderFactory; | 55 class URLLoaderFactory; |
| 57 } // namespace mojom | 56 } // namespace mojom |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 // | 91 // |
| 93 // |routing_id| is used to associated the bridge with a frame's network | 92 // |routing_id| is used to associated the bridge with a frame's network |
| 94 // context. | 93 // context. |
| 95 // | 94 // |
| 96 // You can pass an optional argument |loading_task_runner| to specify task | 95 // You can pass an optional argument |loading_task_runner| to specify task |
| 97 // queue to execute loading tasks on. | 96 // queue to execute loading tasks on. |
| 98 virtual int StartAsync( | 97 virtual int StartAsync( |
| 99 std::unique_ptr<ResourceRequest> request, | 98 std::unique_ptr<ResourceRequest> request, |
| 100 int routing_id, | 99 int routing_id, |
| 101 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, | 100 scoped_refptr<base::SingleThreadTaskRunner> loading_task_runner, |
| 102 const GURL& frame_origin, | 101 const url::Origin& frame_origin, |
| 103 std::unique_ptr<RequestPeer> peer, | 102 std::unique_ptr<RequestPeer> peer, |
| 104 blink::WebURLRequest::LoadingIPCType ipc_type, | 103 blink::WebURLRequest::LoadingIPCType ipc_type, |
| 105 mojom::URLLoaderFactory* url_loader_factory, | 104 mojom::URLLoaderFactory* url_loader_factory, |
| 106 mojo::AssociatedGroup* associated_group); | 105 mojo::AssociatedGroup* associated_group); |
| 107 | 106 |
| 108 // Removes a request from the |pending_requests_| list, returning true if the | 107 // Removes a request from the |pending_requests_| list, returning true if the |
| 109 // request was found and removed. | 108 // request was found and removed. |
| 110 bool RemovePendingRequest(int request_id); | 109 bool RemovePendingRequest(int request_id); |
| 111 | 110 |
| 112 // Cancels a request in the |pending_requests_| list. The request will be | 111 // Cancels a request in the |pending_requests_| list. The request will be |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 151 |
| 153 private: | 152 private: |
| 154 friend class URLResponseBodyConsumer; | 153 friend class URLResponseBodyConsumer; |
| 155 friend class ResourceDispatcherTest; | 154 friend class ResourceDispatcherTest; |
| 156 | 155 |
| 157 typedef std::deque<IPC::Message*> MessageQueue; | 156 typedef std::deque<IPC::Message*> MessageQueue; |
| 158 struct PendingRequestInfo { | 157 struct PendingRequestInfo { |
| 159 PendingRequestInfo(std::unique_ptr<RequestPeer> peer, | 158 PendingRequestInfo(std::unique_ptr<RequestPeer> peer, |
| 160 ResourceType resource_type, | 159 ResourceType resource_type, |
| 161 int origin_pid, | 160 int origin_pid, |
| 162 const GURL& frame_origin, | 161 const url::Origin& frame_origin, |
| 163 const GURL& request_url, | 162 const GURL& request_url, |
| 164 bool download_to_file); | 163 bool download_to_file); |
| 165 | 164 |
| 166 ~PendingRequestInfo(); | 165 ~PendingRequestInfo(); |
| 167 | 166 |
| 168 std::unique_ptr<RequestPeer> peer; | 167 std::unique_ptr<RequestPeer> peer; |
| 169 ResourceType resource_type; | 168 ResourceType resource_type; |
| 170 // The PID of the original process which issued this request. This gets | 169 // The PID of the original process which issued this request. This gets |
| 171 // non-zero only for a request proxied by another renderer, particularly | 170 // non-zero only for a request proxied by another renderer, particularly |
| 172 // requests from plugins. | 171 // requests from plugins. |
| 173 int origin_pid; | 172 int origin_pid; |
| 174 MessageQueue deferred_message_queue; | 173 MessageQueue deferred_message_queue; |
| 175 bool is_deferred = false; | 174 bool is_deferred = false; |
| 176 // Original requested url. | 175 // Original requested url. |
| 177 GURL url; | 176 GURL url; |
| 178 // The security origin of the frame that initiates this request. | 177 // The security origin of the frame that initiates this request. |
| 179 GURL frame_origin; | 178 url::Origin frame_origin; |
| 180 // The url of the latest response even in case of redirection. | 179 // The url of the latest response even in case of redirection. |
| 181 GURL response_url; | 180 GURL response_url; |
| 182 bool download_to_file; | 181 bool download_to_file; |
| 183 std::unique_ptr<IPC::Message> pending_redirect_message; | 182 std::unique_ptr<IPC::Message> pending_redirect_message; |
| 184 base::TimeTicks request_start; | 183 base::TimeTicks request_start; |
| 185 base::TimeTicks response_start; | 184 base::TimeTicks response_start; |
| 186 base::TimeTicks completion_time; | 185 base::TimeTicks completion_time; |
| 187 linked_ptr<base::SharedMemory> buffer; | 186 linked_ptr<base::SharedMemory> buffer; |
| 188 scoped_refptr<SharedMemoryReceivedDataFactory> received_data_factory; | 187 scoped_refptr<SharedMemoryReceivedDataFactory> received_data_factory; |
| 189 std::unique_ptr<SiteIsolationResponseMetaData> site_isolation_metadata; | 188 std::unique_ptr<SiteIsolationResponseMetaData> site_isolation_metadata; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // handle in it that we should cleanup it up nicely. This method accepts any | 251 // handle in it that we should cleanup it up nicely. This method accepts any |
| 253 // message and determine whether the message is | 252 // message and determine whether the message is |
| 254 // ViewHostMsg_Resource_DataReceived and clean up the shared memory handle. | 253 // ViewHostMsg_Resource_DataReceived and clean up the shared memory handle. |
| 255 static void ReleaseResourcesInDataMessage(const IPC::Message& message); | 254 static void ReleaseResourcesInDataMessage(const IPC::Message& message); |
| 256 | 255 |
| 257 // Iterate through a message queue and clean up the messages by calling | 256 // Iterate through a message queue and clean up the messages by calling |
| 258 // ReleaseResourcesInDataMessage and removing them from the queue. Intended | 257 // ReleaseResourcesInDataMessage and removing them from the queue. Intended |
| 259 // for use on deferred message queues that are no longer needed. | 258 // for use on deferred message queues that are no longer needed. |
| 260 static void ReleaseResourcesInMessageQueue(MessageQueue* queue); | 259 static void ReleaseResourcesInMessageQueue(MessageQueue* queue); |
| 261 | 260 |
| 262 std::unique_ptr<ResourceRequest> CreateRequest( | |
| 263 const RequestInfo& request_info, | |
| 264 ResourceRequestBodyImpl* request_body, | |
| 265 GURL* frame_origin); | |
| 266 | |
| 267 IPC::Sender* message_sender_; | 261 IPC::Sender* message_sender_; |
| 268 | 262 |
| 269 // All pending requests issued to the host | 263 // All pending requests issued to the host |
| 270 PendingRequestMap pending_requests_; | 264 PendingRequestMap pending_requests_; |
| 271 | 265 |
| 272 ResourceDispatcherDelegate* delegate_; | 266 ResourceDispatcherDelegate* delegate_; |
| 273 | 267 |
| 274 // IO thread timestamp for ongoing IPC message. | 268 // IO thread timestamp for ongoing IPC message. |
| 275 base::TimeTicks io_timestamp_; | 269 base::TimeTicks io_timestamp_; |
| 276 | 270 |
| 277 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; | 271 scoped_refptr<base::SingleThreadTaskRunner> main_thread_task_runner_; |
| 278 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter_; | 272 scoped_refptr<ResourceSchedulingFilter> resource_scheduling_filter_; |
| 279 | 273 |
| 280 base::WeakPtrFactory<ResourceDispatcher> weak_factory_; | 274 base::WeakPtrFactory<ResourceDispatcher> weak_factory_; |
| 281 | 275 |
| 282 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); | 276 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); |
| 283 }; | 277 }; |
| 284 | 278 |
| 285 } // namespace content | 279 } // namespace content |
| 286 | 280 |
| 287 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ | 281 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ |
| OLD | NEW |