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

Unified Diff: net/cookies/canonical_cookie.h

Issue 454623003: Store in memory cookies in a hash set instead of a list. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months 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
Index: net/cookies/canonical_cookie.h
diff --git a/net/cookies/canonical_cookie.h b/net/cookies/canonical_cookie.h
index a55674052422314f3fa9e8d84491bde7fb0ab662..05504ebc16797c9147ab9bb424860b77f9f9e610 100644
--- a/net/cookies/canonical_cookie.h
+++ b/net/cookies/canonical_cookie.h
@@ -9,6 +9,8 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/containers/hash_tables.h"
+#include "base/hash.h"
#include "base/time/time.h"
#include "net/base/net_export.h"
#include "net/cookies/cookie_constants.h"
@@ -166,6 +168,28 @@ class NET_EXPORT CanonicalCookie {
typedef std::vector<CanonicalCookie> CookieList;
+struct CanonicalCookieHasher {
+ std::size_t operator()(const CanonicalCookie& cookie) const {
+ return base::SuperFastHash(cookie.Name().c_str(), cookie.Name().size()) +
+ 3 * base::SuperFastHash(cookie.Domain().c_str(),
+ cookie.Domain().size()) +
+ 7 * base::SuperFastHash(cookie.Path().c_str(), cookie.Path().size());
+ }
+};
+
+struct CanonicalCookieComparer {
+ bool operator()(const CanonicalCookie& cookie1,
+ const CanonicalCookie& cookie2) const {
+ return cookie1.Name() == cookie2.Name() &&
+ cookie1.Domain() == cookie2.Domain() &&
+ cookie1.Path() == cookie2.Path();
+ }
+};
+
+typedef base::hash_set<CanonicalCookie,
+ CanonicalCookieHasher,
+ CanonicalCookieComparer> CookieHashSet;
+
} // namespace net
#endif // NET_COOKIES_CANONICAL_COOKIE_H_

Powered by Google App Engine
This is Rietveld 408576698