1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // Provides utility structures for inserting a CanonicalCookie into a hash set.
6 // Two cookies are considered equal if their names, domains, and paths are
9 #ifndef CHROME_BROWSER_BROWSING_DATA_CANONICAL_COOKIE_HASH_H_
10 #define CHROME_BROWSER_BROWSING_DATA_CANONICAL_COOKIE_HASH_H_
12 #include "base/containers/hash_tables.h"
13 #include "net/cookies/canonical_cookie.h"
15 namespace canonical_cookie
{
17 // Returns a fast hash of a cookie, based on its name, domain, and path.
18 size_t FastHash(const net::CanonicalCookie
& cookie
);
20 struct CanonicalCookieHasher
{
21 std::size_t operator()(const net::CanonicalCookie
& cookie
) const {
22 return FastHash(cookie
);
26 struct CanonicalCookieComparer
{
27 bool operator()(const net::CanonicalCookie
& cookie1
,
28 const net::CanonicalCookie
& cookie2
) const {
29 return cookie1
.Name() == cookie2
.Name() &&
30 cookie1
.Domain() == cookie2
.Domain() &&
31 cookie1
.Path() == cookie2
.Path();
35 typedef base::hash_set
<net::CanonicalCookie
,
36 CanonicalCookieHasher
,
37 CanonicalCookieComparer
> CookieHashSet
;
39 }; // namespace canonical_cookie
41 #endif // CHROME_BROWSER_BROWSING_DATA_CANONICAL_COOKIE_HASH_H_