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

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_file.h » ('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..175ec22fcf869605baf37aa5012280b9cd8b487f 100644
--- a/net/disk_cache/simple/simple_entry_impl.cc
+++ b/net/disk_cache/simple/simple_entry_impl.cc
@@ -42,6 +42,14 @@ int SimpleEntryImpl::OpenEntry(SimpleIndex* index,
// TODO(gavinp): More closely unify the last_used_ in the
// SimpleSynchronousEntry and the SimpleIndex.
if (!index || index->UseIfExists(key)) {
+ // 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.
+ // Same is true for the CreateEntry() bellow.
+ if (index)
+ index->Insert(key);
gavinp 2013/04/19 09:30:17 This is dead code. Either index is null, or index-
felipeg 2013/04/19 10:14:05 Done.
scoped_refptr<SimpleEntryImpl> new_entry =
new SimpleEntryImpl(index, path, key);
SynchronousCreationCallback sync_creation_callback =
@@ -63,6 +71,9 @@ int SimpleEntryImpl::CreateEntry(SimpleIndex* index,
const std::string& key,
Entry** entry,
const CompletionCallback& callback) {
+ // See comment on OpenEntry regarding inserting the entry in the index.
+ if (index)
+ index->Insert(key);
scoped_refptr<SimpleEntryImpl> new_entry =
new SimpleEntryImpl(index, path, key);
SynchronousCreationCallback sync_creation_callback =
@@ -334,8 +345,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_file.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698