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

Side by Side Diff: net/cookies/canonical_cookie.h

Issue 1455693007: Add cookie prefix metrics (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 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 | « no previous file | net/cookies/canonical_cookie.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_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
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/gtest_prod_util.h"
12 #include "base/time/time.h" 13 #include "base/time/time.h"
13 #include "net/base/net_export.h" 14 #include "net/base/net_export.h"
14 #include "net/cookies/cookie_constants.h" 15 #include "net/cookies/cookie_constants.h"
15 #include "net/cookies/cookie_options.h" 16 #include "net/cookies/cookie_options.h"
16 17
17 class GURL; 18 class GURL;
18 19
19 namespace net { 20 namespace net {
20 21
21 class ParsedCookie; 22 class ParsedCookie;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
152 // domain and path. In particular, two equivalent cookies (see IsEquivalent()) 153 // domain and path. In particular, two equivalent cookies (see IsEquivalent())
153 // are identical for PartialCompare(). 154 // are identical for PartialCompare().
154 bool PartialCompare(const CanonicalCookie& other) const; 155 bool PartialCompare(const CanonicalCookie& other) const;
155 156
156 // Returns true if the cookie is less than |other|, considering all fields. 157 // Returns true if the cookie is less than |other|, considering all fields.
157 // FullCompare() is consistent with PartialCompare(): cookies sorted using 158 // FullCompare() is consistent with PartialCompare(): cookies sorted using
158 // FullCompare() are also sorted with respect to PartialCompare(). 159 // FullCompare() are also sorted with respect to PartialCompare().
159 bool FullCompare(const CanonicalCookie& other) const; 160 bool FullCompare(const CanonicalCookie& other) const;
160 161
161 private: 162 private:
163 FRIEND_TEST_ALL_PREFIXES(CanonicalCookiePrefixHistogramTest, TestHistograms);
164
165 // The special cookie prefixes as defined in
166 // https://tools.ietf.org/html/draft-west-cookie-prefixes
167 //
168 // This enum is being histogrammed; do not reorder or remove values.
169 enum CookiePrefix {
170 COOKIE_PREFIX_NONE = 0,
171 COOKIE_PREFIX_SECURE,
172 COOKIE_PREFIX_HOST,
173 COOKIE_PREFIX_LAST
174 };
175
176 // Returns the CookiePrefix (or COOKIE_PREFIX_NONE if none) that
177 // applies to the given cookie |name|.
178 static CookiePrefix GetCookiePrefix(const std::string& name);
179 // Records histograms to measure how often cookie prefixes appear in
180 // the wild and how often they would be blocked.
181 static void RecordCookiePrefixMetrics(CookiePrefix prefix,
182 bool is_cookie_valid);
183 // Returns true if a prefixed cookie does not violate any of the rules
184 // for that cookie.
185 static bool IsCookiePrefixValid(CookiePrefix prefix,
186 const GURL& url,
187 const ParsedCookie& parsed_cookie);
188
162 // The source member of a canonical cookie is the origin of the URL that tried 189 // The source member of a canonical cookie is the origin of the URL that tried
163 // to set this cookie. This field is not persistent though; its only used in 190 // to set this cookie. This field is not persistent though; its only used in
164 // the in-tab cookies dialog to show the user the source URL. This is used for 191 // the in-tab cookies dialog to show the user the source URL. This is used for
165 // both allowed and blocked cookies. 192 // both allowed and blocked cookies.
166 // When a CanonicalCookie is constructed from the backing store (common case) 193 // When a CanonicalCookie is constructed from the backing store (common case)
167 // this field will be null. CanonicalCookie consumers should not rely on 194 // this field will be null. CanonicalCookie consumers should not rely on
168 // this field unless they guarantee that the creator of those 195 // this field unless they guarantee that the creator of those
169 // CanonicalCookies properly initialized the field. 196 // CanonicalCookies properly initialized the field.
170 GURL source_; 197 GURL source_;
171 std::string name_; 198 std::string name_;
172 std::string value_; 199 std::string value_;
173 std::string domain_; 200 std::string domain_;
174 std::string path_; 201 std::string path_;
175 base::Time creation_date_; 202 base::Time creation_date_;
176 base::Time expiry_date_; 203 base::Time expiry_date_;
177 base::Time last_access_date_; 204 base::Time last_access_date_;
178 bool secure_; 205 bool secure_;
179 bool httponly_; 206 bool httponly_;
180 bool first_party_only_; 207 bool first_party_only_;
181 CookiePriority priority_; 208 CookiePriority priority_;
182 }; 209 };
183 210
184 typedef std::vector<CanonicalCookie> CookieList; 211 typedef std::vector<CanonicalCookie> CookieList;
185 212
186 } // namespace net 213 } // namespace net
187 214
188 #endif // NET_COOKIES_CANONICAL_COOKIE_H_ 215 #endif // NET_COOKIES_CANONICAL_COOKIE_H_
OLDNEW
« no previous file with comments | « no previous file | net/cookies/canonical_cookie.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698