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_COOKIES_CANONICAL_COOKIE_H_ | 5 #ifndef NET_COOKIES_CANONICAL_COOKIE_H_ |
6 #define NET_COOKIES_CANONICAL_COOKIE_H_ | 6 #define NET_COOKIES_CANONICAL_COOKIE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 std::string DebugString() const; | 129 std::string DebugString() const; |
130 | 130 |
131 // Returns the cookie source when cookies are set for |url|. This function | 131 // Returns the cookie source when cookies are set for |url|. This function |
132 // is public for unit test purposes only. | 132 // is public for unit test purposes only. |
133 static std::string GetCookieSourceFromURL(const GURL& url); | 133 static std::string GetCookieSourceFromURL(const GURL& url); |
134 static std::string CanonPath(const GURL& url, const ParsedCookie& pc); | 134 static std::string CanonPath(const GURL& url, const ParsedCookie& pc); |
135 static base::Time CanonExpiration(const ParsedCookie& pc, | 135 static base::Time CanonExpiration(const ParsedCookie& pc, |
136 const base::Time& current, | 136 const base::Time& current, |
137 const base::Time& server_time); | 137 const base::Time& server_time); |
138 | 138 |
| 139 // Cookie ordering methods. |
| 140 |
| 141 // Returns true if the cookie is less than |other|, considering only name, |
| 142 // domain and path. In particular, two equivalent cookies (see IsEquivalent()) |
| 143 // are identical for PartialCompare(). |
| 144 bool PartialCompare(const CanonicalCookie& other) const; |
| 145 |
| 146 // Returns true if the cookie is less than |other|, considering all fields. |
| 147 // FullCompare() is consistent with PartialCompare(): cookies sorted using |
| 148 // FullCompare() are also sorted with respect to PartialCompare(). |
| 149 bool FullCompare(const CanonicalCookie& other) const; |
| 150 |
139 private: | 151 private: |
140 // The source member of a canonical cookie is the origin of the URL that tried | 152 // The source member of a canonical cookie is the origin of the URL that tried |
141 // to set this cookie, minus the port number if any. This field is not | 153 // to set this cookie, minus the port number if any. This field is not |
142 // persistent though; its only used in the in-tab cookies dialog to show the | 154 // persistent though; its only used in the in-tab cookies dialog to show the |
143 // user the source URL. This is used for both allowed and blocked cookies. | 155 // user the source URL. This is used for both allowed and blocked cookies. |
144 // When a CanonicalCookie is constructed from the backing store (common case) | 156 // When a CanonicalCookie is constructed from the backing store (common case) |
145 // this field will be null. CanonicalCookie consumers should not rely on | 157 // this field will be null. CanonicalCookie consumers should not rely on |
146 // this field unless they guarantee that the creator of those | 158 // this field unless they guarantee that the creator of those |
147 // CanonicalCookies properly initialized the field. | 159 // CanonicalCookies properly initialized the field. |
148 std::string source_; | 160 std::string source_; |
149 std::string name_; | 161 std::string name_; |
150 std::string value_; | 162 std::string value_; |
151 std::string domain_; | 163 std::string domain_; |
152 std::string path_; | 164 std::string path_; |
153 base::Time creation_date_; | 165 base::Time creation_date_; |
154 base::Time expiry_date_; | 166 base::Time expiry_date_; |
155 base::Time last_access_date_; | 167 base::Time last_access_date_; |
156 bool secure_; | 168 bool secure_; |
157 bool httponly_; | 169 bool httponly_; |
158 bool first_party_only_; | 170 bool first_party_only_; |
159 CookiePriority priority_; | 171 CookiePriority priority_; |
160 }; | 172 }; |
161 | 173 |
162 typedef std::vector<CanonicalCookie> CookieList; | 174 typedef std::vector<CanonicalCookie> CookieList; |
163 | 175 |
164 } // namespace net | 176 } // namespace net |
165 | 177 |
166 #endif // NET_COOKIES_CANONICAL_COOKIE_H_ | 178 #endif // NET_COOKIES_CANONICAL_COOKIE_H_ |
OLD | NEW |