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

Unified Diff: net/disk_cache/simple/simple_entry_impl.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
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_index.cc » ('j') | net/disk_cache/simple/simple_index.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/disk_cache/simple/simple_entry_impl.cc
diff --git a/net/disk_cache/simple/simple_entry_impl.cc b/net/disk_cache/simple/simple_entry_impl.cc
index 4fa31adb26e38ed8ede677fab3afc45e69d75a7b..545628d02b39a7903aa736f1f5bc531316494fe4 100644
--- a/net/disk_cache/simple/simple_entry_impl.cc
+++ b/net/disk_cache/simple/simple_entry_impl.cc
@@ -63,6 +63,13 @@ int SimpleEntryImpl::CreateEntry(SimpleIndex* index,
const std::string& key,
Entry** entry,
const CompletionCallback& callback) {
+ // We insert the entry in the index before creating the entry files in the
+ // SimpleSynchronousEntry, because this way the worse scenario is when we
+ // have the entry in the index but we don't have the created files yet, this
+ // way we never leak files. CreationOperationComplete will remove the entry
+ // from the index if the creation fails.
+ if (index)
+ index->Insert(key);
scoped_refptr<SimpleEntryImpl> new_entry =
new SimpleEntryImpl(index, path, key);
SynchronousCreationCallback sync_creation_callback =
@@ -334,8 +341,6 @@ void SimpleEntryImpl::CreationOperationComplete(
AddRef(); // Balanced in CloseInternal().
synchronous_entry_ = sync_entry;
SetSynchronousData();
- if (index_)
- index_->Insert(key_);
*out_entry = this;
completion_callback.Run(net::OK);
}
« no previous file with comments | « no previous file | net/disk_cache/simple/simple_index.cc » ('j') | net/disk_cache/simple/simple_index.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698