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

Unified Diff: net/http/http_response_headers.h

Issue 455623003: stale-while-revalidate experimental implementation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: GetFreshnessLifetimes now returns two times. Duplicate AsyncValidations for the same URL are discar… Created 6 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_response_headers.h
diff --git a/net/http/http_response_headers.h b/net/http/http_response_headers.h
index ddab798c0a2c0795556d1b2da0a583574c581553..79cb26adb012141f35a7eb5399900b8ef7260a75 100644
--- a/net/http/http_response_headers.h
+++ b/net/http/http_response_headers.h
@@ -28,6 +28,12 @@ namespace net {
class HttpByteRange;
+enum ValidationType {
+ VALIDATION_NONE = 0, // the resource is fresh
rvargas (doing something else) 2014/09/11 02:33:07 nit: Start with uppercase and period at the end.
Adam Rice 2014/09/12 01:46:49 Done.
+ VALIDATION_ASYNCHRONOUS, // the resource requires async revalidation
+ VALIDATION_SYNCHRONOUS // the resource requires sync revalidation
+};
+
// HttpResponseHeaders: parses and holds HTTP response headers.
class NET_EXPORT HttpResponseHeaders
: public base::RefCountedThreadSafe<HttpResponseHeaders> {
@@ -43,6 +49,20 @@ class NET_EXPORT HttpResponseHeaders
static const PersistOptions PERSIST_SANS_RANGES = 1 << 4;
static const PersistOptions PERSIST_SANS_SECURITY_STATE = 1 << 5;
+ struct FreshnessLifetimes {
+ // Initialise |fresh| and set |stale| to 0.
rvargas (doing something else) 2014/09/11 02:33:07 Can we get rid of constructors and destructors? It
Adam Rice 2014/09/12 01:46:49 Done.
+ explicit FreshnessLifetimes(const base::TimeDelta& fresh);
+ // Initialise both fields to zero.
+ FreshnessLifetimes();
+ ~FreshnessLifetimes();
+
+ // How long the resource will be fresh for.
+ base::TimeDelta fresh;
+ // How long after becoming not fresh that the resource will be usable stale
rvargas (doing something else) 2014/09/11 02:33:07 Suggestion: "... not fresh the resource will be st
Adam Rice 2014/09/12 01:46:49 Done.
+ // (if async revalidation is enabled).
+ base::TimeDelta stale;
+ };
+
static const char kContentRange[];
// Parses the given raw_headers. raw_headers should be formatted thus:
@@ -201,19 +221,27 @@ class NET_EXPORT HttpResponseHeaders
// redirect.
static bool IsRedirectResponseCode(int response_code);
- // Returns true if the response cannot be reused without validation. The
- // result is relative to the current_time parameter, which is a parameter to
- // support unit testing. The request_time parameter indicates the time at
- // which the request was made that resulted in this response, which was
- // received at response_time.
- bool RequiresValidation(const base::Time& request_time,
- const base::Time& response_time,
- const base::Time& current_time) const;
-
- // Returns the amount of time the server claims the response is fresh from
+ // Returns VALIDATION_NONE if the response can be reused without
+ // validation. VALIDATION_ASYNCHRONOUS means the response can be re-used, but
+ // asynchronous revalidation must be performed. VALIDATION_SYNCHRONOUS means
+ // that the result cannot be reused without revalidation.
+ // The result is relative to the current_time parameter, which is
+ // a parameter to support unit testing. The request_time parameter indicates
+ // the time at which the request was made that resulted in this response,
+ // which was received at response_time.
+ ValidationType RequiresValidation(const base::Time& request_time,
+ const base::Time& response_time,
+ const base::Time& current_time) const;
+
+ // Calculates the amount of time the server claims the response is fresh from
// the time the response was generated. See section 13.2.4 of RFC 2616. See
- // RequiresValidation for a description of the response_time parameter.
- base::TimeDelta GetFreshnessLifetime(const base::Time& response_time) const;
+ // RequiresValidation for a description of the response_time parameter. Sets
+ // |Freshness.usable| to false and |Freshness.lifetime| to zero if there is a
rvargas (doing something else) 2014/09/11 02:33:07 Stale comment Maybe mention rfc 5861
Adam Rice 2014/09/12 01:46:49 Sorry about that. Updated.
+ // header that prohibits the use of the response. This allows us to
+ // distinguish cases when a stale response cannot be used by
+ // stale-while-revalidate.
+ FreshnessLifetimes GetFreshnessLifetimes(
+ const base::Time& response_time) const;
// Returns the age of the response. See section 13.2.3 of RFC 2616.
// See RequiresValidation for a description of this method's parameters.

Powered by Google App Engine
This is Rietveld 408576698