diff options
| author | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 17:53:22 +0000 |
|---|---|---|
| committer | satish@chromium.org <satish@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-03-04 17:53:22 +0000 |
| commit | 0c9bf87fe0b87849105fc7a2ea16280e48ee9089 (patch) | |
| tree | 8858b7c1f6c1071b2a0f93a92c72f08dcb0ad96d /net/base/upload_data_stream.cc | |
| parent | 27030d8d5d54002e1baaf19fefd909ebfb82de40 (diff) | |
| download | chromium_src-0c9bf87fe0b87849105fc7a2ea16280e48ee9089.zip chromium_src-0c9bf87fe0b87849105fc7a2ea16280e48ee9089.tar.gz chromium_src-0c9bf87fe0b87849105fc7a2ea16280e48ee9089.tar.bz2 | |
Add chunked uploads support to SPDY
As part of this, I had to move the chunked encoding part from UploadData::Element::SetChunk
to HttpStreamParser::DoSendBody as SPDY doesn't have this encoded format and UploadData
needs to serve both.
BUG=none
TEST=net_unittests (2 new tests added)
Committed and rolled back: http://src.chromium.org/viewvc/chrome?view=rev&revision=76892
Review URL: http://codereview.chromium.org/6292013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@76930 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/base/upload_data_stream.cc')
| -rw-r--r-- | net/base/upload_data_stream.cc | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/net/base/upload_data_stream.cc b/net/base/upload_data_stream.cc index 9f7bdbb..4a056f4 100644 --- a/net/base/upload_data_stream.cc +++ b/net/base/upload_data_stream.cc @@ -12,6 +12,8 @@ namespace net { +bool UploadDataStream::merge_chunks_ = true; + UploadDataStream::~UploadDataStream() { } @@ -69,8 +71,13 @@ int UploadDataStream::FillBuf() { size_t bytes_copied = std::min(count, size_remaining); - memcpy(buf_->data() + buf_len_, &d[next_element_offset_], bytes_copied); - buf_len_ += bytes_copied; + // Check if we have anything to copy first, because we are getting the + // address of an element in |d| and that will throw an exception if |d| + // is an empty vector. + if (bytes_copied) { + memcpy(buf_->data() + buf_len_, &d[next_element_offset_], bytes_copied); + buf_len_ += bytes_copied; + } if (bytes_copied == count) { advance_to_next_element = true; @@ -126,6 +133,9 @@ int UploadDataStream::FillBuf() { next_element_remaining_ = 0; next_element_stream_.reset(); } + + if (is_chunked() && !merge_chunks_) + break; } if (next_element_ == elements.size() && !buf_len_) { @@ -138,4 +148,13 @@ int UploadDataStream::FillBuf() { return OK; } +bool UploadDataStream::IsOnLastChunk() const { + const std::vector<UploadData::Element>& elements = *data_->elements(); + DCHECK(data_->is_chunked()); + return (eof_ || + (!elements.empty() && + next_element_ == elements.size() && + elements.back().is_last_chunk())); +} + } // namespace net |
