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

Unified Diff: net/disk_cache/simple/simple_index.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.cc
diff --git a/net/disk_cache/simple/simple_index.cc b/net/disk_cache/simple/simple_index.cc
index c2b73b9c80716577363e59f05a4387de37bc4181..db075bd4f9c54343dc79213baef760c6a43da62d 100644
--- a/net/disk_cache/simple/simple_index.cc
+++ b/net/disk_cache/simple/simple_index.cc
@@ -173,6 +173,8 @@ void SimpleIndex::InsertInEntrySet(
}
void SimpleIndex::PostponeWritingToDisk() {
+ if (!initialized_)
+ return;
const base::TimeDelta file_age = base::Time::Now() - last_write_to_disk_;
if (file_age > base::TimeDelta::FromSeconds(kMaxWriteToDiskDelaySecs) &&
write_to_disk_timer_.IsRunning()) {
@@ -194,11 +196,12 @@ void SimpleIndex::LoadFromDisk(
const base::FilePath& index_filename,
base::SingleThreadTaskRunner* io_thread,
const IndexCompletionCallback& completion_callback) {
+ // TODO(felipeg): probably could load a stale index and use it for something.
scoped_ptr<EntrySet> index_file_entries =
SimpleIndexFile::LoadFromDisk(index_filename);
bool force_index_flush = false;
gavinp 2013/04/19 12:23:13 This whole function is a lot easier to read. Thank
felipeg 2013/04/19 12:55:58 Done.
- if (!index_file_entries.get()) {
+ if (!index_file_entries) {
index_file_entries = SimpleIndex::RestoreFromDisk(index_filename);
// When we restore from disk we write the merged index file to disk right
// away, this might save us from having to restore again next time.

Powered by Google App Engine
This is Rietveld 408576698