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

Unified Diff: net/http/http_cache.h

Issue 1230113012: [net] Better StopCaching() handling for HttpCache::Transaction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing MockTransaction initializers Created 5 years, 3 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.h
diff --git a/net/http/http_cache.h b/net/http/http_cache.h
index 026d476e92f0dcfd36c309d07c5016ddfaa04854..c1bea7a7ad6454e8858fadaf4160f05743ea8eb2 100644
--- a/net/http/http_cache.h
+++ b/net/http/http_cache.h
@@ -240,6 +240,9 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory,
kNumCacheEntryDataIndices
};
+ // Used with DoneWithEntry() to indicate the state of the entry.
+ enum class EntryState { KEEP, DOOM };
+
class MetadataWriter;
class QuicServerInfoFactoryAdaptor;
class Transaction;
@@ -347,17 +350,20 @@ class NET_EXPORT HttpCache : public HttpTransactionFactory,
// one (in this case, the entry is no longer valid).
int AddTransactionToEntry(ActiveEntry* entry, Transaction* trans);
- // Called when the transaction has finished working with this entry. |cancel|
- // is true if the operation was cancelled by the caller instead of running
- // to completion.
- void DoneWithEntry(ActiveEntry* entry, Transaction* trans, bool cancel);
-
- // Called when the transaction has finished writing to this entry. |success|
- // is false if the cache entry should be deleted.
- void DoneWritingToEntry(ActiveEntry* entry, bool success);
-
- // Called when the transaction has finished reading from this entry.
- void DoneReadingFromEntry(ActiveEntry* entry, Transaction* trans);
+ // Removes |trans| from |entry|. |trans| is required to be a reader or writer
+ // that was added to |trans| by AddTransactionToEntry(). For writers,
+ // |entry_state| indicates whether the cache entry should be kept or
+ // discarded.
+ //
+ // If |entry_state| is DOOM, then the cache entry is destroyed and any
+ // pending transactions that were formerly waiting to be added to |entry| will
+ // receive ERR_CACHE_RACE.
+ //
+ // If |entry_state| is KEEP, then |entry| is assumed to be safe for
+ // further consumption and pending transaction will be permitted to use it.
+ void DoneWithEntry(ActiveEntry* entry,
+ Transaction* trans,
+ EntryState entry_state);
// Converts the active writer transaction to a reader so that other
// transactions can start reading from this entry.

Powered by Google App Engine
This is Rietveld 408576698