summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorsatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 00:30:51 +0000
committersatorux@chromium.org <satorux@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-19 00:30:51 +0000
commit3bf8471bcb1ff95660f7dda324ab0ad2d00a8abe (patch)
tree2c583aa47d79b83db9a36da256e878e0fc1a4f33 /net/http
parent3020ca91c71f72c54de74cbd3fd7ef3f9023cc67 (diff)
downloadchromium_src-3bf8471bcb1ff95660f7dda324ab0ad2d00a8abe.zip
chromium_src-3bf8471bcb1ff95660f7dda324ab0ad2d00a8abe.tar.gz
chromium_src-3bf8471bcb1ff95660f7dda324ab0ad2d00a8abe.tar.bz2
Add comments to HttpStreamParser::DoSendBody().
This function is relatively complex. Add comments to clarify what this function does. Will clean up the code in a separate patch. BUG=72001 TEST=chrome and tests build as before. Review URL: http://codereview.chromium.org/9213018 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@118193 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_stream_parser.cc12
1 files changed, 10 insertions, 2 deletions
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index 64248ff..5277780 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -327,9 +327,13 @@ int HttpStreamParser::DoSendHeaders(int result) {
}
int HttpStreamParser::DoSendBody(int result) {
+ // |result| is the number of bytes sent from the last call to
+ // DoSendBody(), or 0 (i.e. OK) the first time.
+
if (request_body_->is_chunked()) {
chunk_length_ -= result;
if (chunk_length_) {
+ // Move the remaining data in the chunk buffer to the beginning.
memmove(chunk_buf_->data(), chunk_buf_->data() + result, chunk_length_);
return connection_->socket()->Write(chunk_buf_, chunk_length_,
io_callback_);
@@ -340,6 +344,8 @@ int HttpStreamParser::DoSendBody(int result) {
return OK;
}
+ // |chunk_length_without_encoding_| is 0 when DoSendBody() is first
+ // called, hence the first call to MarkConsumedAndFillBuffer() is a noop.
request_body_->MarkConsumedAndFillBuffer(chunk_length_without_encoding_);
chunk_length_without_encoding_ = 0;
chunk_length_ = 0;
@@ -363,7 +369,7 @@ int HttpStreamParser::DoSendBody(int result) {
chunk_length_ = chunk_header.length() + buf_len + 2;
}
- if (!chunk_length_) // More POST data is yet to come?
+ if (!chunk_length_) // chunk_buf_ is empty. More POST data is yet to come?
return ERR_IO_PENDING;
return connection_->socket()->Write(chunk_buf_, chunk_length_,
@@ -371,6 +377,8 @@ int HttpStreamParser::DoSendBody(int result) {
}
// Non-chunked request body.
+
+ // The first call to MarkConsumedAndFillBuffer() is a noop as |result| is 0.
request_body_->MarkConsumedAndFillBuffer(result);
if (!request_body_->eof()) {