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

Unified Diff: net/http/http_response_body_drainer.cc

Issue 8591037: Implement Drain() on HttpPipelinedStream. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Skip on unusable Created 9 years, 1 month 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
« no previous file with comments | « net/http/http_response_body_drainer.h ('k') | net/http/http_response_body_drainer_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..bbd27276b1711dafa2b7f12ba563ff454255fe5e 100644
--- a/net/http/http_response_body_drainer.cc
+++ b/net/http/http_response_body_drainer.cc
@@ -25,7 +25,25 @@ 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);
+ // TODO(simonjam): Consider raising this limit if we're pipelining. If we have
+ // a bunch of responses in the pipeline, we should be less willing to give up
+ // while draining.
+ if (num_bytes_to_drain > kDrainBodyBufferSize) {
+ 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 +89,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_);
}
« no previous file with comments | « net/http/http_response_body_drainer.h ('k') | net/http/http_response_body_drainer_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698