Index: net/http/http_response_headers.h |
diff --git a/net/http/http_response_headers.h b/net/http/http_response_headers.h |
index 653eacc4d44e30b86d15c41532ec2514ef8ba435..43639916d1fb0e5f4c816cae8181c966a313e97f 100644 |
--- a/net/http/http_response_headers.h |
+++ b/net/http/http_response_headers.h |
@@ -30,12 +30,6 @@ namespace net { |
class HttpByteRange; |
-enum ValidationType { |
- VALIDATION_NONE, // The resource is fresh. |
- 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> { |
@@ -51,12 +45,26 @@ class NET_EXPORT HttpResponseHeaders |
static const PersistOptions PERSIST_SANS_RANGES = 1 << 4; |
static const PersistOptions PERSIST_SANS_SECURITY_STATE = 1 << 5; |
- struct FreshnessLifetimes { |
+ struct ExpirationTimes { |
+ base::Time GetFreshnessExpiry() const { |
+ return corrected_response_time + freshness_lifetime; |
+ } |
+ |
+ base::Time GetStalenessExpiry() const { |
+ return corrected_response_time + staleness_lifetime; |
+ } |
+ |
+ // The |base::Time::Now()| value for which this request would have an age of |
+ // exactly zero. You can subtract this from |base::Time::Now()| to get the |
+ // current age. |
+ base::Time corrected_response_time; |
+ |
// How long the resource will be fresh for. |
- base::TimeDelta freshness; |
+ base::TimeDelta freshness_lifetime; |
+ |
// How long after becoming not fresh that the resource will be stale but |
// usable (if async revalidation is enabled). |
- base::TimeDelta staleness; |
+ base::TimeDelta staleness_lifetime; |
}; |
static const char kContentRange[]; |
@@ -225,17 +233,12 @@ class NET_EXPORT HttpResponseHeaders |
// redirect. |
static bool IsRedirectResponseCode(int response_code); |
- // 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; |
+ // Returns an ExpirationTimes struct which can be used to calculate the |
+ // freshness and stale-white-revalidate status of this response. The values in |
+ // the ExpirationTimes struct do not depend on the current time, so they can |
+ // be stored and used later as well. |
+ ExpirationTimes GetExpirationTimes(const base::Time& request_time, |
+ const base::Time& response_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 |
@@ -243,14 +246,9 @@ class NET_EXPORT HttpResponseHeaders |
// the definition of FreshnessLifetimes above for the meaning of the return |
// value. See RFC 5861 section 3 for the definition of |
// 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. |
- base::TimeDelta GetCurrentAge(const base::Time& request_time, |
- const base::Time& response_time, |
- const base::Time& current_time) const; |
+ void CalculateLifetimes(const base::Time& response_time, |
+ base::TimeDelta* out_freshness_lifetime, |
+ base::TimeDelta* out_staleness_lifetime) const; |
// The following methods extract values from the response headers. If a |
// value is not present, or is invalid, then false is returned. Otherwise, |