Chromium Code Reviews| 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..ac7c351bd519117d414cfb19c8a85383c07b213c 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. | 
| 
 
mmenke
2014/10/09 14:29:58
Does this "= 0" give us anything?
 
Adam Rice
2014/10/20 09:31:24
No. But all the cool kids are doing it.
Removed i
 
 | 
| + 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,14 @@ class NET_EXPORT HttpResponseHeaders | 
| static const PersistOptions PERSIST_SANS_RANGES = 1 << 4; | 
| static const PersistOptions PERSIST_SANS_SECURITY_STATE = 1 << 5; | 
| + struct FreshnessLifetimes { | 
| + // How long the resource will be fresh for. | 
| + base::TimeDelta fresh; | 
| + // How long after becoming not fresh that the resource will be stale but | 
| + // usable (if async revalidation is enabled). | 
| + base::TimeDelta stale; | 
| 
 
mmenke
2014/10/09 14:29:58
I think these names are very confusing - it doesn'
 
rvargas (doing something else)
2014/10/09 19:13:45
FreshnessLifetime is the standard term for time de
 
mmenke
2014/10/09 19:32:01
Thanks for the link!  I guess this function only m
 
rvargas (doing something else)
2014/10/09 21:29:32
GetFreshnessLifetimes() is used by RequiresValidat
 
rvargas (doing something else)
2014/10/09 21:47:14
BTW, another thing to consider is how the code rea
 
mmenke
2014/10/09 21:50:28
I was looking at it in chrome_network_delegate.cc.
 
Adam Rice
2014/10/20 09:31:24
I have implemented the freshness/staleness approac
 
 | 
| + }; | 
| + | 
| static const char kContentRange[]; | 
| // Parses the given raw_headers. raw_headers should be formatted thus: | 
| @@ -201,19 +215,28 @@ 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 | 
| + // |FreshnessLifetimes.fresh| to the length of time the response may be used | 
| + // without revalidation, and |FreshnessLifetimes.stale| to the length of time | 
| 
 
mmenke
2014/10/09 14:29:58
nit:  Only use || around argument names.  I docume
 
Adam Rice
2014/10/20 09:31:24
Done.
 
 | 
| + // the response may be used stale with asynchronous revalidation if | 
| + // stale-while-revalidate support is enabled. 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. |