| 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 28 matching lines...) Expand all Loading... |
| 39 } else if (range_offset) { | 39 } else if (range_offset) { |
| 40 rv = file_stream->SeekSync(FROM_BEGIN, range_offset); | 40 rv = file_stream->SeekSync(FROM_BEGIN, range_offset); |
| 41 if (rv < 0) { | 41 if (rv < 0) { |
| 42 DLOG(WARNING) << "Failed to seek \"" << path.value() | 42 DLOG(WARNING) << "Failed to seek \"" << path.value() |
| 43 << "\" to offset: " << range_offset << " (" << rv << ")"; | 43 << "\" to offset: " << range_offset << " (" << rv << ")"; |
| 44 return rv; | 44 return rv; |
| 45 } | 45 } |
| 46 } | 46 } |
| 47 | 47 |
| 48 int64 length = 0; | 48 int64 length = 0; |
| 49 if (!file_util::GetFileSize(path, &length)) { | 49 if (!base::GetFileSize(path, &length)) { |
| 50 DLOG(WARNING) << "Failed to get file size of \"" << path.value() << "\""; | 50 DLOG(WARNING) << "Failed to get file size of \"" << path.value() << "\""; |
| 51 return ERR_FILE_NOT_FOUND; | 51 return ERR_FILE_NOT_FOUND; |
| 52 } | 52 } |
| 53 | 53 |
| 54 if (range_offset < static_cast<uint64>(length)) { | 54 if (range_offset < static_cast<uint64>(length)) { |
| 55 // Compensate for the offset. | 55 // Compensate for the offset. |
| 56 length = std::min(length - range_offset, range_length); | 56 length = std::min(length - range_offset, range_length); |
| 57 } | 57 } |
| 58 | 58 |
| 59 // If the underlying file has been changed and the expected file modification | 59 // If the underlying file has been changed and the expected file modification |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 const int result = ReadInternal(buf, buf_length, BytesRemaining(), | 289 const int result = ReadInternal(buf, buf_length, BytesRemaining(), |
| 290 file_stream_.get()); | 290 file_stream_.get()); |
| 291 if (result > 0) { | 291 if (result > 0) { |
| 292 DCHECK_GE(bytes_remaining_, static_cast<uint64>(result)); | 292 DCHECK_GE(bytes_remaining_, static_cast<uint64>(result)); |
| 293 bytes_remaining_ -= result; | 293 bytes_remaining_ -= result; |
| 294 } | 294 } |
| 295 return result; | 295 return result; |
| 296 } | 296 } |
| 297 | 297 |
| 298 } // namespace net | 298 } // namespace net |
| OLD | NEW |