| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/chunked_upload_data_stream.h" | 5 #include "net/base/chunked_upload_data_stream.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 return; | 57 return; |
| 58 | 58 |
| 59 int result = ReadChunk(read_buffer_.get(), read_buffer_len_); | 59 int result = ReadChunk(read_buffer_.get(), read_buffer_len_); |
| 60 // Shouldn't get an error or ERR_IO_PENDING. | 60 // Shouldn't get an error or ERR_IO_PENDING. |
| 61 DCHECK_GE(result, 0); | 61 DCHECK_GE(result, 0); |
| 62 read_buffer_ = NULL; | 62 read_buffer_ = NULL; |
| 63 read_buffer_len_ = 0; | 63 read_buffer_len_ = 0; |
| 64 OnReadCompleted(result); | 64 OnReadCompleted(result); |
| 65 } | 65 } |
| 66 | 66 |
| 67 int ChunkedUploadDataStream::InitInternal() { | 67 int ChunkedUploadDataStream::InitInternal(const BoundNetLog& net_log) { |
| 68 // ResetInternal should already have been called. | 68 // ResetInternal should already have been called. |
| 69 DCHECK(!read_buffer_.get()); | 69 DCHECK(!read_buffer_.get()); |
| 70 DCHECK_EQ(0u, read_index_); | 70 DCHECK_EQ(0u, read_index_); |
| 71 DCHECK_EQ(0u, read_offset_); | 71 DCHECK_EQ(0u, read_offset_); |
| 72 return OK; | 72 return OK; |
| 73 } | 73 } |
| 74 | 74 |
| 75 int ChunkedUploadDataStream::ReadInternal(IOBuffer* buf, int buf_len) { | 75 int ChunkedUploadDataStream::ReadInternal(IOBuffer* buf, int buf_len) { |
| 76 DCHECK_LT(0, buf_len); | 76 DCHECK_LT(0, buf_len); |
| 77 DCHECK(!read_buffer_.get()); | 77 DCHECK(!read_buffer_.get()); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 // ERR_IO_PENDING. The read will be completed in the next call to AppendData. | 114 // ERR_IO_PENDING. The read will be completed in the next call to AppendData. |
| 115 if (bytes_read == 0 && !all_data_appended_) | 115 if (bytes_read == 0 && !all_data_appended_) |
| 116 return ERR_IO_PENDING; | 116 return ERR_IO_PENDING; |
| 117 | 117 |
| 118 if (read_index_ == upload_data_.size() && all_data_appended_) | 118 if (read_index_ == upload_data_.size() && all_data_appended_) |
| 119 SetIsFinalChunk(); | 119 SetIsFinalChunk(); |
| 120 return bytes_read; | 120 return bytes_read; |
| 121 } | 121 } |
| 122 | 122 |
| 123 } // namespace net | 123 } // namespace net |
| OLD | NEW |