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..d859a8044b37c2d666fbef64e8ef2e43f687c31a 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,30 @@ 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); |
| + |
| + // Call this method to load the resource synchronously (i.e., in one shot). |
| + // This is an alternative to the StartAsync 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 StartSync(const RequestInfo& request_info, |
| + ResourceRequestBody* request_body, |
| + SyncLoadResponse* response); |
| + |
| + // Call this method to initiate the request. If this method succeeds, then |
| + // the peer's methods will be called asynchronously to report various events. |
| + // Returns the request id. |
| + int StartAsync(const RequestInfo& request_info, |
| + ResourceRequestBody* request_body, |
| + 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(int request_id); |
| // Adds a request from the pending_requests_ list, returning the new |
| // requests' ID |
| @@ -67,15 +90,14 @@ class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { |
| // Cancels a request in the pending_requests_ list. |
| void CancelPendingRequest(int request_id); |
| - IPC::Sender* message_sender() const { |
| - return message_sender_; |
| - } |
| + IPC::Sender* message_sender() const { return message_sender_; } |
| // Toggles the is_deferred attribute for the specified request. |
| void SetDefersLoading(int request_id, bool value); |
| // Indicates the priority of the specified request changed. |
| - void DidChangePriority(int routing_id, int request_id, |
| + void DidChangePriority(int routing_id, |
| + int request_id, |
| net::RequestPriority new_priority, |
| int intra_priority_value); |
| @@ -138,33 +160,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); |
| @@ -201,11 +214,24 @@ class CONTENT_EXPORT ResourceDispatcher : public IPC::Listener { |
| // for use on deferred message queues that are no longer needed. |
| static void ReleaseResourcesInMessageQueue(MessageQueue* queue); |
| + void CreateRequest(const RequestInfo& request_info, |
| + ResourceRequestBody* request_body); |
| + |
| IPC::Sender* message_sender_; |
| // All pending requests issued to the host |
| PendingRequestList pending_requests_; |
| + scoped_ptr<ResourceHostMsg_Request> request_; |
| + |
| + // ID for the request, valid once Start()ed, -1 if not valid yet. |
| + int request_id_; |
| + |
| + // The security origin of the frame that initiates this request. |
| + GURL frame_origin_; |
| + |
| + bool is_synchronous_request_; |
|
jam
2014/04/16 16:24:04
remove this entire section (see my second-last mes
|
| + |
| base::WeakPtrFactory<ResourceDispatcher> weak_factory_; |
| ResourceDispatcherDelegate* delegate_; |