summaryrefslogtreecommitdiffstats
path: root/storage/browser
diff options
context:
space:
mode:
authorjsbell <jsbell@chromium.org>2015-09-01 17:55:03 -0700
committerCommit bot <commit-bot@chromium.org>2015-09-02 00:55:39 +0000
commit1d45da203ac9fc8ea3f119edf9030d8e948722a3 (patch)
tree704760bf7c661adcc3155576b9bf16e3d4f20c82 /storage/browser
parenta777250f5630d1e4880d9a4430aa7bdc7e18e23f (diff)
downloadchromium_src-1d45da203ac9fc8ea3f119edf9030d8e948722a3.zip
chromium_src-1d45da203ac9fc8ea3f119edf9030d8e948722a3.tar.gz
chromium_src-1d45da203ac9fc8ea3f119edf9030d8e948722a3.tar.bz2
FileAPI: Compare expected modification time with delta on file read
The File API reader validates that the "expected" modification time - e.g. taken when a user selects a file via <input type=file> matches the "actual" modification time when trying to read. Certain file timestamps (on Windows/NTFS at least) are high enough precision (tenths of microseconds) that an int64->double->int64 round trip through Blink loses bits. Files with these timestamps can't be read! Sample timestamp: 2011-01-01T01:23:45.999999Z (that's a lot of 9s) Make the comparison with an epsilon of 10us. BUG=525088 R=michaeln@chromium.org Review URL: https://codereview.chromium.org/1308773006 Cr-Commit-Position: refs/heads/master@{#346802}
Diffstat (limited to 'storage/browser')
-rw-r--r--storage/browser/fileapi/file_stream_reader.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/storage/browser/fileapi/file_stream_reader.cc b/storage/browser/fileapi/file_stream_reader.cc
index cb87ecb..00d3e22 100644
--- a/storage/browser/fileapi/file_stream_reader.cc
+++ b/storage/browser/fileapi/file_stream_reader.cc
@@ -8,13 +8,18 @@
namespace storage {
+// Int64->double->int64 conversions (e.g. through Blink) may lose some
+// precision in the microsecond range. Allow 10us delta.
+const int kModificationTimeAllowedDeltaMicroseconds = 10;
+
// Verify if the underlying file has not been modified.
bool FileStreamReader::VerifySnapshotTime(
const base::Time& expected_modification_time,
const base::File::Info& file_info) {
return expected_modification_time.is_null() ||
- expected_modification_time.ToTimeT() ==
- file_info.last_modified.ToTimeT();
+ (expected_modification_time - file_info.last_modified)
+ .magnitude()
+ .InMicroseconds() < kModificationTimeAllowedDeltaMicroseconds;
}
} // namespace storage