| OLD | NEW |
| 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_VARY_DATA_H_ | 5 #ifndef NET_HTTP_HTTP_VARY_DATA_H_ |
| 6 #define NET_HTTP_HTTP_VARY_DATA_H_ | 6 #define NET_HTTP_HTTP_VARY_DATA_H_ |
| 7 | 7 |
| 8 #include "base/md5.h" | 8 #include "base/md5.h" |
| 9 #include "net/base/net_export.h" | 9 #include "net/base/net_export.h" |
| 10 | 10 |
| 11 namespace base { |
| 11 class Pickle; | 12 class Pickle; |
| 12 class PickleIterator; | 13 class PickleIterator; |
| 14 } // namespace base |
| 13 | 15 |
| 14 namespace net { | 16 namespace net { |
| 15 | 17 |
| 16 struct HttpRequestInfo; | 18 struct HttpRequestInfo; |
| 17 class HttpResponseHeaders; | 19 class HttpResponseHeaders; |
| 18 | 20 |
| 19 // Used to implement the HTTP/1.1 Vary header. This class contains a MD5 hash | 21 // Used to implement the HTTP/1.1 Vary header. This class contains a MD5 hash |
| 20 // over the request headers indicated by a Vary header. | 22 // over the request headers indicated by a Vary header. |
| 21 // | 23 // |
| 22 // While RFC 2616 requires strict request header comparisons, it is much | 24 // While RFC 2616 requires strict request header comparisons, it is much |
| (...skipping 22 matching lines...) Expand all Loading... |
| 45 bool Init(const HttpRequestInfo& request_info, | 47 bool Init(const HttpRequestInfo& request_info, |
| 46 const HttpResponseHeaders& response_headers); | 48 const HttpResponseHeaders& response_headers); |
| 47 | 49 |
| 48 // Initialize from a pickle that contains data generated by a call to the | 50 // Initialize from a pickle that contains data generated by a call to the |
| 49 // vary data's Persist method. | 51 // vary data's Persist method. |
| 50 // | 52 // |
| 51 // Upon success, true is returned and the object is marked as valid such that | 53 // Upon success, true is returned and the object is marked as valid such that |
| 52 // is_valid() will return true. Otherwise, false is returned to indicate | 54 // is_valid() will return true. Otherwise, false is returned to indicate |
| 53 // that this object is marked as invalid. | 55 // that this object is marked as invalid. |
| 54 // | 56 // |
| 55 bool InitFromPickle(PickleIterator* pickle_iter); | 57 bool InitFromPickle(base::PickleIterator* pickle_iter); |
| 56 | 58 |
| 57 // Call this method to persist the vary data. Illegal to call this on an | 59 // Call this method to persist the vary data. Illegal to call this on an |
| 58 // invalid object. | 60 // invalid object. |
| 59 void Persist(Pickle* pickle) const; | 61 void Persist(base::Pickle* pickle) const; |
| 60 | 62 |
| 61 // Call this method to test if the given request matches the previous request | 63 // Call this method to test if the given request matches the previous request |
| 62 // with which this vary data corresponds. The |cached_response_headers| must | 64 // with which this vary data corresponds. The |cached_response_headers| must |
| 63 // be the same response headers used to generate this vary data. | 65 // be the same response headers used to generate this vary data. |
| 64 bool MatchesRequest(const HttpRequestInfo& request_info, | 66 bool MatchesRequest(const HttpRequestInfo& request_info, |
| 65 const HttpResponseHeaders& cached_response_headers) const; | 67 const HttpResponseHeaders& cached_response_headers) const; |
| 66 | 68 |
| 67 private: | 69 private: |
| 68 // Returns the corresponding request header value. | 70 // Returns the corresponding request header value. |
| 69 static std::string GetRequestValue(const HttpRequestInfo& request_info, | 71 static std::string GetRequestValue(const HttpRequestInfo& request_info, |
| 70 const std::string& request_header); | 72 const std::string& request_header); |
| 71 | 73 |
| 72 // Append to the MD5 context for the given request header. | 74 // Append to the MD5 context for the given request header. |
| 73 static void AddField(const HttpRequestInfo& request_info, | 75 static void AddField(const HttpRequestInfo& request_info, |
| 74 const std::string& request_header, | 76 const std::string& request_header, |
| 75 base::MD5Context* context); | 77 base::MD5Context* context); |
| 76 | 78 |
| 77 // A digested version of the request headers corresponding to the Vary header. | 79 // A digested version of the request headers corresponding to the Vary header. |
| 78 base::MD5Digest request_digest_; | 80 base::MD5Digest request_digest_; |
| 79 | 81 |
| 80 // True when request_digest_ contains meaningful data. | 82 // True when request_digest_ contains meaningful data. |
| 81 bool is_valid_; | 83 bool is_valid_; |
| 82 }; | 84 }; |
| 83 | 85 |
| 84 } // namespace net | 86 } // namespace net |
| 85 | 87 |
| 86 #endif // NET_HTTP_HTTP_VARY_DATA_H_ | 88 #endif // NET_HTTP_HTTP_VARY_DATA_H_ |
| OLD | NEW |