| 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);
|
| }
|
|
|