Chromium Code Reviews| 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..ae6362a340c916621b42678f0f7947b6d374bf93 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 |
|
gavinp
2013/04/19 11:30:17
nit: one space after .
felipeg
2013/04/19 12:20:29
Done.
|
| + // 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); |
| } |