OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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" |
11 #include "net/http/http_network_session.h" | 11 #include "net/http/http_network_session.h" |
12 #include "net/http/http_stream_base.h" | 12 #include "net/http/http_stream_base.h" |
13 | 13 |
14 namespace net { | 14 namespace net { |
15 | 15 |
16 HttpResponseBodyDrainer::HttpResponseBodyDrainer(HttpStreamBase* stream) | 16 HttpResponseBodyDrainer::HttpResponseBodyDrainer(HttpStreamBase* stream) |
17 : read_size_(0), | 17 : read_size_(0), |
18 stream_(stream), | 18 stream_(stream), |
19 next_state_(STATE_NONE), | 19 next_state_(STATE_NONE), |
20 total_read_(0), | 20 total_read_(0), |
21 session_(NULL) {} | 21 session_(NULL) { |
| 22 } |
22 | 23 |
23 HttpResponseBodyDrainer::~HttpResponseBodyDrainer() {} | 24 HttpResponseBodyDrainer::~HttpResponseBodyDrainer() { |
| 25 } |
24 | 26 |
25 void HttpResponseBodyDrainer::Start(HttpNetworkSession* session) { | 27 void HttpResponseBodyDrainer::Start(HttpNetworkSession* session) { |
26 StartWithSize(session, kDrainBodyBufferSize); | 28 StartWithSize(session, kDrainBodyBufferSize); |
27 } | 29 } |
28 | 30 |
29 void HttpResponseBodyDrainer::StartWithSize(HttpNetworkSession* session, | 31 void HttpResponseBodyDrainer::StartWithSize(HttpNetworkSession* session, |
30 int num_bytes_to_drain) { | 32 int num_bytes_to_drain) { |
31 DCHECK_LE(0, num_bytes_to_drain); | 33 DCHECK_LE(0, num_bytes_to_drain); |
32 // TODO(simonjam): Consider raising this limit if we're pipelining. If we have | 34 // TODO(simonjam): Consider raising this limit if we're pipelining. If we have |
33 // a bunch of responses in the pipeline, we should be less willing to give up | 35 // a bunch of responses in the pipeline, we should be less willing to give up |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 stream_->Close(true /* no keep-alive */); | 138 stream_->Close(true /* no keep-alive */); |
137 } else { | 139 } else { |
138 DCHECK_EQ(OK, result); | 140 DCHECK_EQ(OK, result); |
139 stream_->Close(false /* keep-alive */); | 141 stream_->Close(false /* keep-alive */); |
140 } | 142 } |
141 | 143 |
142 delete this; | 144 delete this; |
143 } | 145 } |
144 | 146 |
145 } // namespace net | 147 } // namespace net |
OLD | NEW |