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

Side by Side 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: Support the bandwidth reduction proxy. 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 unified diff | Download patch
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 25 matching lines...) Expand all
36 typedef int PersistOptions; 36 typedef int PersistOptions;
37 static const PersistOptions PERSIST_RAW = -1; // Raw, unparsed headers. 37 static const PersistOptions PERSIST_RAW = -1; // Raw, unparsed headers.
38 static const PersistOptions PERSIST_ALL = 0; // Parsed headers. 38 static const PersistOptions PERSIST_ALL = 0; // Parsed headers.
39 static const PersistOptions PERSIST_SANS_COOKIES = 1 << 0; 39 static const PersistOptions PERSIST_SANS_COOKIES = 1 << 0;
40 static const PersistOptions PERSIST_SANS_CHALLENGES = 1 << 1; 40 static const PersistOptions PERSIST_SANS_CHALLENGES = 1 << 1;
41 static const PersistOptions PERSIST_SANS_HOP_BY_HOP = 1 << 2; 41 static const PersistOptions PERSIST_SANS_HOP_BY_HOP = 1 << 2;
42 static const PersistOptions PERSIST_SANS_NON_CACHEABLE = 1 << 3; 42 static const PersistOptions PERSIST_SANS_NON_CACHEABLE = 1 << 3;
43 static const PersistOptions PERSIST_SANS_RANGES = 1 << 4; 43 static const PersistOptions PERSIST_SANS_RANGES = 1 << 4;
44 static const PersistOptions PERSIST_SANS_SECURITY_STATE = 1 << 5; 44 static const PersistOptions PERSIST_SANS_SECURITY_STATE = 1 << 5;
45 45
46 enum ValidationType {
47 VALIDATION_NONE = 0, // the resource is fresh
48 VALIDATION_ASYNCHRONOUS, // the resource requires async revalidation
49 VALIDATION_SYNCHRONOUS // the resource requires sync revalidation
50 };
51
52 enum FreshnessType { NEVER_FRESH, MAYBE_FRESH };
53
46 static const char kContentRange[]; 54 static const char kContentRange[];
47 55
48 // Parses the given raw_headers. raw_headers should be formatted thus: 56 // Parses the given raw_headers. raw_headers should be formatted thus:
49 // includes the http status response line, each line is \0-terminated, and 57 // includes the http status response line, each line is \0-terminated, and
50 // it's terminated by an empty line (ie, 2 \0s in a row). 58 // it's terminated by an empty line (ie, 2 \0s in a row).
51 // (Note that line continuations should have already been joined; 59 // (Note that line continuations should have already been joined;
52 // see HttpUtil::AssembleRawHeaders) 60 // see HttpUtil::AssembleRawHeaders)
53 // 61 //
54 // HttpResponseHeaders does not perform any encoding changes on the input. 62 // HttpResponseHeaders does not perform any encoding changes on the input.
55 // 63 //
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 bool GetCharset(std::string* charset) const; 202 bool GetCharset(std::string* charset) const;
195 203
196 // Returns true if this response corresponds to a redirect. The target 204 // Returns true if this response corresponds to a redirect. The target
197 // location of the redirect is optionally returned if location is non-null. 205 // location of the redirect is optionally returned if location is non-null.
198 bool IsRedirect(std::string* location) const; 206 bool IsRedirect(std::string* location) const;
199 207
200 // Returns true if the HTTP response code passed in corresponds to a 208 // Returns true if the HTTP response code passed in corresponds to a
201 // redirect. 209 // redirect.
202 static bool IsRedirectResponseCode(int response_code); 210 static bool IsRedirectResponseCode(int response_code);
203 211
204 // Returns true if the response cannot be reused without validation. The 212 // Returns VALIDATION_NONE if the response can be reused without
205 // result is relative to the current_time parameter, which is a parameter to 213 // validation. VALIDATION_ASYNCHRONOUS means the response can be re-used, but
206 // support unit testing. The request_time parameter indicates the time at 214 // asynchronous revalidation must be performed. VALIDATION_SYNCHRONOUS means
207 // which the request was made that resulted in this response, which was 215 // that the result cannot be reused without revalidation.
208 // received at response_time. 216 // The result is relative to the current_time parameter, which is
209 bool RequiresValidation(const base::Time& request_time, 217 // a parameter to support unit testing. The request_time parameter indicates
210 const base::Time& response_time, 218 // the time at which the request was made that resulted in this response,
211 const base::Time& current_time) const; 219 // which was received at response_time.
220 ValidationType RequiresValidation(const base::Time& request_time,
221 const base::Time& response_time,
222 const base::Time& current_time) const;
212 223
213 // Returns the amount of time the server claims the response is fresh from 224 // Calculates the amount of time the server claims the response is fresh from
214 // the time the response was generated. See section 13.2.4 of RFC 2616. See 225 // the time the response was generated. See section 13.2.4 of RFC 2616. See
215 // RequiresValidation for a description of the response_time parameter. 226 // RequiresValidation for a description of the response_time parameter.
216 base::TimeDelta GetFreshnessLifetime(const base::Time& response_time) const; 227 // Returns NEVER_FRESH and sets |lifetime| to zero if there is a header that
228 // prohibits the use of the response, otherwise returns MAYBE_FRESH. This
229 // allows us to distinguish cases when a stale response cannot be used by
230 // stale-while-revalidate.
231 FreshnessType GetFreshnessLifetime(const base::Time& response_time,
232 base::TimeDelta* lifetime) const;
217 233
218 // Returns the age of the response. See section 13.2.3 of RFC 2616. 234 // Returns the age of the response. See section 13.2.3 of RFC 2616.
219 // See RequiresValidation for a description of this method's parameters. 235 // See RequiresValidation for a description of this method's parameters.
220 base::TimeDelta GetCurrentAge(const base::Time& request_time, 236 base::TimeDelta GetCurrentAge(const base::Time& request_time,
221 const base::Time& response_time, 237 const base::Time& response_time,
222 const base::Time& current_time) const; 238 const base::Time& current_time) const;
223 239
224 // The following methods extract values from the response headers. If a 240 // The following methods extract values from the response headers. If a
225 // value is not present, then false is returned. Otherwise, true is returned 241 // value is not present, then false is returned. Otherwise, true is returned
226 // and the out param is assigned to the corresponding value. 242 // and the out param is assigned to the corresponding value.
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 404
389 // The parsed http version number (not normalized). 405 // The parsed http version number (not normalized).
390 HttpVersion parsed_http_version_; 406 HttpVersion parsed_http_version_;
391 407
392 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders); 408 DISALLOW_COPY_AND_ASSIGN(HttpResponseHeaders);
393 }; 409 };
394 410
395 } // namespace net 411 } // namespace net
396 412
397 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_ 413 #endif // NET_HTTP_HTTP_RESPONSE_HEADERS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698