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

Side by Side Diff: chrome/browser/browsing_data/browsing_data_cookie_helper.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: Fix total ordering. 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
« no previous file with comments | « no previous file | chrome/browser/browsing_data/browsing_data_cookie_helper.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COOKIE_HELPER_H_ 5 #ifndef CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COOKIE_HELPER_H_
6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COOKIE_HELPER_H_ 6 #define CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COOKIE_HELPER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 10
11 #include "base/basictypes.h" 11 #include "base/basictypes.h"
12 #include "base/callback.h" 12 #include "base/callback.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "chrome/browser/browsing_data/canonical_cookie_hash.h"
14 #include "net/cookies/cookie_monster.h" 15 #include "net/cookies/cookie_monster.h"
15 16
16 class GURL; 17 class GURL;
17 18
18 namespace net { 19 namespace net {
19 class CanonicalCookie; 20 class CanonicalCookie;
20 class URLRequestContextGetter; 21 class URLRequestContextGetter;
21 } 22 }
22 23
23 // This class fetches cookie information on behalf of a caller 24 // This class fetches cookie information on behalf of a caller
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 // that are received from a server or set via JavaScript using the method 84 // that are received from a server or set via JavaScript using the method
84 // AddChangedCookie. 85 // AddChangedCookie.
85 // Cookies are distinguished by the tuple cookie name (called cookie-name in 86 // Cookies are distinguished by the tuple cookie name (called cookie-name in
86 // RFC 6265), cookie domain (called cookie-domain in RFC 6265), cookie path 87 // RFC 6265), cookie domain (called cookie-domain in RFC 6265), cookie path
87 // (called cookie-path in RFC 6265) and host-only-flag (see RFC 6265 section 88 // (called cookie-path in RFC 6265) and host-only-flag (see RFC 6265 section
88 // 5.3). Cookies with same tuple (cookie-name, cookie-domain, cookie-path, 89 // 5.3). Cookies with same tuple (cookie-name, cookie-domain, cookie-path,
89 // host-only-flag) as cookie that are already stored, will replace the stored 90 // host-only-flag) as cookie that are already stored, will replace the stored
90 // cookies. 91 // cookies.
91 class CannedBrowsingDataCookieHelper : public BrowsingDataCookieHelper { 92 class CannedBrowsingDataCookieHelper : public BrowsingDataCookieHelper {
92 public: 93 public:
93 typedef std::map<GURL, net::CookieList*> OriginCookieListMap; 94 typedef std::map<GURL, canonical_cookie::CookieHashSet*> OriginCookieSetMap;
94 95
95 explicit CannedBrowsingDataCookieHelper( 96 explicit CannedBrowsingDataCookieHelper(
96 net::URLRequestContextGetter* request_context); 97 net::URLRequestContextGetter* request_context);
97 98
98 // Return a copy of the cookie helper. Only one consumer can use the 99 // Return a copy of the cookie helper. Only one consumer can use the
99 // StartFetching method at a time, so we need to create a copy of the helper 100 // StartFetching method at a time, so we need to create a copy of the helper
100 // everytime we instantiate a cookies tree model for it. 101 // everytime we instantiate a cookies tree model for it.
101 CannedBrowsingDataCookieHelper* Clone(); 102 CannedBrowsingDataCookieHelper* Clone();
102 103
103 // Adds the cookies from |cookie_list|. Current cookies that have the same 104 // Adds the cookies from |cookie_list|. Current cookies that have the same
(...skipping 27 matching lines...) Expand all
131 132
132 // BrowsingDataCookieHelper methods. 133 // BrowsingDataCookieHelper methods.
133 virtual void StartFetching( 134 virtual void StartFetching(
134 const net::CookieMonster::GetCookieListCallback& callback) OVERRIDE; 135 const net::CookieMonster::GetCookieListCallback& callback) OVERRIDE;
135 virtual void DeleteCookie(const net::CanonicalCookie& cookie) OVERRIDE; 136 virtual void DeleteCookie(const net::CanonicalCookie& cookie) OVERRIDE;
136 137
137 // Returns the number of stored cookies. 138 // Returns the number of stored cookies.
138 size_t GetCookieCount() const; 139 size_t GetCookieCount() const;
139 140
140 // Returns the map that contains the cookie lists for all frame urls. 141 // Returns the map that contains the cookie lists for all frame urls.
141 const OriginCookieListMap& origin_cookie_list_map() { 142 const OriginCookieSetMap& origin_cookie_set_map() {
142 return origin_cookie_list_map_; 143 return origin_cookie_set_map_;
143 } 144 }
144 145
145 private: 146 private:
146 // Check if the cookie list contains a cookie with the same name, 147 // Check if the cookie set contains a cookie with the same name,
147 // domain, and path as the newly created cookie. Delete the old cookie 148 // domain, and path as the newly created cookie. Delete the old cookie
148 // if does. 149 // if does.
149 bool DeleteMatchingCookie(const net::CanonicalCookie& add_cookie, 150 bool DeleteMatchingCookie(const net::CanonicalCookie& add_cookie,
150 net::CookieList* cookie_list); 151 canonical_cookie::CookieHashSet* cookie_set);
151 152
152 virtual ~CannedBrowsingDataCookieHelper(); 153 virtual ~CannedBrowsingDataCookieHelper();
153 154
154 // Returns the |CookieList| for the given |origin|. 155 // Returns the |CookieSet| for the given |origin|.
155 net::CookieList* GetCookiesFor(const GURL& origin); 156 canonical_cookie::CookieHashSet* GetCookiesFor(const GURL& origin);
156 157
157 // Adds the |cookie| to the cookie list for the given |frame_url|. 158 // Adds the |cookie| to the cookie set for the given |frame_url|.
158 void AddCookie(const GURL& frame_url, 159 void AddCookie(const GURL& frame_url,
159 const net::CanonicalCookie& cookie); 160 const net::CanonicalCookie& cookie);
160 161
161 // Map that contains the cookie lists for all frame origins. 162 // Map that contains the cookie sets for all frame origins.
162 OriginCookieListMap origin_cookie_list_map_; 163 OriginCookieSetMap origin_cookie_set_map_;
163 164
164 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataCookieHelper); 165 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataCookieHelper);
165 }; 166 };
166 167
167 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COOKIE_HELPER_H_ 168 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COOKIE_HELPER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/browsing_data/browsing_data_cookie_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698