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

Unified Diff: net/http/http_cache_transaction.h

Issue 2721933002: HttpCache::Transaction layer allowing parallel validation (Closed)
Patch Set: Feedback addressed (based on refs/heads/master@{#459057}) Created 3 years, 9 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 a8fca54228e8d8f6cadda6b947e90ab7bf24cd94..6e250dd6f1cd5b795c97872ff644cc757f7fdeda 100644
--- a/net/http/http_cache_transaction.h
+++ b/net/http/http_cache_transaction.h
@@ -164,6 +164,13 @@ class HttpCache::Transaction : public HttpTransaction {
int ResumeNetworkStart() override;
void GetConnectionAttempts(ConnectionAttempts* out) const override;
+ // Invoked when parallel validation cannot proceed due to response failure
+ // and this transaction needs to be restarted.
+ void SetValidatingCannotProceed();
Randy Smith (Not in Mondays) 2017/03/31 19:26:12 So conceptually this seems like the same thing as
shivanisha 2017/04/03 20:16:49 Combined the 2 in the following manner: - Created
Randy Smith (Not in Mondays) 2017/04/04 21:21:16 Awesome! Thank you.
+
+ // Converts mode_ to read-only and resets if there is a network transaction.
+ void ConvertToReadMode();
+
// Returns the estimate of dynamically allocated memory in bytes.
size_t EstimateMemoryUsage() const;
@@ -220,6 +227,8 @@ class HttpCache::Transaction : public HttpTransaction {
STATE_PARTIAL_HEADERS_RECEIVED,
STATE_CACHE_READ_METADATA,
STATE_CACHE_READ_METADATA_COMPLETE,
+ STATE_FINISH_HEADERS,
+ STATE_FINISH_HEADERS_COMPLETE,
// These states are entered from Read/AddTruncatedFlag.
STATE_NETWORK_READ,
@@ -247,6 +256,7 @@ class HttpCache::Transaction : public HttpTransaction {
// Runs the state transition loop. Resets and calls |callback_| on exit,
// unless the return value is ERR_IO_PENDING.
int DoLoop(int result);
+ int DoLoopImpl(int result);
Randy Smith (Not in Mondays) 2017/03/31 19:26:12 I don't think this exists anymore?
shivanisha 2017/04/03 20:16:49 Removed
// Each of these methods corresponds to a State value. If there is an
// argument, the value corresponds to the return of the previous state or
@@ -286,6 +296,8 @@ class HttpCache::Transaction : public HttpTransaction {
int DoTruncateCachedMetadata();
int DoTruncateCachedMetadataComplete(int result);
int DoPartialHeadersReceived();
+ int DoFinishHeaders(int result);
+ int DoFinishHeadersComplete(int result);
int DoCacheReadMetadata();
int DoCacheReadMetadataComplete(int result);
int DoNetworkRead();
@@ -414,6 +426,13 @@ class HttpCache::Transaction : public HttpTransaction {
// |old_network_trans_load_timing_|, which must be NULL when this is called.
void ResetNetworkTransaction();
+ // Since a transaction could be doing validation of request headers in
+ // parallel with another request writing response data to the entry, failure
+ // to write the data might lead to restarting this request. This function
+ // resets all the required variables to be able to restart the transaction's
+ // state machine.
+ void RestartAfterValidationStarted();
+
// Returns true if we should bother attempting to resume this request if it is
// aborted while in progress. If |has_data| is true, the size of the stored
// data is considered for the result.
@@ -457,6 +476,7 @@ class HttpCache::Transaction : public HttpTransaction {
const HttpResponseInfo* new_response_;
std::string cache_key_;
Mode mode_;
+ Mode original_mode_; // Used when restarting the transaction.
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.
@@ -469,6 +489,9 @@ class HttpCache::Transaction : public HttpTransaction {
bool couldnt_conditionalize_request_;
bool bypass_lock_for_test_; // A test is exercising the cache lock.
bool fail_conditionalization_for_test_; // Fail ConditionalizeRequest.
+ // Parallel validation cannot proceed due to response failure, restart the
+ // transaction.
+ bool validating_cannot_proceed_;
scoped_refptr<IOBuffer> read_buf_;
int io_buf_len_;
int read_offset_;

Powered by Google App Engine
This is Rietveld 408576698