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

Side by Side Diff: net/http/http_response_headers.h

Issue 665023002: Post-commit fixes for "stale-while-revalidate..." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/http_response_headers.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef NET_HTTP_HTTP_RESPONSE_HEADERS_H_ 5 #ifndef NET_HTTP_HTTP_RESPONSE_HEADERS_H_
6 #define NET_HTTP_HTTP_RESPONSE_HEADERS_H_ 6 #define NET_HTTP_HTTP_RESPONSE_HEADERS_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 11 matching lines...) Expand all
22 namespace base { 22 namespace base {
23 class Time; 23 class Time;
24 class TimeDelta; 24 class TimeDelta;
25 } 25 }
26 26
27 namespace net { 27 namespace net {
28 28
29 class HttpByteRange; 29 class HttpByteRange;
30 30
31 enum ValidationType { 31 enum ValidationType {
32 VALIDATION_NONE = 0, // The resource is fresh. 32 VALIDATION_NONE, // The resource is fresh.
33 VALIDATION_ASYNCHRONOUS, // The resource requires async revalidation. 33 VALIDATION_ASYNCHRONOUS, // The resource requires async revalidation.
34 VALIDATION_SYNCHRONOUS // The resource requires sync revalidation. 34 VALIDATION_SYNCHRONOUS // The resource requires sync revalidation.
35 }; 35 };
36 36
37 // HttpResponseHeaders: parses and holds HTTP response headers. 37 // HttpResponseHeaders: parses and holds HTTP response headers.
38 class NET_EXPORT HttpResponseHeaders 38 class NET_EXPORT HttpResponseHeaders
39 : public base::RefCountedThreadSafe<HttpResponseHeaders> { 39 : public base::RefCountedThreadSafe<HttpResponseHeaders> {
40 public: 40 public:
41 // Persist options. 41 // Persist options.
42 typedef int PersistOptions; 42 typedef int PersistOptions;
43 static const PersistOptions PERSIST_RAW = -1; // Raw, unparsed headers. 43 static const PersistOptions PERSIST_RAW = -1; // Raw, unparsed headers.
44 static const PersistOptions PERSIST_ALL = 0; // Parsed headers. 44 static const PersistOptions PERSIST_ALL = 0; // Parsed headers.
45 static const PersistOptions PERSIST_SANS_COOKIES = 1 << 0; 45 static const PersistOptions PERSIST_SANS_COOKIES = 1 << 0;
46 static const PersistOptions PERSIST_SANS_CHALLENGES = 1 << 1; 46 static const PersistOptions PERSIST_SANS_CHALLENGES = 1 << 1;
47 static const PersistOptions PERSIST_SANS_HOP_BY_HOP = 1 << 2; 47 static const PersistOptions PERSIST_SANS_HOP_BY_HOP = 1 << 2;
48 static const PersistOptions PERSIST_SANS_NON_CACHEABLE = 1 << 3; 48 static const PersistOptions PERSIST_SANS_NON_CACHEABLE = 1 << 3;
49 static const PersistOptions PERSIST_SANS_RANGES = 1 << 4; 49 static const PersistOptions PERSIST_SANS_RANGES = 1 << 4;
50 static const PersistOptions PERSIST_SANS_SECURITY_STATE = 1 << 5; 50 static const PersistOptions PERSIST_SANS_SECURITY_STATE = 1 << 5;
51 51
52 struct FreshnessLifetimes { 52 struct FreshnessLifetimes {
53 // How long the resource will be fresh for. 53 // How long the resource will be fresh for.
54 base::TimeDelta fresh; 54 base::TimeDelta freshness;
55 // How long after becoming not fresh that the resource will be stale but 55 // How long after becoming not fresh that the resource will be stale but
56 // usable (if async revalidation is enabled). 56 // usable (if async revalidation is enabled).
57 base::TimeDelta stale; 57 base::TimeDelta staleness;
58 }; 58 };
59 59
60 static const char kContentRange[]; 60 static const char kContentRange[];
61 61
62 // Parses the given raw_headers. raw_headers should be formatted thus: 62 // Parses the given raw_headers. raw_headers should be formatted thus:
63 // includes the http status response line, each line is \0-terminated, and 63 // includes the http status response line, each line is \0-terminated, and
64 // it's terminated by an empty line (ie, 2 \0s in a row). 64 // it's terminated by an empty line (ie, 2 \0s in a row).
65 // (Note that line continuations should have already been joined; 65 // (Note that line continuations should have already been joined;
66 // see HttpUtil::AssembleRawHeaders) 66 // see HttpUtil::AssembleRawHeaders)
67 // 67 //
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 // The result is relative to the current_time parameter, which is 222 // The result is relative to the current_time parameter, which is
223 // a parameter to support unit testing. The request_time parameter indicates 223 // a parameter to support unit testing. The request_time parameter indicates
224 // the time at which the request was made that resulted in this response, 224 // the time at which the request was made that resulted in this response,
225 // which was received at response_time. 225 // which was received at response_time.
226 ValidationType RequiresValidation(const base::Time& request_time, 226 ValidationType RequiresValidation(const base::Time& request_time,
227 const base::Time& response_time, 227 const base::Time& response_time,
228 const base::Time& current_time) const; 228 const base::Time& current_time) const;
229 229
230 // Calculates the amount of time the server claims the response is fresh from 230 // Calculates the amount of time the server claims the response is fresh from
231 // the time the response was generated. See section 13.2.4 of RFC 2616. See 231 // the time the response was generated. See section 13.2.4 of RFC 2616. See
232 // RequiresValidation for a description of the response_time parameter. Sets 232 // RequiresValidation for a description of the response_time parameter. See
233 // |FreshnessLifetimes.fresh| to the length of time the response may be used 233 // the definition of FreshnessLifetimes above for the meaning of the return
234 // without revalidation, and |FreshnessLifetimes.stale| to the length of time 234 // value. See RFC 5861 section 3 for the definition of
235 // the response may be used stale with asynchronous revalidation if 235 // stale-while-revalidate.
236 // stale-while-revalidate support is enabled. See RFC 5861 section 3 for the
237 // definition of stale-while-revalidate.
238 FreshnessLifetimes GetFreshnessLifetimes( 236 FreshnessLifetimes GetFreshnessLifetimes(
239 const base::Time& response_time) const; 237 const base::Time& response_time) const;
240 238
241 // Returns the age of the response. See section 13.2.3 of RFC 2616. 239 // Returns the age of the response. See section 13.2.3 of RFC 2616.
242 // See RequiresValidation for a description of this method's parameters. 240 // See RequiresValidation for a description of this method's parameters.
243 base::TimeDelta GetCurrentAge(const base::Time& request_time, 241 base::TimeDelta GetCurrentAge(const base::Time& request_time,
244 const base::Time& response_time, 242 const base::Time& response_time,
245 const base::Time& current_time) const; 243 const base::Time& current_time) const;
246 244
247 // The following methods extract values from the response headers. If a 245 // The following methods extract values from the response headers. If a
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 409
412 // The parsed http version number (not normalized). 410 // The parsed http version number (not normalized).
413 HttpVersion parsed_http_version_; 411 HttpVersion parsed_http_version_;
414 412
415 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); 413 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders);
416 }; 414 };
417 415
418 } // namespace net 416 } // namespace net
419 417
420 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ 418 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_
OLDNEW
« no previous file with comments | « net/http/http_cache_transaction.cc ('k') | net/http/http_response_headers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698