Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(87)

Unified Diff: storage/browser/fileapi/file_stream_reader.cc

Issue 1308773006: FileAPI: Compare expected modification time with delta on file read (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove 20us test since OSX has 1s resolution. ASSERT->EXPECT Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/fileapi/local_file_stream_reader_unittest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: storage/browser/fileapi/file_stream_reader.cc
diff --git a/storage/browser/fileapi/file_stream_reader.cc b/storage/browser/fileapi/file_stream_reader.cc
index cb87ecb939ba4b96a5d6f56a565626b8ece0c47e..00d3e22bd00cf1b532887ed3ddfcc1de083703fa 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
« no previous file with comments | « content/browser/fileapi/local_file_stream_reader_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698