| Index: net/base/upload_data.h
|
| diff --git a/net/base/upload_data.h b/net/base/upload_data.h
|
| index d42ffad16352f8e7be97fc08f0b8f8440af87d44..a7f3d34da61e2d17bd3ce8a8928a15ef44171dc9 100644
|
| --- a/net/base/upload_data.h
|
| +++ b/net/base/upload_data.h
|
| @@ -110,13 +110,31 @@ class NET_EXPORT UploadData : public base::RefCounted<UploadData> {
|
| // is returned. This is done for consistency with Mozilla.
|
| uint64 GetContentLength();
|
|
|
| - // Returns a FileStream opened for reading for this element, positioned at
|
| - // |file_range_offset_|. The caller gets ownership and is responsible
|
| - // for cleaning up the FileStream. Returns NULL if this element is not of
|
| - // type TYPE_FILE or if the file is not openable.
|
| - FileStream* NewFileStreamForReading();
|
| + // Reads up to |buf_len| bytes synchronously. Returns the number of bytes
|
| + // read. This function never fails. If there's less data to read than we
|
| + // initially observed, then pad with zero (this can happen with files).
|
| + // |buf_len| must be greater than 0.
|
| + int ReadSync(char* buf, int buf_len);
|
| +
|
| + // Returns the number of bytes remaining to read.
|
| + uint64 BytesRemaining();
|
| +
|
| + // Resets the offset to zero, so that the element can be reread.
|
| + void ResetOffset() { offset_ = 0; }
|
|
|
| private:
|
| + // Returns a FileStream opened for reading for this element, positioned
|
| + // at |file_range_offset_|. Returns NULL if the file is not openable.
|
| + FileStream* OpenFileStream();
|
| +
|
| + // Reads up to |buf_len| bytes synchronously from memory (i.e. type_ is
|
| + // TYPE_BYTES or TYPE_CHUNK).
|
| + int ReadFromMemorySync(char* buf, int buf_len);
|
| +
|
| + // Reads up to |buf_len| bytes synchronously from a file (i.e. type_ is
|
| + // TYPE_FILE).
|
| + int ReadFromFileSync(char* buf, int buf_len);
|
| +
|
| // Allows tests to override the result of GetContentLength.
|
| void SetContentLength(uint64 content_length) {
|
| override_content_length_ = true;
|
| @@ -134,6 +152,12 @@ class NET_EXPORT UploadData : public base::RefCounted<UploadData> {
|
| bool override_content_length_;
|
| bool content_length_computed_;
|
| uint64 content_length_;
|
| +
|
| + // The byte offset from the beginning of the element data. Used to track
|
| + // the current position when reading data.
|
| + size_t offset_;
|
| +
|
| + // The stream of the element data, if this element is of TYPE_FILE.
|
| FileStream* file_stream_;
|
|
|
| FRIEND_TEST_ALL_PREFIXES(UploadDataStreamTest, FileSmallerThanLength);
|
| @@ -180,6 +204,11 @@ class NET_EXPORT UploadData : public base::RefCounted<UploadData> {
|
| // upload data is not chunked, and all elemnts are of TYPE_BYTES).
|
| bool IsInMemory() const;
|
|
|
| + // Resets the offset of each upload data element to zero, so that the
|
| + // upload data can be reread. This can happen if the same upload data is
|
| + // reused for a new UploadDataStream.
|
| + void ResetOffset();
|
| +
|
| std::vector<Element>* elements() {
|
| return &elements_;
|
| }
|
|
|