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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 return base::WrapUnique(new Writer(weak_factory_.GetWeakPtr())); | 42 return base::WrapUnique(new Writer(weak_factory_.GetWeakPtr())); |
43 } | 43 } |
44 | 44 |
45 void ChunkedUploadDataStream::AppendData( | 45 void ChunkedUploadDataStream::AppendData( |
46 const char* data, int data_len, bool is_done) { | 46 const char* data, int data_len, bool is_done) { |
47 DCHECK(!all_data_appended_); | 47 DCHECK(!all_data_appended_); |
48 DCHECK(data_len > 0 || is_done); | 48 DCHECK(data_len > 0 || is_done); |
49 if (data_len > 0) { | 49 if (data_len > 0) { |
50 DCHECK(data); | 50 DCHECK(data); |
51 upload_data_.push_back( | 51 upload_data_.push_back( |
52 base::WrapUnique(new std::vector<char>(data, data + data_len))); | 52 base::MakeUnique<std::vector<char>>(data, data + data_len)); |
53 } | 53 } |
54 all_data_appended_ = is_done; | 54 all_data_appended_ = is_done; |
55 | 55 |
56 if (!read_buffer_.get()) | 56 if (!read_buffer_.get()) |
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; |
(...skipping 51 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 |