diff options
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/upload_data_stream.cc | 8 | ||||
-rw-r--r-- | net/base/upload_data_stream.h | 5 |
2 files changed, 8 insertions, 5 deletions
diff --git a/net/base/upload_data_stream.cc b/net/base/upload_data_stream.cc index 0a41a13..468ef6b 100644 --- a/net/base/upload_data_stream.cc +++ b/net/base/upload_data_stream.cc @@ -11,6 +11,7 @@ namespace net { UploadDataStream::UploadDataStream(const UploadData* data) : data_(data), + buf_(new IOBuffer(kBufSize)), buf_len_(0), next_element_(data->elements().begin()), next_element_offset_(0), @@ -28,7 +29,7 @@ void UploadDataStream::DidConsume(size_t num_bytes) { buf_len_ -= num_bytes; if (buf_len_) - memmove(buf_, buf_ + num_bytes, buf_len_); + memmove(buf_->data(), buf_->data() + num_bytes, buf_len_); FillBuf(); @@ -51,7 +52,7 @@ void UploadDataStream::FillBuf() { size_t bytes_copied = std::min(count, size_remaining); - memcpy(buf_ + buf_len_, &d[next_element_offset_], bytes_copied); + memcpy(buf_->data() + buf_len_, &d[next_element_offset_], bytes_copied); buf_len_ += bytes_copied; if (bytes_copied == count) { @@ -88,7 +89,8 @@ void UploadDataStream::FillBuf() { int count = static_cast<int>(std::min( static_cast<uint64>(size_remaining), next_element_remaining_)); if (count > 0 && - (rv = next_element_stream_.Read(buf_ + buf_len_, count, NULL)) > 0) { + (rv = next_element_stream_.Read(buf_->data() + buf_len_, + count, NULL)) > 0) { buf_len_ += rv; next_element_remaining_ -= rv; } else { diff --git a/net/base/upload_data_stream.h b/net/base/upload_data_stream.h index b39c550..e65d08b 100644 --- a/net/base/upload_data_stream.h +++ b/net/base/upload_data_stream.h @@ -6,6 +6,7 @@ #define NET_BASE_UPLOAD_DATA_STREAM_H_ #include "net/base/file_stream.h" +#include "net/base/io_buffer.h" #include "net/base/upload_data.h" namespace net { @@ -16,7 +17,7 @@ class UploadDataStream { ~UploadDataStream(); // Returns the stream's buffer and buffer length. - const char* buf() const { return buf_; } + IOBuffer* buf() const { return buf_; } size_t buf_len() const { return buf_len_; } // Call to indicate that a portion of the stream's buffer was consumed. This @@ -38,7 +39,7 @@ class UploadDataStream { // once, then we memmove the remaining portion and back-fill the buffer for // the next "write" call. buf_len_ indicates how much data is in the buffer. enum { kBufSize = 16384 }; - char buf_[kBufSize]; + scoped_refptr<IOBuffer> buf_; size_t buf_len_; // Iterator to the upload element to be written to the send buffer next. |