Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / storage / browser / fileapi / file_stream_reader.cc
blob00d3e22bd00cf1b532887ed3ddfcc1de083703fa
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
3 // found in the LICENSE file.
5 #include "storage/browser/fileapi/file_stream_reader.h"
7 #include "base/time/time.h"
9 namespace storage {
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;
15 // Verify if the underlying file has not been modified.
16 bool FileStreamReader::VerifySnapshotTime(
17 const base::Time& expected_modification_time,
18 const base::File::Info& file_info) {
19 return expected_modification_time.is_null() ||
20 (expected_modification_time - file_info.last_modified)
21 .magnitude()
22 .InMicroseconds() < kModificationTimeAllowedDeltaMicroseconds;
25 } // namespace storage