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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | net/cookies/canonical_cookie.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/cookies/canonical_cookie.h
diff --git a/net/cookies/canonical_cookie.h b/net/cookies/canonical_cookie.h
index 312ad1fd9e62255d7aec36ff1788f3ba6e5ddb5e..bc1cc65417c9a5c7ae51c4f1f6540daecce5471b 100644
--- a/net/cookies/canonical_cookie.h
+++ b/net/cookies/canonical_cookie.h
@@ -9,6 +9,7 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/gtest_prod_util.h"
#include "base/time/time.h"
#include "net/base/net_export.h"
#include "net/cookies/cookie_constants.h"
@@ -159,6 +160,32 @@ class NET_EXPORT CanonicalCookie {
bool FullCompare(const CanonicalCookie& other) const;
private:
+ FRIEND_TEST_ALL_PREFIXES(CanonicalCookiePrefixHistogramTest, TestHistograms);
+
+ // The special cookie prefixes as defined in
+ // https://tools.ietf.org/html/draft-west-cookie-prefixes
+ //
+ // This enum is being histogrammed; do not reorder or remove values.
+ enum CookiePrefix {
+ COOKIE_PREFIX_NONE = 0,
+ COOKIE_PREFIX_SECURE,
+ COOKIE_PREFIX_HOST,
+ COOKIE_PREFIX_LAST
+ };
+
+ // Returns the CookiePrefix (or COOKIE_PREFIX_NONE if none) that
+ // applies to the given cookie |name|.
+ static CookiePrefix GetCookiePrefix(const std::string& name);
+ // Records histograms to measure how often cookie prefixes appear in
+ // the wild and how often they would be blocked.
+ static void RecordCookiePrefixMetrics(CookiePrefix prefix,
+ bool is_cookie_valid);
+ // Returns true if a prefixed cookie does not violate any of the rules
+ // for that cookie.
+ static bool IsCookiePrefixValid(CookiePrefix prefix,
+ const GURL& url,
+ const ParsedCookie& parsed_cookie);
+
// The source member of a canonical cookie is the origin of the URL that tried
// to set this cookie. This field is not persistent though; its only used in
// the in-tab cookies dialog to show the user the source URL. This is used for
« 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