| 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..e6bbf2e58d6c33d357e87b9e1b8f8b3a217b1124 100644
|
| --- a/net/http/http_response_headers.h
|
| +++ b/net/http/http_response_headers.h
|
| @@ -43,6 +43,25 @@ class NET_EXPORT HttpResponseHeaders
|
| static const PersistOptions PERSIST_SANS_RANGES = 1 << 4;
|
| static const PersistOptions PERSIST_SANS_SECURITY_STATE = 1 << 5;
|
|
|
| + enum ValidationType {
|
| + VALIDATION_NONE = 0, // the resource is fresh
|
| + VALIDATION_ASYNCHRONOUS, // the resource requires async revalidation
|
| + VALIDATION_SYNCHRONOUS // the resource requires sync revalidation
|
| + };
|
| +
|
| + struct Freshness {
|
| + // Construct an "unusable" Freshness entry (lifetime = 0, usable = false)
|
| + Freshness();
|
| + // Construct a "usable" Freshness entry (lifetime >= 0, usable = true)
|
| + explicit Freshness(const base::TimeDelta& lifetime);
|
| + ~Freshness();
|
| +
|
| + // True if the response might be usable (depending on freshness).
|
| + const bool usable;
|
| + // Invariant: if usable is false, lifetime is 0.
|
| + const base::TimeDelta lifetime;
|
| + };
|
| +
|
| static const char kContentRange[];
|
|
|
| // Parses the given raw_headers. raw_headers should be formatted thus:
|
| @@ -201,19 +220,26 @@ 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
|
| + // 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.
|
| + Freshness GetFreshnessLifetime(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.
|
|
|