blob: 066c388c051e459d88da446d03540b9f287161ac [file] [log] [blame]
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Provides utility structures for inserting a CanonicalCookie into a hash set.
// Two cookies are considered equal if their names, domains, and paths are
// equivalent.
#include <stddef.h>
#include "base/containers/hash_tables.h"
#include "net/cookies/canonical_cookie.h"
namespace canonical_cookie {
// Returns a fast hash of a cookie, based on its name, domain, and path.
size_t FastHash(const net::CanonicalCookie& cookie);
struct CanonicalCookieHasher {
std::size_t operator()(const net::CanonicalCookie& cookie) const {
return FastHash(cookie);
struct CanonicalCookieComparer {
bool operator()(const net::CanonicalCookie& cookie1,
const net::CanonicalCookie& cookie2) const {
return cookie1.Name() == cookie2.Name() &&
cookie1.Domain() == cookie2.Domain() &&
cookie1.Path() == cookie2.Path();
typedef base::hash_set<net::CanonicalCookie,
CanonicalCookieComparer> CookieHashSet;
} // namespace canonical_cookie