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 #include "net/base/upload_file_element_reader.h" | 5 #include "net/base/upload_file_element_reader.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/location.h" | 9 #include "base/location.h" |
10 #include "base/task_runner_util.h" | 10 #include "base/task_runner_util.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 if (!callback.is_null()) | 215 if (!callback.is_null()) |
216 callback.Run(result); | 216 callback.Run(result); |
217 } | 217 } |
218 | 218 |
219 void UploadFileElementReader::OnReadCompleted( | 219 void UploadFileElementReader::OnReadCompleted( |
220 ScopedFileStreamPtr file_stream, | 220 ScopedFileStreamPtr file_stream, |
221 const CompletionCallback& callback, | 221 const CompletionCallback& callback, |
222 int result) { | 222 int result) { |
223 file_stream_.swap(file_stream); | 223 file_stream_.swap(file_stream); |
224 if (result > 0) { | 224 if (result > 0) { |
225 DCHECK_GE(static_cast<int>(bytes_remaining_), result); | 225 DCHECK_GE(bytes_remaining_, static_cast<uint64>(result)); |
226 bytes_remaining_ -= result; | 226 bytes_remaining_ -= result; |
227 } | 227 } |
228 if (!callback.is_null()) | 228 if (!callback.is_null()) |
229 callback.Run(result); | 229 callback.Run(result); |
230 } | 230 } |
231 | 231 |
232 UploadFileElementReader::ScopedOverridingContentLengthForTests:: | 232 UploadFileElementReader::ScopedOverridingContentLengthForTests:: |
233 ScopedOverridingContentLengthForTests(uint64 value) { | 233 ScopedOverridingContentLengthForTests(uint64 value) { |
234 overriding_content_length = value; | 234 overriding_content_length = value; |
235 } | 235 } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 uint64 UploadFileElementReaderSync::BytesRemaining() const { | 274 uint64 UploadFileElementReaderSync::BytesRemaining() const { |
275 return bytes_remaining_; | 275 return bytes_remaining_; |
276 } | 276 } |
277 | 277 |
278 int UploadFileElementReaderSync::Read(IOBuffer* buf, | 278 int UploadFileElementReaderSync::Read(IOBuffer* buf, |
279 int buf_length, | 279 int buf_length, |
280 const CompletionCallback& callback) { | 280 const CompletionCallback& callback) { |
281 const int result = ReadInternal(buf, buf_length, BytesRemaining(), | 281 const int result = ReadInternal(buf, buf_length, BytesRemaining(), |
282 file_stream_.get()); | 282 file_stream_.get()); |
283 if (result > 0) { | 283 if (result > 0) { |
284 DCHECK_GE(static_cast<int>(bytes_remaining_), result); | 284 DCHECK_GE(bytes_remaining_, static_cast<uint64>(result)); |
285 bytes_remaining_ -= result; | 285 bytes_remaining_ -= result; |
286 } | 286 } |
287 return result; | 287 return result; |
288 } | 288 } |
289 | 289 |
290 } // namespace net | 290 } // namespace net |
OLD | NEW |