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 #ifndef NET_BASE_UPLOAD_DATA_STREAM_H_ | 5 #ifndef NET_BASE_UPLOAD_DATA_STREAM_H_ |
6 #define NET_BASE_UPLOAD_DATA_STREAM_H_ | 6 #define NET_BASE_UPLOAD_DATA_STREAM_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
49 // data stream to |buf| and returns the number of bytes read; otherwise, | 49 // data stream to |buf| and returns the number of bytes read; otherwise, |
50 // returns ERR_IO_PENDING and calls |callback| with the number of bytes read. | 50 // returns ERR_IO_PENDING and calls |callback| with the number of bytes read. |
51 // Partial reads are allowed. Zero is returned on a call to Read when there | 51 // Partial reads are allowed. Zero is returned on a call to Read when there |
52 // are no remaining bytes in the stream, and IsEof() will return true | 52 // are no remaining bytes in the stream, and IsEof() will return true |
53 // hereafter. | 53 // hereafter. |
54 // | 54 // |
55 // If there's less data to read than we initially observed (i.e. the actual | 55 // If there's less data to read than we initially observed (i.e. the actual |
56 // upload data is smaller than size()), zeros are padded to ensure that | 56 // upload data is smaller than size()), zeros are padded to ensure that |
57 // size() bytes can be read, which can happen for TYPE_FILE payloads. | 57 // size() bytes can be read, which can happen for TYPE_FILE payloads. |
58 // | 58 // |
59 // Reads are currently not allowed to fail - they must either return | 59 // Reads can fail - they can either return |
60 // a value >= 0 or ERR_IO_PENDING, and call OnReadCompleted with a | 60 // ERR_FAILED or ERR_IO_PENDING on failures, and must call OnReadCompleted |
61 // value >= 0. | 61 // with an error value. |
mmenke
2016/06/06 16:22:33
Think this should separate ERR_FAILED with ERR_IO_
maksims (do not use this acc)
2016/06/21 11:09:25
Should I remove your TODO now?
| |
62 // TODO(mmenke): Investigate letting reads fail. | 62 // TODO(mmenke): Investigate letting reads fail. |
63 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); | 63 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
64 | 64 |
65 // Returns the total size of the data stream and the current position. | 65 // Returns the total size of the data stream and the current position. |
66 // When the data is chunked, always returns zero. Must always return the same | 66 // When the data is chunked, always returns zero. Must always return the same |
67 // value after each call to Initialize(). | 67 // value after each call to Initialize(). |
68 uint64_t size() const { return total_size_; } | 68 uint64_t size() const { return total_size_; } |
69 uint64_t position() const { return current_position_; } | 69 uint64_t position() const { return current_position_; } |
70 | 70 |
71 // See constructor for description. | 71 // See constructor for description. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
137 bool is_eof_; | 137 bool is_eof_; |
138 | 138 |
139 CompletionCallback callback_; | 139 CompletionCallback callback_; |
140 | 140 |
141 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); | 141 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); |
142 }; | 142 }; |
143 | 143 |
144 } // namespace net | 144 } // namespace net |
145 | 145 |
146 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ | 146 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ |
OLD | NEW |