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

Unified Diff: net/http/http_cache.cc

Issue 2774603003: Doom and create new entry when validation is not a match (Closed)
Patch Set: Rebased with refs/heads/master@{#484325} Created 3 years, 5 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 | « net/http/http_cache.h ('k') | net/http/http_cache_transaction.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/http/http_cache.cc
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index 88a4e5265178bb61dc10cc89aa851e9c96936973..c196e68be86ca5b04ab094b1d84327f24a190df4 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -952,6 +952,32 @@ void HttpCache::DoneReadingFromEntry(ActiveEntry* entry,
ProcessQueuedTransactions(entry);
}
+void HttpCache::DoomEntryValidationNoMatch(ActiveEntry* entry) {
+ // Validating transaction received a non-matching response.
+ DCHECK(entry->headers_transaction);
+
+ entry->headers_transaction = nullptr;
+ if (entry->HasNoTransactions() && !entry->will_process_queued_transactions) {
+ entry->disk_entry->Doom();
+ DestroyEntry(entry);
+ return;
+ }
+
+ DoomActiveEntry(entry->disk_entry->GetKey());
+
+ // Restart only add_to_entry_queue transactions.
+ // Post task here to avoid a race in creating the entry between |transaction|
+ // and the add_to_entry_queue transactions. Reset the queued transaction's
+ // cache pending state so that in case it's destructor is invoked, it's ok
+ // for the transaction to not be found in this entry.
+ for (auto* transaction : entry->add_to_entry_queue) {
+ transaction->ResetCachePendingState();
+ base::ThreadTaskRunnerHandle::Get()->PostTask(
+ FROM_HERE, base::Bind(transaction->io_callback(), net::ERR_CACHE_RACE));
+ }
+ entry->add_to_entry_queue.clear();
+}
+
void HttpCache::RemoveAllQueuedTransactions(ActiveEntry* entry,
TransactionList* list) {
// Process done_headers_queue before add_to_entry_queue to maintain FIFO
@@ -968,8 +994,8 @@ void HttpCache::RemoveAllQueuedTransactions(ActiveEntry* entry,
void HttpCache::ProcessEntryFailure(ActiveEntry* entry,
Transaction* transaction) {
- // Failure case is either writer failing to completely write the response to
- // the cache or validating transaction received a non-304 response.
+ // The writer failed to completely write the response to
+ // the cache.
if (entry->headers_transaction && transaction != entry->headers_transaction)
RestartHeadersTransaction(entry);
« no previous file with comments | « net/http/http_cache.h ('k') | net/http/http_cache_transaction.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698