OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "storage/browser/fileapi/file_stream_reader.h" | 5 #include "storage/browser/fileapi/file_stream_reader.h" |
6 | 6 |
7 #include "base/time/time.h" | 7 #include "base/time/time.h" |
8 | 8 |
9 namespace storage { | 9 namespace storage { |
10 | 10 |
| 11 // Int64->double->int64 conversions (e.g. through Blink) may lose some |
| 12 // precision in the microsecond range. Allow 10us delta. |
| 13 const int kModificationTimeAllowedDeltaMicroseconds = 10; |
| 14 |
11 // Verify if the underlying file has not been modified. | 15 // Verify if the underlying file has not been modified. |
12 bool FileStreamReader::VerifySnapshotTime( | 16 bool FileStreamReader::VerifySnapshotTime( |
13 const base::Time& expected_modification_time, | 17 const base::Time& expected_modification_time, |
14 const base::File::Info& file_info) { | 18 const base::File::Info& file_info) { |
15 return expected_modification_time.is_null() || | 19 return expected_modification_time.is_null() || |
16 expected_modification_time.ToTimeT() == | 20 (expected_modification_time - file_info.last_modified) |
17 file_info.last_modified.ToTimeT(); | 21 .magnitude() |
| 22 .InMicroseconds() < kModificationTimeAllowedDeltaMicroseconds; |
18 } | 23 } |
19 | 24 |
20 } // namespace storage | 25 } // namespace storage |
OLD | NEW |