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

Unified Diff: base/platform_file_posix.cc

Issue 22582009: Improve time resolution in PlatformFileInfo. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: one more TODO for gavinp Created 7 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 | « no previous file | net/disk_cache/simple/simple_util.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/platform_file_posix.cc
diff --git a/base/platform_file_posix.cc b/base/platform_file_posix.cc
index e1bab1e34c997ad03cb64f3cb82b38c47f47ef2a..056577c58172740fa886b031f2586cf677e18268 100644
--- a/base/platform_file_posix.cc
+++ b/base/platform_file_posix.cc
@@ -379,9 +379,50 @@ bool GetPlatformFileInfo(PlatformFile file, PlatformFileInfo* info) {
info->is_directory = S_ISDIR(file_info.st_mode);
info->is_symbolic_link = S_ISLNK(file_info.st_mode);
info->size = file_info.st_size;
- info->last_modified = base::Time::FromTimeT(file_info.st_mtime);
- info->last_accessed = base::Time::FromTimeT(file_info.st_atime);
- info->creation_time = base::Time::FromTimeT(file_info.st_ctime);
+
+#if defined(OS_LINUX)
+ const time_t last_modified_sec = file_info.st_mtim.tv_sec;
+ const int64 last_modified_nsec = file_info.st_mtim.tv_nsec;
+ const time_t last_accessed_sec = file_info.st_atim.tv_sec;
+ const int64 last_accessed_nsec = file_info.st_atim.tv_nsec;
+ const time_t creation_time_sec = file_info.st_ctim.tv_sec;
+ const int64 creation_time_nsec = file_info.st_ctim.tv_nsec;
+#elif defined(OS_ANDROID)
+ const time_t last_modified_sec = file_info.st_mtime;
+ const int64 last_modified_nsec = file_info.st_mtime_nsec;
+ const time_t last_accessed_sec = file_info.st_atime;
+ const int64 last_accessed_nsec = file_info.st_atime_nsec;
+ const time_t creation_time_sec = file_info.st_ctime;
+ const int64 creation_time_nsec = file_info.st_ctime_nsec;
+#elif defined(OS_MACOSX) || defined(OS_IOS) || defined(OS_BSD)
+ const time_t last_modified_sec = file_info.st_mtimespec.tv_sec;
+ const int64 last_modified_nsec = file_info.st_mtimespec.tv_nsec;
+ const time_t last_accessed_sec = file_info.st_atimespec.tv_sec;
+ const int64 last_accessed_nsec = file_info.st_atimespec.tv_nsec;
+ const time_t creation_time_sec = file_info.st_ctimespec.tv_sec;
+ const int64 creation_time_nsec = file_info.st_ctimespec.tv_nsec;
+#else
+ // TODO(gavinp): Investigate a good high resolution option for OS_NACL.
+ const time_t last_modified_sec = file_info.st_mtime;
+ const int64 last_modified_nsec = 0;
+ const time_t last_accessed_sec = file_info.st_atime;
+ const int64 last_accessed_nsec = 0;
+ const time_t creation_time_sec = file_info.st_ctime;
+ const int64 creation_time_nsec = 0;
+#endif
+
+ info->last_modified =
+ base::Time::FromTimeT(last_modified_sec) +
+ base::TimeDelta::FromMicroseconds(last_modified_nsec /
+ base::Time::kNanosecondsPerMicrosecond);
+ info->last_accessed =
+ base::Time::FromTimeT(last_accessed_sec) +
+ base::TimeDelta::FromMicroseconds(last_accessed_nsec /
+ base::Time::kNanosecondsPerMicrosecond);
+ info->creation_time =
+ base::Time::FromTimeT(creation_time_sec) +
+ base::TimeDelta::FromMicroseconds(creation_time_nsec /
+ base::Time::kNanosecondsPerMicrosecond);
return true;
}
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698