Chromium Code Reviews| Index: net/http/http_response_body_drainer.cc |
| diff --git a/net/http/http_response_body_drainer.cc b/net/http/http_response_body_drainer.cc |
| index aefb18026528f2b90307349fc153e15cbdd7d3c6..f137c2419a50d504c299db14b73a4dc723dc59eb 100644 |
| --- a/net/http/http_response_body_drainer.cc |
| +++ b/net/http/http_response_body_drainer.cc |
| @@ -25,7 +25,22 @@ HttpResponseBodyDrainer::HttpResponseBodyDrainer(HttpStream* stream) |
| HttpResponseBodyDrainer::~HttpResponseBodyDrainer() {} |
| void HttpResponseBodyDrainer::Start(HttpNetworkSession* session) { |
| - read_buf_ = new IOBuffer(kDrainBodyBufferSize); |
| + StartWithSize(session, kDrainBodyBufferSize); |
| +} |
| + |
| +void HttpResponseBodyDrainer::StartWithSize(HttpNetworkSession* session, |
| + int num_bytes_to_drain) { |
| + DCHECK_LE(0, num_bytes_to_drain); |
| + if (num_bytes_to_drain > kDrainBodyBufferSize) { |
|
mmenke
2011/11/28 18:39:10
Just thinking out loud: A larger minimum may be b
James Simonsen
2011/11/29 23:57:28
Good point. I added a TODO.
|
| + Finish(ERR_RESPONSE_BODY_TOO_BIG_TO_DRAIN); |
| + return; |
| + } else if (num_bytes_to_drain == 0) { |
| + Finish(OK); |
| + return; |
| + } |
| + |
| + read_size_ = num_bytes_to_drain; |
| + read_buf_ = new IOBuffer(read_size_); |
| next_state_ = STATE_DRAIN_RESPONSE_BODY; |
| int rv = DoLoop(OK); |
| @@ -71,7 +86,7 @@ int HttpResponseBodyDrainer::DoDrainResponseBody() { |
| next_state_ = STATE_DRAIN_RESPONSE_BODY_COMPLETE; |
| return stream_->ReadResponseBody( |
| - read_buf_, kDrainBodyBufferSize - total_read_, |
| + read_buf_, read_size_ - total_read_, |
| &io_callback_); |
| } |