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

Unified Diff: net/http/http_cache_transaction.h

Issue 1230113012: [net] Better StopCaching() handling for HttpCache::Transaction. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 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_transaction.h
diff --git a/net/http/http_cache_transaction.h b/net/http/http_cache_transaction.h
index ec88da37e1416febc51c03d538ea5a0af79d2d0a..a094d93f93650b7607cae5cadea23d4adbba4075 100644
--- a/net/http/http_cache_transaction.h
+++ b/net/http/http_cache_transaction.h
@@ -210,15 +210,17 @@ class HttpCache::Transaction : public HttpTransaction {
STATE_CACHE_READ_METADATA,
STATE_CACHE_READ_METADATA_COMPLETE,
- // These states are entered from Read/AddTruncatedFlag.
+ // These states are entered from Read
rvargas (doing something else) 2015/08/19 23:46:39 nit: period at the end.
asanka 2015/09/04 19:09:04 Done.
+ STATE_RELEASE_CACHE_ENTRY_AND_CONTINUE_USING_NETWORK,
STATE_NETWORK_READ,
STATE_NETWORK_READ_COMPLETE,
STATE_CACHE_READ_DATA,
STATE_CACHE_READ_DATA_COMPLETE,
STATE_CACHE_WRITE_DATA,
STATE_CACHE_WRITE_DATA_COMPLETE,
+
STATE_CACHE_WRITE_TRUNCATED_RESPONSE,
- STATE_CACHE_WRITE_TRUNCATED_RESPONSE_COMPLETE
+ STATE_CACHE_WRITE_TRUNCATED_RESPONSE_COMPLETE,
};
// Used for categorizing transactions for reporting in histograms. Patterns
@@ -290,6 +292,7 @@ class HttpCache::Transaction : public HttpTransaction {
int DoCacheWriteDataComplete(int result);
int DoCacheWriteTruncatedResponse();
int DoCacheWriteTruncatedResponseComplete(int result);
+ int DoReleaseCacheEntryAndContinueUsingNetwork();
rvargas (doing something else) 2015/08/19 23:46:39 nit: keep the same order of the enum.
asanka 2015/09/04 19:09:04 Done.
// These functions are involved in a field trial testing storing certificates
// in seperate entries from the HttpResponseInfo.
@@ -375,6 +378,42 @@ class HttpCache::Transaction : public HttpTransaction {
// is always "OK".
int OnWriteResponseInfoToEntryComplete(int result);
+ // Requested state of the cache entry after a call to
+ // ReleaseCacheEntry().
+ enum CacheEntryDisposition {
+ // Preserve the cache entry if it already existed prior to this cache
+ // transaction.
+ CACHE_ENTRY_PRESERVE_PREEXISTING,
+
+ // Try to preserve the existing cache entry. It will be marked as truncated
+ // if necessary.
+ CACHE_ENTRY_PRESERVE,
+
+ // Doom the cache entry.
+ CACHE_ENTRY_DOOM
+ };
+
+ // Called when the client has finished with the cache entry. May start the
+ // state machine again. Hence should only be called when there are no more
+ // pending operations.
+ //
+ // If |entry_disposition| is CACHE_ENTRY_PRESERVE_PREEXISTING:
+ // If the cache entry is sparse or was not created by this transaction, then
+ // acts as if |entry_disposition| was CACHE_ENTRY_PRESERVE. Otherwise acts
+ // as if it was CACHE_ENTRY_DOOM.
+ //
+ // If |entry_disposition| is CACHE_ENTRY_PRESERVE:
+ // If the cache entry was written completely or if the entry is resumable or
+ // sparse, then preserves the cache entry. If a non-sparse entry wasn't
+ // written completely, it will be marked as truncated.
+ //
+ // If |entry_disposition| is CACHE_ENTRY_DOOM:
+ // Marks the cache entry as doomed.
rvargas (doing something else) 2015/08/19 23:46:39 nit: Dooms the entry (there's no really a doom mar
asanka 2015/09/04 19:09:04 Done.
+ //
+ // In all cases other than the case where the entry needs to be marked as
+ // truncated, this call will completely synchronously.
+ int ReleaseCacheEntry(CacheEntryDisposition entry_disposition);
+
// Called when we are done writing to the cache entry.
void DoneWritingToEntry(bool success);
@@ -403,6 +442,8 @@ class HttpCache::Transaction : public HttpTransaction {
// between the byte range request and the cached entry.
int DoRestartPartialRequest();
+ void OnCacheReleaseComplete(const base::Closure& closure, int result);
+
// Resets the relavant internal state to remove traces of internal processing
// related to range requests. Deletes |partial_| if |delete_object| is true.
void ResetPartialState(bool delete_object);
@@ -442,15 +483,16 @@ class HttpCache::Transaction : public HttpTransaction {
std::string cache_key_;
Mode mode_;
bool reading_; // We are already reading. Never reverts to false once set.
- bool invalid_range_; // We may bypass the cache for this request.
- bool truncated_; // We don't have all the response data.
- bool is_sparse_; // The data is stored in sparse byte ranges.
+ bool invalid_range_; // We may bypass the cache for this request.
+ bool truncated_; // We don't have all the response data.
+ bool is_sparse_; // The data is stored in sparse byte ranges.
bool range_requested_; // The user requested a byte range.
- bool handling_206_; // We must deal with this 206 response.
- bool cache_pending_; // We are waiting for the HttpCache.
- bool done_reading_; // All available data was read.
- bool vary_mismatch_; // The request doesn't match the stored vary data.
+ bool handling_206_; // We must deal with this 206 response.
+ bool cache_pending_; // We are waiting for the HttpCache.
+ bool done_reading_; // All available data was written to the cache entry.
+ bool vary_mismatch_; // The request doesn't match the stored vary data.
bool couldnt_conditionalize_request_;
+ bool stopped_caching_; // Avoid further writes to the cache.
bool bypass_lock_for_test_; // A test is exercising the cache lock.
bool fail_conditionalization_for_test_; // Fail ConditionalizeRequest.
scoped_refptr<IOBuffer> read_buf_;

Powered by Google App Engine
This is Rietveld 408576698