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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 |
60 // time is set, treat it as error. Note that the expected modification time | 60 // time is set, treat it as error. Note that the expected modification time |
61 // from WebKit is based on time_t precision. So we have to convert both to | 61 // from WebKit is based on time_t precision. So we have to convert both to |
62 // time_t to compare. This check is used for sliced files. | 62 // time_t to compare. This check is used for sliced files. |
63 if (!expected_modification_time.is_null()) { | 63 if (!expected_modification_time.is_null()) { |
64 base::PlatformFileInfo info; | 64 base::File::Info info; |
65 if (!base::GetFileInfo(path, &info)) { | 65 if (!base::GetFileInfo(path, &info)) { |
66 DLOG(WARNING) << "Failed to get file info of \"" << path.value() << "\""; | 66 DLOG(WARNING) << "Failed to get file info of \"" << path.value() << "\""; |
67 return ERR_FILE_NOT_FOUND; | 67 return ERR_FILE_NOT_FOUND; |
68 } | 68 } |
69 | 69 |
70 if (expected_modification_time.ToTimeT() != info.last_modified.ToTimeT()) { | 70 if (expected_modification_time.ToTimeT() != info.last_modified.ToTimeT()) { |
71 return ERR_UPLOAD_FILE_CHANGED; | 71 return ERR_UPLOAD_FILE_CHANGED; |
72 } | 72 } |
73 } | 73 } |
74 | 74 |
(...skipping 214 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 |