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

Unified Diff: net/http/http_cache_transaction.h

Issue 455623003: stale-while-revalidate experimental implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Stop setting Cache-Control: max-age=0 on async revalidations. Created 6 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 8ba8f676cdefee3fa6e859a5211901a033d64cc4..08abd2d7ef9527b16167aa005216ae183d4bda29 100644
--- a/net/http/http_cache_transaction.h
+++ b/net/http/http_cache_transaction.h
@@ -16,6 +16,7 @@
#include "net/base/request_priority.h"
#include "net/http/http_cache.h"
#include "net/http/http_request_headers.h"
+#include "net/http/http_response_headers.h"
#include "net/http/http_response_info.h"
#include "net/http/http_transaction.h"
@@ -108,6 +109,13 @@ class HttpCache::Transaction : public HttpTransaction {
bypass_lock_for_test_ = true;
}
+ // Used by asynchronous validations to ensure that the asynchronous validation
+ // path isn't re-entered. The LOAD_VALIDATE_CACHE flag cannot be passed to
+ // Start() via the HttpRequestInfo object because it has the side effect of
+ // causing HttpNetworkTransaction to add a Cache-Control: max-age=0 header.
+ // This method must be called before Start().
+ void ValidateInternalCache();
+
// HttpTransaction methods:
virtual int Start(const HttpRequestInfo* request_info,
const CompletionCallback& callback,
@@ -311,8 +319,9 @@ 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();
+ // Called to determine if we need to validate the cache entry before using it,
+ // and whether the validation should be synchronous or asynchronous.
+ HttpResponseHeaders::ValidationType RequiredValidationType();
// 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.
@@ -329,6 +338,9 @@ class HttpCache::Transaction : public HttpTransaction {
// Removes content-length and byte range related info if needed.
void FixHeadersForHead();
+ // Launches an asynchronous revalidation based on this transaction.
+ void TriggerAsyncValidation();
+
// Changes the response code of a range request to be 416 (Requested range not
// satisfiable).
void FailRangeRequest();

Powered by Google App Engine
This is Rietveld 408576698