Index: net/http/http_cache.cc |
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc |
index 796aeea501414bdacb9efa9aecd625a6702a85aa..f54720ac39716c8e7b4617f32730daee74573ae3 100644 |
--- a/net/http/http_cache.cc |
+++ b/net/http/http_cache.cc |
@@ -839,69 +839,43 @@ int HttpCache::AddTransactionToEntry(ActiveEntry* entry, Transaction* trans) { |
return OK; |
} |
-void HttpCache::DoneWithEntry(ActiveEntry* entry, Transaction* trans, |
- bool cancel) { |
+void HttpCache::DoneWithEntry(ActiveEntry* entry, |
+ Transaction* trans, |
+ EntryState entry_state) { |
// If we already posted a task to move on to the next transaction and this was |
// the writer, there is nothing to cancel. |
if (entry->will_process_pending_queue && entry->readers.empty()) |
return; |
if (entry->writer) { |
- DCHECK(trans == entry->writer); |
- |
- // Assume there was a failure. |
- bool success = false; |
- if (cancel) { |
- DCHECK(entry->disk_entry); |
- // This is a successful operation in the sense that we want to keep the |
- // entry. |
- success = trans->AddTruncatedFlag(); |
- // The previous operation may have deleted the entry. |
- if (!trans->entry()) |
- return; |
- } |
- DoneWritingToEntry(entry, success); |
- } else { |
- DoneReadingFromEntry(entry, trans); |
- } |
-} |
- |
-void HttpCache::DoneWritingToEntry(ActiveEntry* entry, bool success) { |
- DCHECK(entry->readers.empty()); |
- |
- entry->writer = NULL; |
+ DCHECK_EQ(trans, entry->writer); |
+ DCHECK(entry->readers.empty()); |
- if (success) { |
- ProcessPendingQueue(entry); |
- } else { |
- DCHECK(!entry->will_process_pending_queue); |
+ entry->writer = nullptr; |
- // We failed to create this entry. |
- TransactionList pending_queue; |
- pending_queue.swap(entry->pending_queue); |
+ if (entry_state == EntryState::DOOMED || entry->doomed) { |
+ DCHECK(!entry->will_process_pending_queue); |
- entry->disk_entry->Doom(); |
- DestroyEntry(entry); |
+ TransactionList pending_queue; |
+ pending_queue.swap(entry->pending_queue); |
+ if (!entry->doomed) |
+ entry->disk_entry->Doom(); |
+ DestroyEntry(entry); |
- // We need to do something about these pending entries, which now need to |
- // be added to a new entry. |
- while (!pending_queue.empty()) { |
- // ERR_CACHE_RACE causes the transaction to restart the whole process. |
- pending_queue.front()->io_callback().Run(ERR_CACHE_RACE); |
- pending_queue.pop_front(); |
+ // We need to do something about these pending entries, which now need to |
+ // be added to a new entry. |
+ while (!pending_queue.empty()) { |
+ // ERR_CACHE_RACE causes the transaction to restart the whole process. |
+ pending_queue.front()->io_callback().Run(ERR_CACHE_RACE); |
+ pending_queue.pop_front(); |
+ } |
+ return; |
} |
+ } else { |
+ auto it = std::find(entry->readers.begin(), entry->readers.end(), trans); |
+ DCHECK(it != entry->readers.end()); |
+ entry->readers.erase(it); |
} |
-} |
- |
-void HttpCache::DoneReadingFromEntry(ActiveEntry* entry, Transaction* trans) { |
- DCHECK(!entry->writer); |
- |
- TransactionList::iterator it = |
- std::find(entry->readers.begin(), entry->readers.end(), trans); |
- DCHECK(it != entry->readers.end()); |
- |
- entry->readers.erase(it); |
- |
ProcessPendingQueue(entry); |
} |