Chromium Code Reviews| Index: content/child/resource_dispatcher.h |
| diff --git a/content/child/resource_dispatcher.h b/content/child/resource_dispatcher.h |
| index 5aabbd4e91880d1c35a25252f5b8c093fe1c2522..7cd050092e763b01a00a0caadb357e8bcffce2ca 100644 |
| --- a/content/child/resource_dispatcher.h |
| +++ b/content/child/resource_dispatcher.h |
| @@ -12,6 +12,7 @@ |
| #include "base/containers/hash_tables.h" |
| #include "base/memory/linked_ptr.h" |
| +#include "base/memory/scoped_ptr.h" |
| #include "base/memory/shared_memory.h" |
| #include "base/memory/weak_ptr.h" |
| #include "base/time/time.h" |
| @@ -21,6 +22,7 @@ |
| #include "net/base/request_priority.h" |
| #include "webkit/common/resource_type.h" |
| +struct ResourceHostMsg_Request; |
| struct ResourceMsg_RequestCompleteData; |
| namespace webkit_glue { |
| @@ -31,9 +33,11 @@ struct ResourceResponseInfo; |
| namespace content { |
| class RequestPeer; |
| class ResourceDispatcherDelegate; |
| +class ResourceRequestBody; |
| struct RequestInfo; |
| struct ResourceResponseHead; |
| struct SiteIsolationResponseMetaData; |
| +struct SyncLoadResponse; |
| // This class serves as a communication interface between the |
| // ResourceDispatcherHost in the browser process and the ResourceLoaderBridge in |
| @@ -46,11 +50,40 @@ class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { |
| // IPC::Listener implementation. |
| virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| - // Creates a ResourceLoaderBridge for this type of dispatcher, this is so |
| - // this can be tested regardless of the ResourceLoaderBridge::Create |
| - // implementation. |
| - webkit_glue::ResourceLoaderBridge* CreateBridge( |
| - const RequestInfo& request_info); |
| + void CreateBridge(const RequestInfo& request_info); |
|
tfarina
2014/04/11 03:00:53
I forgot to ask. John, do you have a better name f
|
| + |
| + // Call this method before calling Start() to set the request body. |
| + // May only be used with HTTP(S) POST requests. |
| + void SetRequestBody(ResourceRequestBody* request_body); |
| + |
| + // Call this method to initiate the request. If this method succeeds, then |
| + // the peer's methods will be called asynchronously to report various events. |
| + bool Start(RequestPeer* peer); |
| + |
| + // Call this method to cancel a request that is in progress. This method |
| + // causes the request to immediately transition into the 'done' state. The |
| + // OnCompletedRequest method will be called asynchronously; this assumes |
| + // the peer is still valid. |
| + void Cancel(); |
| + |
| + // Call this method to suspend or resume a load that is in progress. This |
| + // method may only be called after a successful call to the Start method. |
| + void SetDefersLoading(bool value); |
| + |
| + // Call this method when the priority of the requested resource changes after |
| + // Start() has been called. This method may only be called after a successful |
| + // call to the Start method. |
| + void DidChangePriority(net::RequestPriority new_priority, |
| + int intra_priority_value); |
| + |
| + // Call this method to load the resource synchronously (i.e., in one shot). |
| + // This is an alternative to the Start method. Be warned that this method |
| + // will block the calling thread until the resource is fully downloaded or an |
| + // error occurs. It could block the calling thread for a long time, so only |
| + // use this if you really need it! There is also no way for the caller to |
| + // interrupt this method. Errors are reported via the status field of the |
| + // response parameter. |
| + void SyncLoad(SyncLoadResponse* response); |
| // Adds a request from the pending_requests_ list, returning the new |
| // requests' ID |
| @@ -138,33 +171,24 @@ class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { |
| void FollowPendingRedirect(int request_id, PendingRequestInfo& request_info); |
| // Message response handlers, called by the message handler for this process. |
| - void OnUploadProgress( |
| - int request_id, |
| - int64 position, |
| - int64 size); |
| + void OnUploadProgress(int request_id, int64 position, int64 size); |
| void OnReceivedResponse(int request_id, const ResourceResponseHead&); |
| void OnReceivedCachedMetadata(int request_id, const std::vector<char>& data); |
| - void OnReceivedRedirect( |
| - int request_id, |
| - const GURL& new_url, |
| - const ResourceResponseHead& response_head); |
| - void OnSetDataBuffer( |
| - int request_id, |
| - base::SharedMemoryHandle shm_handle, |
| - int shm_size, |
| - base::ProcessId renderer_pid); |
| - void OnReceivedData( |
| - int request_id, |
| - int data_offset, |
| - int data_length, |
| - int encoded_data_length); |
| - void OnDownloadedData( |
| - int request_id, |
| - int data_len, |
| - int encoded_data_length); |
| + void OnReceivedRedirect(int request_id, |
| + const GURL& new_url, |
| + const ResourceResponseHead& response_head); |
| + void OnSetDataBuffer(int request_id, |
| + base::SharedMemoryHandle shm_handle, |
| + int shm_size, |
| + base::ProcessId renderer_pid); |
| + void OnReceivedData(int request_id, |
| + int data_offset, |
| + int data_length, |
| + int encoded_data_length); |
| + void OnDownloadedData(int request_id, int data_len, int encoded_data_length); |
| void OnRequestComplete( |
| int request_id, |
| - const ResourceMsg_RequestCompleteData &request_complete_data); |
| + const ResourceMsg_RequestCompleteData& request_complete_data); |
| // Dispatch the message to one of the message response handlers. |
| void DispatchMessage(const IPC::Message& message); |
| @@ -206,6 +230,21 @@ class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { |
| // All pending requests issued to the host |
| PendingRequestList pending_requests_; |
| + scoped_ptr<ResourceHostMsg_Request> request_; |
| + |
| + RequestPeer* peer_; |
| + |
| + // ID for the request, valid once Start()ed, -1 if not valid yet. |
| + int request_id_; |
| + |
| + // The routing id used when sending IPC messages. |
| + int routing_id_; |
| + |
| + // The security origin of the frame that initiates this request. |
| + GURL frame_origin_; |
| + |
| + bool is_synchronous_request_; |
| + |
| base::WeakPtrFactory<ResourceDispatcher> weak_factory_; |
| ResourceDispatcherDelegate* delegate_; |