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..47fd3c1bdfe318c44d40f762e7c489c81c9a4e50 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::IsIndexFileStale(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; |
+} |
+ |
} // namespace disk_cache |