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

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: 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 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 "net/cookies/cookie_monster.h" 14 #include "net/cookies/cookie_monster.h"
15 #include "url/gurl.h"
15 16
16 class GURL; 17 class GURL;
Avi (use Gerrit) 2014/08/07 23:50:37 If you include the header you shouldn't need to fo
erikchen 2014/08/08 00:35:28 Removed.
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
24 // on the UI thread. 25 // on the UI thread.
25 // A client of this class need to call StartFetching from the UI thread to 26 // A client of this class need to call StartFetching from the UI thread to
26 // initiate the flow, and it'll be notified by the callback in its UI 27 // initiate the flow, and it'll be notified by the callback in its UI
(...skipping 56 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, net::CookieHashSet*> OriginCookieListMap;
Avi (use Gerrit) 2014/08/07 23:50:38 OriginCookieSetMap? Or is the current name generic
erikchen 2014/08/08 00:35:28 I changed the name, as well as the names of the va
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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 OriginCookieListMap& origin_cookie_list_map() {
142 return origin_cookie_list_map_; 143 return origin_cookie_list_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 list 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 net::CookieHashSet* cookie_list);
151 152
152 virtual ~CannedBrowsingDataCookieHelper(); 153 virtual ~CannedBrowsingDataCookieHelper();
153 154
154 // Returns the |CookieList| for the given |origin|. 155 // Returns the |CookieList| for the given |origin|.
155 net::CookieList* GetCookiesFor(const GURL& origin); 156 net::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 list 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 lists for all frame origins.
162 OriginCookieListMap origin_cookie_list_map_; 163 OriginCookieListMap origin_cookie_list_map_;
163 164
165 // A cache of the url for the global cookie list.
166 GURL origin_cookie_url_;
Avi (use Gerrit) 2014/08/07 23:50:38 Huh? Why do this? This is used in one place; sugge
erikchen 2014/08/08 00:35:27 Done.
167
164 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataCookieHelper); 168 DISALLOW_COPY_AND_ASSIGN(CannedBrowsingDataCookieHelper);
165 }; 169 };
166 170
167 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COOKIE_HELPER_H_ 171 #endif // CHROME_BROWSER_BROWSING_DATA_BROWSING_DATA_COOKIE_HELPER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698