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

Unified Diff: net/disk_cache/simple/simple_index_file.cc

Issue 13933029: Add SimpleCache index file heuristics (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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
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
« net/disk_cache/simple/simple_index_file.h ('K') | « net/disk_cache/simple/simple_index_file.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698