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..e0089dd6273e4f3899a7472c9571ee1d2bf8a9df 100644 |
--- a/net/disk_cache/simple/simple_index.cc |
+++ b/net/disk_cache/simple/simple_index.cc |
@@ -9,6 +9,7 @@ |
#include "base/bind.h" |
#include "base/bind_helpers.h" |
#include "base/file_util.h" |
+#include "base/file_util.h" |
gavinp
2013/04/19 11:30:17
Once is probably enough.
felipeg
2013/04/19 12:20:29
Done.
|
#include "base/logging.h" |
#include "base/message_loop.h" |
#include "base/pickle.h" |
@@ -173,6 +174,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,21 +197,24 @@ void SimpleIndex::LoadFromDisk( |
const base::FilePath& index_filename, |
base::SingleThreadTaskRunner* io_thread, |
const IndexCompletionCallback& completion_callback) { |
- scoped_ptr<EntrySet> index_file_entries = |
- SimpleIndexFile::LoadFromDisk(index_filename); |
+ bool restore_from_disk = SimpleIndexFile::IsIndexFileStale(index_filename); |
+ |
+ scoped_ptr<EntrySet> index_file_entries; |
+ if (!restore_from_disk) { |
+ index_file_entries = SimpleIndexFile::LoadFromDisk(index_filename); |
gavinp
2013/04/19 11:30:17
Add a TODO commenting that we probably could load
pasko-google - do not use
2013/04/19 11:43:24
It is a little hard to follow the logic of decidin
felipeg
2013/04/19 12:20:29
Done.
felipeg
2013/04/19 12:20:29
Done.
|
+ } |
- bool force_index_flush = false; |
if (!index_file_entries.get()) { |
gavinp
2013/04/19 11:30:17
While we're here, no need for this .get().
felipeg
2013/04/19 12:20:29
Done.
|
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. |
- force_index_flush = true; |
+ restore_from_disk = true; |
} |
io_thread->PostTask(FROM_HERE, |
base::Bind(completion_callback, |
base::Passed(&index_file_entries), |
- force_index_flush)); |
+ restore_from_disk)); |
} |
// static |