Chromium Code Reviews| Index: content/public/child/request_peer.h |
| diff --git a/content/public/child/request_peer.h b/content/public/child/request_peer.h |
| index dfa7a7417ea3d9a6ad36c979fa3b60b1c1e305dd..17145ba0b9e1a331e068e1e5e9719155113bcd04 100644 |
| --- a/content/public/child/request_peer.h |
| +++ b/content/public/child/request_peer.h |
| @@ -6,8 +6,10 @@ |
| #define CONTENT_PUBLIC_CHILD_REQUEST_PEER_H_ |
| #include <string> |
| +#include <vector> |
| #include "base/basictypes.h" |
| +#include "base/memory/scoped_ptr.h" |
| #include "content/common/content_export.h" |
| class GURL; |
| @@ -33,6 +35,42 @@ struct ResourceResponseInfo; |
| // for more information. |
| class CONTENT_EXPORT RequestPeer { |
| public: |
| + // This class represents data gotten from the Browser process. Each data |
| + // consists of |payload|, |length| and |encoded_length|. The payload is |
| + // valid only when the data instance is valid. |
| + // In order to work with Chrome resource loading IPC, it is desirable to |
| + // reclaim data in FIFO order in a RequestPeer in terms of performance. |
| + // |payload|, |length| and |encoded_length| functions are thread-safe, but |
| + // the data object itself must be destroyed on the original thread. |
| + class CONTENT_EXPORT ReceivedData { |
| + public: |
| + virtual ~ReceivedData() {} |
| + virtual const char* payload() const = 0; |
| + virtual int length() const = 0; |
| + // The encoded_length is the length of the encoded data transferred |
| + // over the network, which could be different from data length (e.g. for |
| + // gzipped content). |
| + virtual int encoded_length() const = 0; |
| + }; |
| + |
| + class CONTENT_EXPORT FixedReceivedData final : public ReceivedData { |
|
jochen (gone - plz use gerrit)
2015/06/01 13:08:28
hum, that looks a bit odd, maybe content/public/ch
yhirano
2015/06/02 02:08:47
Done.
|
| + public: |
| + FixedReceivedData(const char* data, size_t length, int encoded_length); |
| + FixedReceivedData(scoped_ptr<ReceivedData> data); |
| + FixedReceivedData(const std::vector<char>& data, int encoded_length); |
| + ~FixedReceivedData() override; |
| + |
| + const char* payload() const override; |
| + int length() const override; |
| + int encoded_length() const override; |
| + |
| + private: |
| + std::vector<char> data_; |
| + int encoded_length_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(FixedReceivedData); |
| + }; |
| + |
| // Called as upload progress is made. |
| // note: only for requests with upload progress enabled. |
| virtual void OnUploadProgress(uint64 position, uint64 size) = 0; |
| @@ -59,12 +97,7 @@ class CONTENT_EXPORT RequestPeer { |
| // Called when a chunk of response data is available. This method may |
| // be called multiple times or not at all if an error occurs. |
| - // The encoded_data_length is the length of the encoded data transferred |
| - // over the network, which could be different from data length (e.g. for |
| - // gzipped content). |
| - virtual void OnReceivedData(const char* data, |
| - int data_length, |
| - int encoded_data_length) = 0; |
| + virtual void OnReceivedData(scoped_ptr<ReceivedData> data) = 0; |
| // Called when metadata generated by the renderer is retrieved from the |
| // cache. This method may be called zero or one times. |