Index: net/http/http_cache.cc |
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc |
index 1a5dffdeee4979956770f6895f946801505c7d0a..d16e3ea5a211ce6ce6ae1e4c96ea4c1849e5b1b7 100644 |
--- a/net/http/http_cache.cc |
+++ b/net/http/http_cache.cc |
@@ -946,6 +946,36 @@ void HttpCache::DoneReadingFromEntry(ActiveEntry* entry, |
ProcessQueuedTransactions(entry); |
} |
+void HttpCache::DoomEntryValidationNoMatch(ActiveEntry* entry, |
+ Transaction* transaction) { |
+ // Validating transaction received a non-matching response. |
+ |
+ // TODO(shivanisha) Can transaction be a writer in case of partial requests? |
jkarlin
2017/06/09 17:04:49
s/a writer/the writer/
shivanisha
2017/06/12 18:01:22
done
|
+ // Handlie the writer case if that's possible. |
jkarlin
2017/06/09 17:04:49
Seems like we need to answer that question before
jkarlin
2017/06/09 17:04:49
s/Handlie/Handle/
shivanisha
2017/06/12 18:01:22
Handled this TODO in CanTransactionWriteResponseHe
|
+ CHECK(transaction == entry->headers_transaction); |
jkarlin
2017/06/09 17:04:49
Let's DCHECK this and save CHECK for cases where w
shivanisha
2017/06/12 18:01:22
done
|
+ |
+ entry->headers_transaction = nullptr; |
+ if (entry->HasNoTransactions() && !entry->will_process_queued_transactions) { |
+ entry->disk_entry->Doom(); |
+ DestroyEntry(entry); |
+ return; |
+ } |
+ |
+ // Restart only add_to_entry_queue transactions. |
+ |
+ DoomActiveEntry(entry->disk_entry->GetKey()); |
+ // Post task here to avoid a race in creating the entry between |transaction| |
+ // and the add_to_entry_queue transactions. Reset the queued transactions' |
+ // cache pending state so that in case their destructor is invoked, it's ok |
+ // for them to not be found in this entry. |
+ for (auto* transaction : entry->add_to_entry_queue) { |
+ transaction->ResetCachePendingState(); |
jkarlin
2017/06/09 17:04:49
Why is this necessary? Won't they all have this re
shivanisha
2017/06/12 18:01:23
I am thinking of the race where we remove them fro
|
+ 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 |
@@ -962,8 +992,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. |
+ // Writer failed to completely write the response to |
+ // the cache. |
if (entry->headers_transaction && transaction != entry->headers_transaction) |
RestartHeadersTransaction(entry, transaction); |