| Index: net/base/upload_data_stream.h
|
| diff --git a/net/base/upload_data_stream.h b/net/base/upload_data_stream.h
|
| index 8679b2c9347a91bb945b3d5242234986e2f7144c..0b351e1d8eee85c4edd152f87320ef346eb66823 100644
|
| --- a/net/base/upload_data_stream.h
|
| +++ b/net/base/upload_data_stream.h
|
| @@ -39,10 +39,11 @@ class NET_EXPORT UploadDataStream {
|
| // Use this method only in tests and Chrome Frame.
|
| int InitSync();
|
|
|
| - // Reads up to |buf_len| bytes from the upload data stream to |buf|. The
|
| - // number of bytes read is returned. Partial reads are allowed. Zero is
|
| - // returned on a call to Read when there are no remaining bytes in the
|
| - // stream, and IsEof() will return true hereafter.
|
| + // Reads up to |buf_len| bytes synchronously from the upload data stream to
|
| + // |buf| and returns the number of bytes read when possible, otherwise,
|
| + // returns ERR_IO_PENDING and calls |callback| with the result. Partial reads
|
| + // are allowed. Zero is returned on a call to Read when there are no
|
| + // remaining bytes in the stream, and IsEof() will return true hereafter.
|
| //
|
| // If there's less data to read than we initially observed (i.e. the actual
|
| // upload data is smaller than size()), zeros are padded to ensure that
|
| @@ -50,9 +51,12 @@ class NET_EXPORT UploadDataStream {
|
| //
|
| // If the upload data stream is chunked (i.e. is_chunked() is true),
|
| // ERR_IO_PENDING is returned to indicate there is nothing to read at the
|
| - // moment, but more data to come at a later time. If not chunked, reads
|
| - // won't fail.
|
| - int Read(IOBuffer* buf, int buf_len);
|
| + // moment, but more data to come at a later time.
|
| + int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback);
|
| +
|
| + // Reads data always synchronously.
|
| + // Use this method only in tests and Chrome Frame.
|
| + int ReadSync(IOBuffer* buf, int buf_len);
|
|
|
| // Sets the callback to be invoked when new chunks are available to upload.
|
| void set_chunk_callback(ChunkCallback* callback) {
|
| @@ -86,6 +90,7 @@ class NET_EXPORT UploadDataStream {
|
| FRIEND_TEST_ALL_PREFIXES(UploadDataStreamTest, InitAsync);
|
| FRIEND_TEST_ALL_PREFIXES(UploadDataStreamTest, InitAsyncFailureAsync);
|
| FRIEND_TEST_ALL_PREFIXES(UploadDataStreamTest, InitAsyncFailureSync);
|
| + FRIEND_TEST_ALL_PREFIXES(UploadDataStreamTest, ReadAsync);
|
|
|
| // Runs Init() for all element readers.
|
| // This method is used to implement Init().
|
| @@ -97,6 +102,14 @@ class NET_EXPORT UploadDataStream {
|
| // This method is used to implement Init().
|
| void FinalizeInitialization();
|
|
|
| + // Reads data from the element readers.
|
| + // This method is used to implement Read().
|
| + void ReadInternal(scoped_refptr<IOBuffer> buf,
|
| + int buf_len,
|
| + int bytes_copied,
|
| + const CompletionCallback& callback,
|
| + int previous_result);
|
| +
|
| // These methods are provided only to be used by unit tests.
|
| static void ResetMergeChunks();
|
| static void set_merge_chunks(bool merge) { merge_chunks_ = merge; }
|
|
|