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_H_ | 5 #ifndef NET_BASE_UPLOAD_DATA_H_ |
6 #define NET_BASE_UPLOAD_DATA_H_ | 6 #define NET_BASE_UPLOAD_DATA_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 // Reads up to |buf_len| bytes synchronously. Returns the number of bytes | 123 // Reads up to |buf_len| bytes synchronously. Returns the number of bytes |
124 // read. This function never fails. If there's less data to read than we | 124 // read. This function never fails. If there's less data to read than we |
125 // initially observed, then pad with zero (this can happen with files). | 125 // initially observed, then pad with zero (this can happen with files). |
126 // |buf_len| must be greater than 0. | 126 // |buf_len| must be greater than 0. |
127 int ReadSync(char* buf, int buf_len); | 127 int ReadSync(char* buf, int buf_len); |
128 | 128 |
129 // Returns the number of bytes remaining to read. | 129 // Returns the number of bytes remaining to read. |
130 uint64 BytesRemaining(); | 130 uint64 BytesRemaining(); |
131 | 131 |
132 // Resets the offset to zero and closes the file stream if opened, so | 132 // Resets the offset to zero, so that the element can be reread. |
133 // that the element can be reread. | 133 void ResetOffset() { offset_ = 0; } |
134 void ResetOffset(); | |
135 | 134 |
136 private: | 135 private: |
137 // Returns a FileStream opened for reading for this element, positioned | 136 // Returns a FileStream opened for reading for this element, positioned |
138 // at |file_range_offset_|. Returns NULL if the file is not openable. | 137 // at |file_range_offset_|. Returns NULL if the file is not openable. |
139 FileStream* OpenFileStream(); | 138 FileStream* OpenFileStream(); |
140 | 139 |
141 // Reads up to |buf_len| bytes synchronously from memory (i.e. type_ is | 140 // Reads up to |buf_len| bytes synchronously from memory (i.e. type_ is |
142 // TYPE_BYTES or TYPE_CHUNK). | 141 // TYPE_BYTES or TYPE_CHUNK). |
143 int ReadFromMemorySync(char* buf, int buf_len); | 142 int ReadFromMemorySync(char* buf, int buf_len); |
144 | 143 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 276 |
278 inline bool operator!=(const UploadData::Element& a, | 277 inline bool operator!=(const UploadData::Element& a, |
279 const UploadData::Element& b) { | 278 const UploadData::Element& b) { |
280 return !(a == b); | 279 return !(a == b); |
281 } | 280 } |
282 #endif // defined(UNIT_TEST) | 281 #endif // defined(UNIT_TEST) |
283 | 282 |
284 } // namespace net | 283 } // namespace net |
285 | 284 |
286 #endif // NET_BASE_UPLOAD_DATA_H_ | 285 #endif // NET_BASE_UPLOAD_DATA_H_ |
OLD | NEW |