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

Unified Diff: net/base/upload_file_element_reader.cc

Issue 868253012: [net] Subtract timestamps to determine if uploading file changed. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Formatting Created 5 years, 11 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 | « no previous file | net/base/upload_file_element_reader_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/base/upload_file_element_reader.cc
diff --git a/net/base/upload_file_element_reader.cc b/net/base/upload_file_element_reader.cc
index 9be9117c2ab53c42d76d1835d3ca37a394ad63a2..864584d849d43f08741e7ce3834bb8af97a64d28 100644
--- a/net/base/upload_file_element_reader.cc
+++ b/net/base/upload_file_element_reader.cc
@@ -174,12 +174,15 @@ void UploadFileElementReader::OnGetFileInfoCompleted(
}
// If the underlying file has been changed and the expected file modification
- // time is set, treat it as error. Note that the expected modification time
- // from WebKit is based on time_t precision. So we have to convert both to
- // time_t to compare. This check is used for sliced files.
+ // time is set, treat it as error. Note that |expected_modification_time_| may
+ // have gone through multiple conversion steps involving loss of precision
+ // (including conversion to time_t). Therefore the check below only verifies
+ // that the timestamps are within one second of each other. This check is used
+ // for sliced files.
if (!expected_modification_time_.is_null() &&
- expected_modification_time_.ToTimeT() !=
- file_info->last_modified.ToTimeT()) {
+ (expected_modification_time_ - file_info->last_modified)
+ .magnitude()
+ .InSeconds() != 0) {
callback.Run(ERR_UPLOAD_FILE_CHANGED);
return;
}
« no previous file with comments | « no previous file | net/base/upload_file_element_reader_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698