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

Unified Diff: net/http/http_cache.cc

Issue 2774603003: Doom and create new entry when validation is not a match (Closed)
Patch Set: Feedback addressed. Created 3 years, 6 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
Index: net/http/http_cache.cc
diff --git a/net/http/http_cache.cc b/net/http/http_cache.cc
index f8fc1fb4eec9fcfad321b424145aaedbc03fd288..030510186a83d03c426575f6ee94021e5fc878aa 100644
--- a/net/http/http_cache.cc
+++ b/net/http/http_cache.cc
@@ -948,6 +948,34 @@ void HttpCache::DoneReadingFromEntry(ActiveEntry* entry,
ProcessQueuedTransactions(entry);
}
+void HttpCache::DoomEntryValidationNoMatch(ActiveEntry* entry,
+ Transaction* transaction) {
jkarlin 2017/06/16 18:28:01 transaction is unused except for a dcheck, let's r
shivanisha 2017/06/27 15:31:14 done
+ // Validating transaction received a non-matching response.
+
+ DCHECK(transaction == entry->headers_transaction);
+
+ 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.
jkarlin 2017/06/16 18:28:01 Seems like this comment should be the first line o
shivanisha 2017/06/27 15:31:14 done
+
+ 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
jkarlin 2017/06/16 18:28:01 s/their/its/
shivanisha 2017/06/27 15:31:14 done
+ // for them 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
@@ -964,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
jkarlin 2017/06/16 18:28:01 The writer failed ...
shivanisha 2017/06/27 15:31:14 done
+ // the cache.
if (entry->headers_transaction && transaction != entry->headers_transaction)
RestartHeadersTransaction(entry, transaction);

Powered by Google App Engine
This is Rietveld 408576698