| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "net/disk_cache/simple/simple_util.h" | 5 #include "net/disk_cache/simple/simple_util.h" |
| 6 | 6 |
| 7 #include <limits> | 7 #include <limits> |
| 8 | 8 |
| 9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 // Size of the uint64 hash_key number in Hex format in a string. | 21 // Size of the uint64 hash_key number in Hex format in a string. |
| 22 const size_t kEntryHashKeyAsHexStringSize = 2 * sizeof(uint64); | 22 const size_t kEntryHashKeyAsHexStringSize = 2 * sizeof(uint64); |
| 23 | 23 |
| 24 // TODO(clamy, gavinp): this should go in base | 24 // TODO(clamy, gavinp): this should go in base |
| 25 bool GetNanoSecsFromStat(const struct stat& st, | 25 bool GetNanoSecsFromStat(const struct stat& st, |
| 26 time_t* out_sec, | 26 time_t* out_sec, |
| 27 long* out_nsec) { | 27 long* out_nsec) { |
| 28 #if defined(OS_ANDROID) | 28 #if defined(OS_ANDROID) |
| 29 *out_sec = st.st_mtime; | 29 *out_sec = st.st_mtime; |
| 30 *out_nsec = st.st_mtime_nsec; | 30 *out_nsec = st.st_mtime_nsec; |
| 31 return true; |
| 31 #elif defined(OS_LINUX) | 32 #elif defined(OS_LINUX) |
| 32 *out_sec = st.st_mtim.tv_sec; | 33 *out_sec = st.st_mtim.tv_sec; |
| 33 *out_nsec = st.st_mtim.tv_nsec; | 34 *out_nsec = st.st_mtim.tv_nsec; |
| 35 return true; |
| 34 #elif defined(OS_MACOSX) || defined(OS_IOS) || defined(OS_BSD) | 36 #elif defined(OS_MACOSX) || defined(OS_IOS) || defined(OS_BSD) |
| 35 *out_sec = st.st_mtimespec.tv_sec; | 37 *out_sec = st.st_mtimespec.tv_sec; |
| 36 *out_nsec = st.st_mtimespec.tv_nsec; | 38 *out_nsec = st.st_mtimespec.tv_nsec; |
| 39 return true; |
| 37 #else | 40 #else |
| 38 return false; | 41 return false; |
| 39 #endif | 42 #endif |
| 40 return true; | |
| 41 } | 43 } |
| 42 | 44 |
| 43 } // namespace | 45 } // namespace |
| 44 | 46 |
| 45 namespace disk_cache { | 47 namespace disk_cache { |
| 46 | 48 |
| 47 namespace simple_util { | 49 namespace simple_util { |
| 48 | 50 |
| 49 std::string ConvertEntryHashKeyToHexString(uint64 hash_key) { | 51 std::string ConvertEntryHashKeyToHexString(uint64 hash_key) { |
| 50 const std::string hash_key_str = base::StringPrintf("%016" PRIx64, hash_key); | 52 const std::string hash_key_str = base::StringPrintf("%016" PRIx64, hash_key); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 base::File::Info file_info; | 130 base::File::Info file_info; |
| 129 if (!base::GetFileInfo(path, &file_info)) | 131 if (!base::GetFileInfo(path, &file_info)) |
| 130 return false; | 132 return false; |
| 131 *out_mtime = file_info.last_modified; | 133 *out_mtime = file_info.last_modified; |
| 132 return true; | 134 return true; |
| 133 } | 135 } |
| 134 | 136 |
| 135 } // namespace simple_backend | 137 } // namespace simple_backend |
| 136 | 138 |
| 137 } // namespace disk_cache | 139 } // namespace disk_cache |
| OLD | NEW |