summaryrefslogtreecommitdiffstats
path: root/net/http
diff options
context:
space:
mode:
authorvandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-10 18:51:34 +0000
committervandebo@chromium.org <vandebo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-11-10 18:51:34 +0000
commit776e175577badb594cc9023f56b16480546c94ea (patch)
treed4159651d2165dd6bbfbdae51faa4ac77404f870 /net/http
parent62cf690a77564be902cf481803a9a7e3d52f7c55 (diff)
downloadchromium_src-776e175577badb594cc9023f56b16480546c94ea.zip
chromium_src-776e175577badb594cc9023f56b16480546c94ea.tar.gz
chromium_src-776e175577badb594cc9023f56b16480546c94ea.tar.bz2
After further discussion, do not try to handle memory errors, but make assertions about allocation parameters stronger.
BUG=25826 TEST=none Review URL: http://codereview.chromium.org/378037 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31574 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net/http')
-rw-r--r--net/http/http_stream_parser.cc18
1 files changed, 5 insertions, 13 deletions
diff --git a/net/http/http_stream_parser.cc b/net/http/http_stream_parser.cc
index b5394d7..ddf7663 100644
--- a/net/http/http_stream_parser.cc
+++ b/net/http/http_stream_parser.cc
@@ -208,10 +208,8 @@ int HttpStreamParser::DoReadHeaders() {
io_state_ = STATE_READ_HEADERS_COMPLETE;
// Grow the read buffer if necessary.
- if (read_buf_->RemainingCapacity() == 0) {
- if (!read_buf_->SetCapacity(read_buf_->capacity() + kHeaderBufInitialSize))
- return ERR_OUT_OF_MEMORY;
- }
+ if (read_buf_->RemainingCapacity() == 0)
+ read_buf_->SetCapacity(read_buf_->capacity() + kHeaderBufInitialSize);
// http://crbug.com/16371: We're seeing |user_buf_->data()| return NULL.
// See if the user is passing in an IOBuffer with a NULL |data_|.
@@ -302,7 +300,6 @@ int HttpStreamParser::DoReadHeadersComplete(int result) {
read_buf_->StartOfBuffer() + read_buf_unused_offset_,
extra_bytes);
}
- // Ok if this fails, since it only shrinks the buffer.
read_buf_->SetCapacity(extra_bytes);
read_buf_unused_offset_ = 0;
return OK;
@@ -386,16 +383,11 @@ int HttpStreamParser::DoReadBodyComplete(int result) {
if (result > 0)
result -= save_amount;
}
+
if (read_buf_->capacity() < save_amount + additional_save_amount) {
- if (!read_buf_->SetCapacity(save_amount + additional_save_amount)) {
- // This response is ok, but we weren't able to copy the extra data,
- // so close the connection so that it is not reused.
- connection_->socket()->Disconnect();
- connection_->Reset();
- read_buf_unused_offset_ = -1; // So that IsMoreDataBuffered works.
- return result;
- }
+ read_buf_->SetCapacity(save_amount + additional_save_amount);
}
+
if (save_amount) {
memcpy(read_buf_->StartOfBuffer(), user_read_buf_->data() + result,
save_amount);