Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(117)

Side by Side Diff: content/child/resource_dispatcher.h

Issue 226273005: Remove webkit's ResourceLoaderBridge interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: put back AddRef() Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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>
11 #include <string> 11 #include <string>
12 12
13 #include "base/containers/hash_tables.h" 13 #include "base/containers/hash_tables.h"
14 #include "base/memory/linked_ptr.h" 14 #include "base/memory/linked_ptr.h"
15 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/shared_memory.h" 16 #include "base/memory/shared_memory.h"
16 #include "base/memory/weak_ptr.h" 17 #include "base/memory/weak_ptr.h"
17 #include "base/time/time.h" 18 #include "base/time/time.h"
18 #include "content/common/content_export.h" 19 #include "content/common/content_export.h"
19 #include "ipc/ipc_listener.h" 20 #include "ipc/ipc_listener.h"
20 #include "ipc/ipc_sender.h" 21 #include "ipc/ipc_sender.h"
21 #include "net/base/request_priority.h" 22 #include "net/base/request_priority.h"
22 #include "webkit/common/resource_type.h" 23 #include "webkit/common/resource_type.h"
23 24
25 struct ResourceHostMsg_Request;
24 struct ResourceMsg_RequestCompleteData; 26 struct ResourceMsg_RequestCompleteData;
25 27
26 namespace webkit_glue { 28 namespace webkit_glue {
27 class ResourceLoaderBridge; 29 class ResourceLoaderBridge;
28 struct ResourceResponseInfo; 30 struct ResourceResponseInfo;
29 } 31 }
30 32
31 namespace content { 33 namespace content {
32 class RequestPeer; 34 class RequestPeer;
33 class ResourceDispatcherDelegate; 35 class ResourceDispatcherDelegate;
36 class ResourceRequestBody;
34 struct RequestInfo; 37 struct RequestInfo;
35 struct ResourceResponseHead; 38 struct ResourceResponseHead;
36 struct SiteIsolationResponseMetaData; 39 struct SiteIsolationResponseMetaData;
40 struct SyncLoadResponse;
37 41
38 // This class serves as a communication interface between the 42 // This class serves as a communication interface between the
39 // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in 43 // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in
40 // the child process. It can be used from any child process. 44 // the child process. It can be used from any child process.
41 class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { 45 class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener {
42 public: 46 public:
43 explicit ResourceDispatcher(IPC::Sender* sender); 47 explicit ResourceDispatcher(IPC::Sender* sender);
44 virtual ~ResourceDispatcher(); 48 virtual ~ResourceDispatcher();
45 49
46 // IPC::Listener implementation. 50 // IPC::Listener implementation.
47 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 51 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
48 52
49 // Creates a ResourceLoaderBridge for this type of dispatcher, this is so 53
50 // this can be tested regardless of the ResourceLoaderBridge::Create 54 // Call this method to load the resource synchronously (i.e., in one shot).
51 // implementation. 55 // This is an alternative to the StartAsync method. Be warned that this method
52 webkit_glue::ResourceLoaderBridge* CreateBridge( 56 // will block the calling thread until the resource is fully downloaded or an
53 const RequestInfo& request_info); 57 // error occurs. It could block the calling thread for a long time, so only
58 // use this if you really need it! There is also no way for the caller to
59 // interrupt this method. Errors are reported via the status field of the
60 // response parameter.
61 void StartSync(const RequestInfo& request_info,
62 ResourceRequestBody* request_body,
63 SyncLoadResponse* response);
64
65 // Call this method to initiate the request. If this method succeeds, then
66 // the peer's methods will be called asynchronously to report various events.
67 // Returns the request id.
68 int StartAsync(const RequestInfo& request_info,
69 ResourceRequestBody* request_body,
70 RequestPeer* peer);
54 71
55 // Adds a request from the pending_requests_ list, returning the new 72 // Adds a request from the pending_requests_ list, returning the new
56 // requests' ID 73 // requests' ID
57 int AddPendingRequest(RequestPeer* callback, 74 int AddPendingRequest(RequestPeer* callback,
58 ResourceType::Type resource_type, 75 ResourceType::Type resource_type,
59 int origin_pid, 76 int origin_pid,
60 const GURL& frame_origin, 77 const GURL& frame_origin,
61 const GURL& request_url); 78 const GURL& request_url);
62 79
63 // 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
64 // request was found and removed. 81 // request was found and removed.
65 bool RemovePendingRequest(int request_id); 82 bool RemovePendingRequest(int request_id);
jam 2014/04/24 16:14:08 i just noticed this isn't called anymore. this wil
tfarina 2014/04/26 04:23:50 Done.
66 83
67 // Cancels a request in the pending_requests_ list. 84 // Cancels a request in the pending_requests_ list.
68 void CancelPendingRequest(int request_id); 85 void CancelPendingRequest(int request_id);
jam 2014/04/24 16:14:08 nit: rename this method to Cancel() now to match t
tfarina 2014/04/26 04:23:50 Done.
69 86
70 IPC::Sender* message_sender() const { 87 IPC::Sender* message_sender() const { return message_sender_; }
71 return message_sender_;
72 }
73 88
74 // Toggles the is_deferred attribute for the specified request. 89 // Toggles the is_deferred attribute for the specified request.
75 void SetDefersLoading(int request_id, bool value); 90 void SetDefersLoading(int request_id, bool value);
76 91
77 // Indicates the priority of the specified request changed. 92 // Indicates the priority of the specified request changed.
78 void DidChangePriority(int routing_id, int request_id, 93 void DidChangePriority(int routing_id,
94 int request_id,
79 net::RequestPriority new_priority, 95 net::RequestPriority new_priority,
80 int intra_priority_value); 96 int intra_priority_value);
81 97
82 // This does not take ownership of the delegate. It is expected that the 98 // This does not take ownership of the delegate. It is expected that the
83 // delegate have a longer lifetime than the ResourceDispatcher. 99 // delegate have a longer lifetime than the ResourceDispatcher.
84 void set_delegate(ResourceDispatcherDelegate* delegate) { 100 void set_delegate(ResourceDispatcherDelegate* delegate) {
85 delegate_ = delegate; 101 delegate_ = delegate;
86 } 102 }
87 103
88 // Remembers IO thread timestamp for next resource message. 104 // Remembers IO thread timestamp for next resource message.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 typedef base::hash_map<int, PendingRequestInfo> PendingRequestList; 147 typedef base::hash_map<int, PendingRequestInfo> PendingRequestList;
132 148
133 // Helper to lookup the info based on the request_id. 149 // Helper to lookup the info based on the request_id.
134 // May return NULL if the request as been canceled from the client side. 150 // May return NULL if the request as been canceled from the client side.
135 PendingRequestInfo* GetPendingRequestInfo(int request_id); 151 PendingRequestInfo* GetPendingRequestInfo(int request_id);
136 152
137 // Follows redirect, if any, for the given request. 153 // Follows redirect, if any, for the given request.
138 void FollowPendingRedirect(int request_id, PendingRequestInfo& request_info); 154 void FollowPendingRedirect(int request_id, PendingRequestInfo& request_info);
139 155
140 // Message response handlers, called by the message handler for this process. 156 // Message response handlers, called by the message handler for this process.
141 void OnUploadProgress( 157 void OnUploadProgress(int request_id, int64 position, int64 size);
142 int request_id,
143 int64 position,
144 int64 size);
145 void OnReceivedResponse(int request_id, const ResourceResponseHead&); 158 void OnReceivedResponse(int request_id, const ResourceResponseHead&);
146 void OnReceivedCachedMetadata(int request_id, const std::vector<char>& data); 159 void OnReceivedCachedMetadata(int request_id, const std::vector<char>& data);
147 void OnReceivedRedirect( 160 void OnReceivedRedirect(int request_id,
148 int request_id, 161 const GURL& new_url,
149 const GURL& new_url, 162 const ResourceResponseHead& response_head);
150 const ResourceResponseHead& response_head); 163 void OnSetDataBuffer(int request_id,
151 void OnSetDataBuffer( 164 base::SharedMemoryHandle shm_handle,
152 int request_id, 165 int shm_size,
153 base::SharedMemoryHandle shm_handle, 166 base::ProcessId renderer_pid);
154 int shm_size, 167 void OnReceivedData(int request_id,
155 base::ProcessId renderer_pid); 168 int data_offset,
156 void OnReceivedData( 169 int data_length,
157 int request_id, 170 int encoded_data_length);
158 int data_offset, 171 void OnDownloadedData(int request_id, int data_len, int encoded_data_length);
159 int data_length,
160 int encoded_data_length);
161 void OnDownloadedData(
162 int request_id,
163 int data_len,
164 int encoded_data_length);
165 void OnRequestComplete( 172 void OnRequestComplete(
166 int request_id, 173 int request_id,
167 const ResourceMsg_RequestCompleteData &request_complete_data); 174 const ResourceMsg_RequestCompleteData& request_complete_data);
168 175
169 // Dispatch the message to one of the message response handlers. 176 // Dispatch the message to one of the message response handlers.
170 void DispatchMessage(const IPC::Message& message); 177 void DispatchMessage(const IPC::Message& message);
171 178
172 // Dispatch any deferred messages for the given request, provided it is not 179 // Dispatch any deferred messages for the given request, provided it is not
173 // again in the deferred state. 180 // again in the deferred state.
174 void FlushDeferredMessages(int request_id); 181 void FlushDeferredMessages(int request_id);
175 182
176 void ToResourceResponseInfo( 183 void ToResourceResponseInfo(
177 const PendingRequestInfo& request_info, 184 const PendingRequestInfo& request_info,
(...skipping 16 matching lines...) Expand all
194 // handle in it that we should cleanup it up nicely. This method accepts any 201 // handle in it that we should cleanup it up nicely. This method accepts any
195 // message and determine whether the message is 202 // message and determine whether the message is
196 // ViewHostMsg_Resource_DataReceived and clean up the shared memory handle. 203 // ViewHostMsg_Resource_DataReceived and clean up the shared memory handle.
197 static void ReleaseResourcesInDataMessage(const IPC::Message& message); 204 static void ReleaseResourcesInDataMessage(const IPC::Message& message);
198 205
199 // Iterate through a message queue and clean up the messages by calling 206 // Iterate through a message queue and clean up the messages by calling
200 // ReleaseResourcesInDataMessage and removing them from the queue. Intended 207 // ReleaseResourcesInDataMessage and removing them from the queue. Intended
201 // for use on deferred message queues that are no longer needed. 208 // for use on deferred message queues that are no longer needed.
202 static void ReleaseResourcesInMessageQueue(MessageQueue* queue); 209 static void ReleaseResourcesInMessageQueue(MessageQueue* queue);
203 210
211 scoped_ptr<ResourceHostMsg_Request> CreateRequest(
212 const RequestInfo& request_info,
213 ResourceRequestBody* request_body,
214 GURL* frame_origin);
215
204 IPC::Sender* message_sender_; 216 IPC::Sender* message_sender_;
205 217
206 // All pending requests issued to the host 218 // All pending requests issued to the host
207 PendingRequestList pending_requests_; 219 PendingRequestList pending_requests_;
208 220
209 base::WeakPtrFactory<ResourceDispatcher> weak_factory_; 221 base::WeakPtrFactory<ResourceDispatcher> weak_factory_;
210 222
211 ResourceDispatcherDelegate* delegate_; 223 ResourceDispatcherDelegate* delegate_;
212 224
213 // IO thread timestamp for ongoing IPC message. 225 // IO thread timestamp for ongoing IPC message.
214 base::TimeTicks io_timestamp_; 226 base::TimeTicks io_timestamp_;
215 227
216 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher); 228 DISALLOW_COPY_AND_ASSIGN(ResourceDispatcher);
217 }; 229 };
218 230
219 } // namespace content 231 } // namespace content
220 232
221 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_ 233 #endif // CONTENT_CHILD_RESOURCE_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698