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" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 base::Bind(&HttpResponseBodyDrainer::OnIOComplete, | 91 base::Bind(&HttpResponseBodyDrainer::OnIOComplete, |
92 base::Unretained(this))); | 92 base::Unretained(this))); |
93 } | 93 } |
94 | 94 |
95 int HttpResponseBodyDrainer::DoDrainResponseBodyComplete(int result) { | 95 int HttpResponseBodyDrainer::DoDrainResponseBodyComplete(int result) { |
96 DCHECK_NE(ERR_IO_PENDING, result); | 96 DCHECK_NE(ERR_IO_PENDING, result); |
97 | 97 |
98 if (result < 0) | 98 if (result < 0) |
99 return result; | 99 return result; |
100 | 100 |
101 if (result == 0) | |
102 return ERR_CONNECTION_CLOSED; | |
103 | |
104 total_read_ += result; | 101 total_read_ += result; |
105 if (stream_->IsResponseBodyComplete()) | 102 if (stream_->IsResponseBodyComplete()) |
106 return OK; | 103 return OK; |
107 | 104 |
108 DCHECK_LE(total_read_, kDrainBodyBufferSize); | 105 DCHECK_LE(total_read_, kDrainBodyBufferSize); |
109 if (total_read_ >= kDrainBodyBufferSize) | 106 if (total_read_ >= kDrainBodyBufferSize) |
110 return ERR_RESPONSE_BODY_TOO_BIG_TO_DRAIN; | 107 return ERR_RESPONSE_BODY_TOO_BIG_TO_DRAIN; |
111 | 108 |
112 next_state_ = STATE_DRAIN_RESPONSE_BODY; | 109 next_state_ = STATE_DRAIN_RESPONSE_BODY; |
113 return OK; | 110 return OK; |
(...skipping 21 matching lines...) Expand all Loading... |
135 stream_->Close(true /* no keep-alive */); | 132 stream_->Close(true /* no keep-alive */); |
136 } else { | 133 } else { |
137 DCHECK_EQ(OK, result); | 134 DCHECK_EQ(OK, result); |
138 stream_->Close(false /* keep-alive */); | 135 stream_->Close(false /* keep-alive */); |
139 } | 136 } |
140 | 137 |
141 delete this; | 138 delete this; |
142 } | 139 } |
143 | 140 |
144 } // namespace net | 141 } // namespace net |
OLD | NEW |