Chromium Code Reviews| Index: net/base/upload_data_stream.h |
| diff --git a/net/base/upload_data_stream.h b/net/base/upload_data_stream.h |
| index 0d179d217bcfdd80c8d0915c84268e5fda856167..382f3d8f9f452e37fcf520cd49a648ba7cd2769e 100644 |
| --- a/net/base/upload_data_stream.h |
| +++ b/net/base/upload_data_stream.h |
| @@ -7,6 +7,7 @@ |
| #pragma once |
| #include "base/scoped_ptr.h" |
| +#include "net/base/completion_callback.h" |
| #include "net/base/upload_data.h" |
| namespace net { |
| @@ -32,6 +33,9 @@ class UploadDataStream { |
| // the upload data to be consumed. |
| void DidConsume(size_t num_bytes); |
| + // Sets the callback to be invoked when new data is available to upload. |
| + void set_data_callback(CompletionCallback* callback); |
| + |
| // Returns the total size of the data stream and the current position. |
| // size() is not to be used to determine whether the stream has ended |
| // because it is possible for the stream to end before its size is reached, |
| @@ -39,15 +43,22 @@ class UploadDataStream { |
| uint64 size() const { return total_size_; } |
| uint64 position() const { return current_position_; } |
| + bool is_chunked() const { return data_->is_chunked(); } |
| + |
| // Returns whether there is no more data to read, regardless of whether |
| // position < size. |
| bool eof() const { return eof_; } |
| + bool waiting_for_data() const { return waiting_for_data_; } |
|
wtc
2011/01/12 02:39:02
It seems that we don't need to add a waiting_for_d
Satish
2011/01/13 17:43:27
Done.
|
| + |
| private: |
| // Protects from public access since now we have a static creator function |
| // which will do both creation and initialization and might return an error. |
| explicit UploadDataStream(UploadData* data); |
| + // Callback invoked by UploadData when new data is available. |
| + void OnDataAvailable(int result); |
| + |
| // Fills the buffer with any remaining data and sets eof_ if there was nothing |
| // left to fill the buffer with. |
| // Returns OK if the operation succeeds. Otherwise error code is returned. |
| @@ -63,8 +74,8 @@ class UploadDataStream { |
| scoped_refptr<IOBuffer> buf_; |
| size_t buf_len_; |
| - // Iterator to the upload element to be written to the send buffer next. |
| - std::vector<UploadData::Element>::iterator next_element_; |
| + // Index of the upload element to be written to the send buffer next. |
| + size_t next_element_; |
| // The byte offset into next_element_'s data buffer if the next element is |
| // a TYPE_BYTES element. |
| @@ -82,6 +93,14 @@ class UploadDataStream { |
| uint64 total_size_; |
| uint64 current_position_; |
| + // Whether we have run out of data and waiting for more to come in. |
| + bool waiting_for_data_; |
| + |
| + // Callback invoked by UploadData when new data is available. |
| + CompletionCallbackImpl<UploadDataStream> upload_data_callback_; |
| + // Callback to be invoked by us when new data is available. |
| + CompletionCallback* data_callback_; |
| + |
| // Whether there is no data left to read. |
| bool eof_; |