| 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/base/upload_data_stream.h" | 5 #include "net/base/upload_data_stream.h" |
| 6 | 6 |
| 7 #include "base/callback_helpers.h" | 7 #include "base/callback_helpers.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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 if (result == OK) { | 102 if (result == OK) { |
| 103 initialized_successfully_ = true; | 103 initialized_successfully_ = true; |
| 104 if (!is_chunked_ && total_size_ == 0) | 104 if (!is_chunked_ && total_size_ == 0) |
| 105 is_eof_ = true; | 105 is_eof_ = true; |
| 106 } | 106 } |
| 107 if (!callback_.is_null()) | 107 if (!callback_.is_null()) |
| 108 base::ResetAndReturn(&callback_).Run(result); | 108 base::ResetAndReturn(&callback_).Run(result); |
| 109 } | 109 } |
| 110 | 110 |
| 111 void UploadDataStream::OnReadCompleted(int result) { | 111 void UploadDataStream::OnReadCompleted(int result) { |
| 112 DCHECK_GE(result, 0); | |
| 113 DCHECK(initialized_successfully_); | 112 DCHECK(initialized_successfully_); |
| 113 DCHECK(result != 0 || is_eof_); |
| 114 DCHECK_NE(ERR_IO_PENDING, result); |
| 114 | 115 |
| 115 current_position_ += result; | 116 if (result > 0) { |
| 116 if (!is_chunked_) { | 117 current_position_ += result; |
| 117 DCHECK_LE(current_position_, total_size_); | 118 if (!is_chunked_) { |
| 118 if (current_position_ == total_size_) | 119 DCHECK_LE(current_position_, total_size_); |
| 119 is_eof_ = true; | 120 if (current_position_ == total_size_) |
| 121 is_eof_ = true; |
| 122 } |
| 120 } | 123 } |
| 121 | 124 |
| 122 DCHECK(result > 0 || is_eof_); | |
| 123 | |
| 124 if (!callback_.is_null()) | 125 if (!callback_.is_null()) |
| 125 base::ResetAndReturn(&callback_).Run(result); | 126 base::ResetAndReturn(&callback_).Run(result); |
| 126 } | 127 } |
| 127 | 128 |
| 128 } // namespace net | 129 } // namespace net |
| OLD | NEW |