| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/http/http_response_body_drainer.h" | 5 #include "net/http/http_response_body_drainer.h" |
| 6 | 6 |
| 7 #include "base/compiler_specific.h" | 7 #include "base/compiler_specific.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 HttpResponseBodyDrainer::~HttpResponseBodyDrainer() {} | 25 HttpResponseBodyDrainer::~HttpResponseBodyDrainer() {} |
| 26 | 26 |
| 27 void HttpResponseBodyDrainer::Start(HttpNetworkSession* session) { | 27 void HttpResponseBodyDrainer::Start(HttpNetworkSession* session) { |
| 28 read_buf_ = new IOBuffer(kDrainBodyBufferSize); | 28 read_buf_ = new IOBuffer(kDrainBodyBufferSize); |
| 29 next_state_ = STATE_DRAIN_RESPONSE_BODY; | 29 next_state_ = STATE_DRAIN_RESPONSE_BODY; |
| 30 int rv = DoLoop(OK); | 30 int rv = DoLoop(OK); |
| 31 | 31 |
| 32 if (rv == ERR_IO_PENDING) { | 32 if (rv == ERR_IO_PENDING) { |
| 33 timer_.Start(base::TimeDelta::FromSeconds(kTimeoutInSeconds), | 33 timer_.Start(base::TimeDelta::FromSeconds(kTimeoutInSeconds), |
| 34 this, | 34 this, |
| 35 &HttpResponseBodyDrainer::OnTimerFired); | 35 &HttpResponseBodyDrainer::OnTimerFired, |
| 36 FROM_HERE); |
| 36 session_ = session; | 37 session_ = session; |
| 37 session->AddResponseDrainer(this); | 38 session->AddResponseDrainer(this); |
| 38 return; | 39 return; |
| 39 } | 40 } |
| 40 | 41 |
| 41 Finish(rv); | 42 Finish(rv); |
| 42 } | 43 } |
| 43 | 44 |
| 44 int HttpResponseBodyDrainer::DoLoop(int result) { | 45 int HttpResponseBodyDrainer::DoLoop(int result) { |
| 45 DCHECK_NE(next_state_, STATE_NONE); | 46 DCHECK_NE(next_state_, STATE_NONE); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 stream_->Close(true /* no keep-alive */); | 118 stream_->Close(true /* no keep-alive */); |
| 118 } else { | 119 } else { |
| 119 DCHECK_EQ(OK, result); | 120 DCHECK_EQ(OK, result); |
| 120 stream_->Close(false /* keep-alive */); | 121 stream_->Close(false /* keep-alive */); |
| 121 } | 122 } |
| 122 | 123 |
| 123 delete this; | 124 delete this; |
| 124 } | 125 } |
| 125 | 126 |
| 126 } // namespace net | 127 } // namespace net |
| OLD | NEW |