| 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, so that the element can be reread. | 132 // Resets the offset to zero and closes the file stream if opened, so |
| 133 void ResetOffset() { offset_ = 0; } | 133 // that the element can be reread. |
| 134 void ResetOffset(); |
| 134 | 135 |
| 135 private: | 136 private: |
| 136 // Returns a FileStream opened for reading for this element, positioned | 137 // Returns a FileStream opened for reading for this element, positioned |
| 137 // at |file_range_offset_|. Returns NULL if the file is not openable. | 138 // at |file_range_offset_|. Returns NULL if the file is not openable. |
| 138 FileStream* OpenFileStream(); | 139 FileStream* OpenFileStream(); |
| 139 | 140 |
| 140 // Reads up to |buf_len| bytes synchronously from memory (i.e. type_ is | 141 // Reads up to |buf_len| bytes synchronously from memory (i.e. type_ is |
| 141 // TYPE_BYTES or TYPE_CHUNK). | 142 // TYPE_BYTES or TYPE_CHUNK). |
| 142 int ReadFromMemorySync(char* buf, int buf_len); | 143 int ReadFromMemorySync(char* buf, int buf_len); |
| 143 | 144 |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 | 277 |
| 277 inline bool operator!=(const UploadData::Element& a, | 278 inline bool operator!=(const UploadData::Element& a, |
| 278 const UploadData::Element& b) { | 279 const UploadData::Element& b) { |
| 279 return !(a == b); | 280 return !(a == b); |
| 280 } | 281 } |
| 281 #endif // defined(UNIT_TEST) | 282 #endif // defined(UNIT_TEST) |
| 282 | 283 |
| 283 } // namespace net | 284 } // namespace net |
| 284 | 285 |
| 285 #endif // NET_BASE_UPLOAD_DATA_H_ | 286 #endif // NET_BASE_UPLOAD_DATA_H_ |
| OLD | NEW |