Chromium Code Reviews| Index: net/disk_cache/simple/simple_index_file.cc |
| diff --git a/net/disk_cache/simple/simple_index_file.cc b/net/disk_cache/simple/simple_index_file.cc |
| index a2913202276b22ef724a04abb6ffd0cdc34aa419..f5dcd5a9ef711d7fa210d48787203a4ce0f1a255 100644 |
| --- a/net/disk_cache/simple/simple_index_file.cc |
| +++ b/net/disk_cache/simple/simple_index_file.cc |
| @@ -161,4 +161,21 @@ void SimpleIndexFile::WriteToDisk(const base::FilePath& index_filename, |
| DCHECK(result); |
| } |
| +// static |
| +bool SimpleIndexFile::IndexFileIsStale(const base::FilePath& index_filename) { |
| + base::PlatformFileInfo dir_info; |
| + base::PlatformFileInfo index_info; |
| + if (!file_util::GetFileInfo(index_filename.DirName(), &dir_info)) |
| + return false; |
| + DCHECK(dir_info.is_directory); |
| + if (!file_util::GetFileInfo(index_filename, &index_info)) |
| + return false; |
| + |
| + // Index file last_modified must be equal to the directory last_modified since |
| + // the last operation we do is ReplaceFile in the |
| + // SimpleIndexFile::WriteToDisk(). |
| + // If not true, we need to restore the index. |
| + return index_info.last_modified != dir_info.last_modified; |
|
gavinp
2013/04/19 09:30:17
I think index_info.last_modified >= dir_info.last_
felipeg
2013/04/19 10:14:05
Done.
|
| +} |
| + |
| } // namespace disk_cache |