diff options
author | gavinp@chromium.org <gavinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-08 23:11:57 +0000 |
---|---|---|
committer | gavinp@chromium.org <gavinp@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-08-08 23:11:57 +0000 |
commit | bc5e399dfa50fee52ae17107061fa720986ff8fe (patch) | |
tree | d6b5c0a9b38d2778118b3e72c0d221b5a34b061f /net | |
parent | 0790575398c5543f4d879d72dba6f54b52b94f8e (diff) | |
download | chromium_src-bc5e399dfa50fee52ae17107061fa720986ff8fe.zip chromium_src-bc5e399dfa50fee52ae17107061fa720986ff8fe.tar.gz chromium_src-bc5e399dfa50fee52ae17107061fa720986ff8fe.tar.bz2 |
Improve time resolution in PlatformFileInfo.
The Simple Cache uses directory and file mtimes at high granularity to
determine index freshness. As well, for linux process creation times,
a high resolution ctime from /proc is useful; so high resolution ctime
makes process creation times accurate.
R=darin
Review URL: https://chromiumcodereview.appspot.com/22582009
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@216478 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'net')
-rw-r--r-- | net/disk_cache/simple/simple_util.cc | 33 | ||||
-rw-r--r-- | net/disk_cache/simple/simple_util.h | 4 |
2 files changed, 2 insertions, 35 deletions
diff --git a/net/disk_cache/simple/simple_util.cc b/net/disk_cache/simple/simple_util.cc index 40d3894..72a4612 100644 --- a/net/disk_cache/simple/simple_util.cc +++ b/net/disk_cache/simple/simple_util.cc @@ -21,25 +21,6 @@ namespace { // Size of the uint64 hash_key number in Hex format in a string. const size_t kEntryHashKeyAsHexStringSize = 2 * sizeof(uint64); -// TODO(clamy, gavinp): this should go in base -bool GetNanoSecsFromStat(const struct stat& st, - time_t* out_sec, - long* out_nsec) { -#if defined(OS_ANDROID) - *out_sec = st.st_mtime; - *out_nsec = st.st_mtime_nsec; -#elif defined(OS_LINUX) - *out_sec = st.st_mtim.tv_sec; - *out_nsec = st.st_mtim.tv_nsec; -#elif defined(OS_MACOSX) || defined(OS_IOS) || defined(OS_BSD) - *out_sec = st.st_mtimespec.tv_sec; - *out_nsec = st.st_mtimespec.tv_nsec; -#else - return false; -#endif - return true; -} - } // namespace namespace disk_cache { @@ -107,20 +88,6 @@ int64 GetFileOffsetFromKeyAndDataOffset(const std::string& key, // TODO(clamy, gavinp): this should go in base bool GetMTime(const base::FilePath& path, base::Time* out_mtime) { DCHECK(out_mtime); -#if defined(OS_POSIX) - base::ThreadRestrictions::AssertIOAllowed(); - struct stat file_stat; - if (stat(path.value().c_str(), &file_stat) != 0) - return false; - time_t sec; - long nsec; - if (GetNanoSecsFromStat(file_stat, &sec, &nsec)) { - int64 usec = (nsec / base::Time::kNanosecondsPerMicrosecond); - *out_mtime = base::Time::FromTimeT(sec) - + base::TimeDelta::FromMicroseconds(usec); - return true; - } -#endif base::PlatformFileInfo file_info; if (!file_util::GetFileInfo(path, &file_info)) return false; diff --git a/net/disk_cache/simple/simple_util.h b/net/disk_cache/simple/simple_util.h index 505501e..2e92b4a 100644 --- a/net/disk_cache/simple/simple_util.h +++ b/net/disk_cache/simple/simple_util.h @@ -62,8 +62,8 @@ NET_EXPORT_PRIVATE int64 GetFileOffsetFromKeyAndDataOffset( const std::string& key, int data_offset); -// Fills |out_time| with the time the file last modified time. Unlike the -// functions in platform_file.h, the time resolution is milliseconds. +// Fills |out_time| with the time the file last modified time. +// TODO(gavinp): Remove this function. NET_EXPORT_PRIVATE bool GetMTime(const base::FilePath& path, base::Time* out_mtime); } // namespace simple_backend |