Index: net/base/upload_data.h |
diff --git a/net/base/upload_data.h b/net/base/upload_data.h |
index d42ffad16352f8e7be97fc08f0b8f8440af87d44..02e07ee46fedebc2927907f6610e9a3b5af789a6 100644 |
--- a/net/base/upload_data.h |
+++ b/net/base/upload_data.h |
@@ -110,13 +110,27 @@ 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). |
+ int ReadSync(char* buf, int buf_len); |
+ |
+ // Returns the number of bytes remaining to read. |
+ uint64 BytesRemaining(); |
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 +148,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); |