diff options
author | wtc@google.com <wtc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-05 21:30:51 +0000 |
---|---|---|
committer | wtc@google.com <wtc@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-05 21:30:51 +0000 |
commit | 372d34ad3c42a5b752fecc8def532674dfc64ead (patch) | |
tree | 82f6bd55f2e54f5da6e4e19598ea3370a1285170 /net/base | |
parent | 400f538f3a1cd36dca3a20fdac57f2f42e5b4958 (diff) | |
download | chromium_src-372d34ad3c42a5b752fecc8def532674dfc64ead.zip chromium_src-372d34ad3c42a5b752fecc8def532674dfc64ead.tar.gz chromium_src-372d34ad3c42a5b752fecc8def532674dfc64ead.tar.bz2 |
Remove the UploadDataStream::Reset method. Instead,
rewind an UploadDataStream by recreating the object.
Fix a bug in MockTCPClientSocket::Write. It needs to
increment write_index_. Add two DCHECKs to simulate
the DCHECKS in SSLClientSocketWin::DoPayloadEncrypt.
Add a unit test.
R=darin,eroman
BUG=4062
Review URL: http://codereview.chromium.org/9384
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@4819 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base')
-rw-r--r-- | net/base/upload_data_stream.cc | 19 | ||||
-rw-r--r-- | net/base/upload_data_stream.h | 5 |
2 files changed, 8 insertions, 16 deletions
diff --git a/net/base/upload_data_stream.cc b/net/base/upload_data_stream.cc index e874439..c25ccba 100644 --- a/net/base/upload_data_stream.cc +++ b/net/base/upload_data_stream.cc @@ -11,8 +11,12 @@ namespace net { UploadDataStream::UploadDataStream(const UploadData* data) : data_(data), - total_size_(data->GetContentLength()) { - Reset(); + buf_len_(0), + next_element_(data->elements().begin()), + next_element_offset_(0), + next_element_remaining_(0), + total_size_(data->GetContentLength()), + current_position_(0) { FillBuf(); } @@ -31,15 +35,6 @@ void UploadDataStream::DidConsume(size_t num_bytes) { current_position_ += num_bytes; } -void UploadDataStream::Reset() { - next_element_stream_.Close(); - buf_len_ = 0; - next_element_ = data_->elements().begin(); - next_element_offset_ = 0; - next_element_remaining_ = 0; - current_position_ = 0; -} - void UploadDataStream::FillBuf() { std::vector<UploadData::Element>::const_iterator end = data_->elements().end(); @@ -68,7 +63,7 @@ void UploadDataStream::FillBuf() { DCHECK(element.type() == UploadData::TYPE_FILE); if (!next_element_stream_.IsOpen()) { - int flags = base::PLATFORM_FILE_OPEN | + int flags = base::PLATFORM_FILE_OPEN | base::PLATFORM_FILE_READ; int rv = next_element_stream_.Open(element.file_path(), flags); // If the file does not exist, that's technically okay.. we'll just diff --git a/net/base/upload_data_stream.h b/net/base/upload_data_stream.h index 7c2bb6d..c7dc2f1 100644 --- a/net/base/upload_data_stream.h +++ b/net/base/upload_data_stream.h @@ -12,7 +12,7 @@ namespace net { class UploadDataStream { public: - UploadDataStream(const UploadData* data); + explicit UploadDataStream(const UploadData* data); ~UploadDataStream(); // Returns the stream's buffer and buffer length. @@ -24,9 +24,6 @@ class UploadDataStream { // the upload data to be consumed. void DidConsume(size_t num_bytes); - // Call to reset the stream position to the beginning. - void Reset(); - // Returns the total size of the data stream and the current position. uint64 size() const { return total_size_; } uint64 position() const { return current_position_; } |