Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Unified Diff: net/base/upload_data_stream.cc

Issue 6292013: Add chunked uploads support to SPDY (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: net/base/upload_data_stream.cc
diff --git a/net/base/upload_data_stream.cc b/net/base/upload_data_stream.cc
index 9f7bdbb419a28d63610b9235c0d5fcd9a6b5952e..2c4ee779f800add31b5c446b9affed01a8e7ad49 100644
--- a/net/base/upload_data_stream.cc
+++ b/net/base/upload_data_stream.cc
@@ -69,8 +69,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;
@@ -138,4 +143,14 @@ int UploadDataStream::FillBuf() {
return OK;
}
+bool UploadDataStream::peek_end_of_chunks() const {
willchan no longer on Chromium 2011/03/03 19:47:48 This is not a trivial accessor. Also, this may be
+ std::vector<UploadData::Element>& elements = *data_->elements();
willchan no longer on Chromium 2011/03/03 19:47:48 Can you get away with a const reference?
+ if (!data_->is_chunked())
willchan no longer on Chromium 2011/03/03 19:47:48 If this doesn't depend on |elements|, then how abo
+ return false;
+ return (eof_ ||
+ (!elements.empty() &&
+ next_element_ >= elements.size() - 1 &&
willchan no longer on Chromium 2011/03/03 19:47:48 I find |next_element_ > elements.size()| more read
Satish 2011/03/03 22:21:44 The condition could only be changed as "next_eleme
willchan no longer on Chromium 2011/03/03 22:26:54 Oops, missed that! Bleh, off by one =/
+ elements.back().is_last_chunk()));
+}
+
} // namespace net

Powered by Google App Engine
This is Rietveld 408576698