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 13 matching lines...) Expand all Loading... | |
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 RequestPeer; | 32 class RequestPeer; |
33 class ResourceDispatcherDelegate; | 33 class ResourceDispatcherDelegate; |
34 class ResourceRequestBody; | |
34 struct RequestInfo; | 35 struct RequestInfo; |
35 struct ResourceResponseHead; | 36 struct ResourceResponseHead; |
36 struct SiteIsolationResponseMetaData; | 37 struct SiteIsolationResponseMetaData; |
38 struct SyncLoadResponse; | |
37 | 39 |
38 // This class serves as a communication interface between the | 40 // This class serves as a communication interface between the |
39 // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in | 41 // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in |
40 // the child process. It can be used from any child process. | 42 // the child process. It can be used from any child process. |
41 class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { | 43 class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { |
42 public: | 44 public: |
43 explicit ResourceDispatcher(IPC::Sender* sender); | 45 explicit ResourceDispatcher(IPC::Sender* sender); |
44 virtual ~ResourceDispatcher(); | 46 virtual ~ResourceDispatcher(); |
45 | 47 |
46 // IPC::Listener implementation. | 48 // IPC::Listener implementation. |
47 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 49 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
48 | 50 |
49 // Creates a ResourceLoaderBridge for this type of dispatcher, this is so | 51 void CreateBridge(const RequestInfo& request_info); |
50 // this can be tested regardless of the ResourceLoaderBridge::Create | 52 void SetRequestBody(ResourceRequestBody* request_body); |
51 // implementation. | 53 bool Start(RequestPeer* peer); |
52 webkit_glue::ResourceLoaderBridge* CreateBridge( | 54 void Cancel(); |
53 const RequestInfo& request_info); | 55 void SetDefersLoading(bool value); |
56 void DidChangePriority(net::RequestPriority new_priority); | |
57 void SyncLoad(SyncLoadResponse* response); | |
54 | 58 |
55 // Adds a request from the pending_requests_ list, returning the new | 59 // Adds a request from the pending_requests_ list, returning the new |
56 // requests' ID | 60 // requests' ID |
57 int AddPendingRequest(RequestPeer* callback, | 61 int AddPendingRequest(RequestPeer* callback, |
58 ResourceType::Type resource_type, | 62 ResourceType::Type resource_type, |
59 int origin_pid, | 63 int origin_pid, |
60 const GURL& frame_origin, | 64 const GURL& frame_origin, |
61 const GURL& request_url); | 65 const GURL& request_url); |
62 | 66 |
63 // Removes a request from the pending_requests_ list, returning true if the | 67 // Removes a request from the pending_requests_ list, returning true if the |
(...skipping 20 matching lines...) Expand all Loading... | |
84 delegate_ = delegate; | 88 delegate_ = delegate; |
85 } | 89 } |
86 | 90 |
87 // Remembers IO thread timestamp for next resource message. | 91 // Remembers IO thread timestamp for next resource message. |
88 void set_io_timestamp(base::TimeTicks io_timestamp) { | 92 void set_io_timestamp(base::TimeTicks io_timestamp) { |
89 io_timestamp_ = io_timestamp; | 93 io_timestamp_ = io_timestamp; |
90 } | 94 } |
91 | 95 |
92 private: | 96 private: |
93 friend class ResourceDispatcherTest; | 97 friend class ResourceDispatcherTest; |
98 class IPCResourceLoaderBridge; | |
tfarina
2014/04/05 02:03:46
John, I burned my head, and this was the way I fou
jam
2014/04/07 16:43:22
you can forward declare that struct and put it int
tfarina
2014/04/11 01:43:55
Done.
| |
94 | 99 |
95 typedef std::deque<IPC::Message*> MessageQueue; | 100 typedef std::deque<IPC::Message*> MessageQueue; |
96 struct PendingRequestInfo { | 101 struct PendingRequestInfo { |
97 PendingRequestInfo(); | 102 PendingRequestInfo(); |
98 | 103 |
99 PendingRequestInfo(RequestPeer* peer, | 104 PendingRequestInfo(RequestPeer* peer, |
100 ResourceType::Type resource_type, | 105 ResourceType::Type resource_type, |
101 int origin_pid, | 106 int origin_pid, |
102 const GURL& frame_origin, | 107 const GURL& frame_origin, |
103 const GURL& request_url); | 108 const GURL& request_url); |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
205 // All pending requests issued to the host | 210 // All pending requests issued to the host |
206 PendingRequestList pending_requests_; | 211 PendingRequestList pending_requests_; |
207 | 212 |
208 base::WeakPtrFactory<ResourceDispatcher> weak_factory_; | 213 base::WeakPtrFactory<ResourceDispatcher> weak_factory_; |
209 | 214 |
210 ResourceDispatcherDelegate* delegate_; | 215 ResourceDispatcherDelegate* delegate_; |
211 | 216 |
212 // IO thread timestamp for ongoing IPC message. | 217 // IO thread timestamp for ongoing IPC message. |
213 base::TimeTicks io_timestamp_; | 218 base::TimeTicks io_timestamp_; |
214 | 219 |
220 scoped_ptr<IPCResourceLoaderBridge> bridge_; | |
221 | |
215 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); | 222 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); |
216 }; | 223 }; |
217 | 224 |
218 } // namespace content | 225 } // namespace content |
219 | 226 |
220 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ | 227 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ |
OLD | NEW |