Index: net/http/http_cache_transaction.h |
diff --git a/net/http/http_cache_transaction.h b/net/http/http_cache_transaction.h |
index 51c0db70256cbd31505ca20ffba6486ab4c36aad..b0f20b3b49e380163d76f8424ca3ab84d0afd46b 100644 |
--- a/net/http/http_cache_transaction.h |
+++ b/net/http/http_cache_transaction.h |
@@ -244,6 +244,14 @@ class HttpCache::Transaction : public HttpTransaction { |
VALIDATION_CAUSE_MAX |
}; |
+ // What, if any, network confirmation for a cache entry is required. |
+ enum EntryValidationStatus { |
+ USABLE, // Can be used without server ok. |
+ REQUIRES_VALIDATION, // Need to check with server. |
+ REQUIRES_VALIDATION_VARY_MISMATCH, // Vary mismatch allows last-modified. |
+ REQUIRES_REFETCH // Entry needs to be fetched. |
shivanisha
2017/05/02 16:03:26
nit: prefer enum class for type safety.
|
+ }; |
+ |
// Runs the state transition loop. Resets and calls |callback_| on exit, |
// unless the return value is ERR_IO_PENDING. |
int DoLoop(int result); |
@@ -338,12 +346,12 @@ class HttpCache::Transaction : public HttpTransaction { |
// Returns network error code. |
int RestartNetworkRequestWithAuth(const AuthCredentials& credentials); |
- // Called to determine if we need to validate the cache entry before using it. |
- bool RequiresValidation(); |
+ // Helper function for GetEntryValidationStatus(). |*vary_mismatch| will |
+ // be set to false unless validation is required because of a vary mismatch. |
+ bool RequiresValidation(bool* vary_mismatch) const; |
- // Called to make the request conditional (to ask the server if the cached |
- // copy is valid). Returns true if able to make the request conditional. |
- bool ConditionalizeRequest(); |
+ // Return the type of network validation required by the entry. |
+ EntryValidationStatus GetEntryValidationStatus() const; |
// Makes sure that a 206 response is expected. Returns true on success. |
// On success, handling_206_ will be set to true if we are processing a |
@@ -464,7 +472,6 @@ class HttpCache::Transaction : public HttpTransaction { |
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 couldnt_conditionalize_request_; |
bool bypass_lock_for_test_; // A test is exercising the cache lock. |
bool fail_conditionalization_for_test_; // Fail ConditionalizeRequest. |
@@ -476,19 +483,21 @@ class HttpCache::Transaction : public HttpTransaction { |
std::unique_ptr<PartialData> partial_; // We are dealing with range requests. |
CompletionCallback io_callback_; |
- // Members used to track data for histograms. |
+ // Members used to track data for histograms. The state of these fields |
+ // do not affect the behavior of the transaction, and hence can be changed |
+ // in const methods. |
// This cache_entry_status_ takes precedence over |
// response_.cache_entry_status. In fact, response_.cache_entry_status must be |
// kept in sync with cache_entry_status_ (via SetResponse and |
// UpdateCacheEntryStatus). |
HttpResponseInfo::CacheEntryStatus cache_entry_status_; |
- ValidationCause validation_cause_; |
+ mutable ValidationCause validation_cause_; |
base::TimeTicks entry_lock_waiting_since_; |
base::TimeTicks first_cache_access_since_; |
base::TimeTicks send_request_since_; |
base::Time open_entry_last_used_; |
- base::TimeDelta stale_entry_freshness_; |
- base::TimeDelta stale_entry_age_; |
+ mutable base::TimeDelta stale_entry_freshness_; |
+ mutable base::TimeDelta stale_entry_age_; |
int64_t total_received_bytes_; |
int64_t total_sent_bytes_; |