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 | |
60 // a value >= 0 or ERR_IO_PENDING, and call OnReadCompleted with a | |
61 // value >= 0. | |
62 // TODO(mmenke): Investigate letting reads fail. | 59 // TODO(mmenke): Investigate letting reads fail. |
63 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); | 60 int Read(IOBuffer* buf, int buf_len, const CompletionCallback& callback); |
64 | 61 |
65 // Returns the total size of the data stream and the current position. | 62 // 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 | 63 // When the data is chunked, always returns zero. Must always return the same |
67 // value after each call to Initialize(). | 64 // value after each call to Initialize(). |
68 uint64_t size() const { return total_size_; } | 65 uint64_t size() const { return total_size_; } |
69 uint64_t position() const { return current_position_; } | 66 uint64_t position() const { return current_position_; } |
70 | 67 |
71 // See constructor for description. | 68 // See constructor for description. |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 bool is_eof_; | 134 bool is_eof_; |
138 | 135 |
139 CompletionCallback callback_; | 136 CompletionCallback callback_; |
140 | 137 |
141 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); | 138 DISALLOW_COPY_AND_ASSIGN(UploadDataStream); |
142 }; | 139 }; |
143 | 140 |
144 } // namespace net | 141 } // namespace net |
145 | 142 |
146 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ | 143 #endif // NET_BASE_UPLOAD_DATA_STREAM_H_ |
OLD | NEW |