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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
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/containers/hash_tables.h"
13 #include "base/hash.h"
12 #include "base/time/time.h" 14 #include "base/time/time.h"
13 #include "net/base/net_export.h" 15 #include "net/base/net_export.h"
14 #include "net/cookies/cookie_constants.h" 16 #include "net/cookies/cookie_constants.h"
15 #include "net/cookies/cookie_options.h" 17 #include "net/cookies/cookie_options.h"
16 18
17 class GURL; 19 class GURL;
18 20
19 namespace net { 21 namespace net {
20 22
21 class ParsedCookie; 23 class ParsedCookie;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 bool secure_; 161 bool secure_;
160 bool httponly_; 162 bool httponly_;
161 CookiePriority priority_; 163 CookiePriority priority_;
162 // NOTE: When any new members are added above this comment, the 164 // NOTE: When any new members are added above this comment, the
163 // implementation of Duplicate() must be updated to copy the new member 165 // implementation of Duplicate() must be updated to copy the new member
164 // accordingly. 166 // accordingly.
165 }; 167 };
166 168
167 typedef std::vector<CanonicalCookie> CookieList; 169 typedef std::vector<CanonicalCookie> CookieList;
168 170
171 struct CanonicalCookieHasher {
172 std::size_t operator()(const CanonicalCookie& cookie) const {
173 return base::SuperFastHash(cookie.Name().c_str(), cookie.Name().size()) +
174 3 * base::SuperFastHash(cookie.Domain().c_str(),
175 cookie.Domain().size()) +
176 7 * base::SuperFastHash(cookie.Path().c_str(), cookie.Path().size());
177 }
178 };
179
180 struct CanonicalCookieComparer {
181 bool operator()(const CanonicalCookie& cookie1,
182 const CanonicalCookie& cookie2) const {
183 return cookie1.Name() == cookie2.Name() &&
184 cookie1.Domain() == cookie2.Domain() &&
185 cookie1.Path() == cookie2.Path();
186 }
187 };
188
189 typedef base::hash_set<CanonicalCookie,
190 CanonicalCookieHasher,
191 CanonicalCookieComparer> CookieHashSet;
192
169 } // namespace net 193 } // namespace net
170 194
171 #endif // NET_COOKIES_CANONICAL_COOKIE_H_ 195 #endif // NET_COOKIES_CANONICAL_COOKIE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698