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

Side by Side Diff: net/cookies/cookie_store.h

Issue 1844243002: [CookieStore] Upgrading host-based deleting to predicate-based deleting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added android changes Created 4 years, 8 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
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 // Brought to you by number 42. 5 // Brought to you by number 42.
6 6
7 #ifndef NET_COOKIES_COOKIE_STORE_H_ 7 #ifndef NET_COOKIES_COOKIE_STORE_H_
8 #define NET_COOKIES_COOKIE_STORE_H_ 8 #define NET_COOKIES_COOKIE_STORE_H_
9 9
10 #include <string> 10 #include <string>
11 #include <vector> 11 #include <vector>
12 12
13 #include "base/callback.h" 13 #include "base/callback_forward.h"
14 #include "base/callback_list.h" 14 #include "base/callback_list.h"
15 #include "base/memory/scoped_ptr.h" 15 #include "base/memory/scoped_ptr.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "net/base/net_export.h" 17 #include "net/base/net_export.h"
18 #include "net/cookies/canonical_cookie.h" 18 #include "net/cookies/canonical_cookie.h"
19 #include "net/cookies/cookie_options.h" 19 #include "net/cookies/cookie_options.h"
20 20
21 class GURL; 21 class GURL;
22 22
23 namespace net { 23 namespace net {
(...skipping 12 matching lines...) Expand all
36 // Callback definitions. 36 // Callback definitions.
37 typedef base::Callback<void(const CookieList& cookies)> GetCookieListCallback; 37 typedef base::Callback<void(const CookieList& cookies)> GetCookieListCallback;
38 typedef base::Callback<void(const std::string& cookie)> GetCookiesCallback; 38 typedef base::Callback<void(const std::string& cookie)> GetCookiesCallback;
39 typedef base::Callback<void(bool success)> SetCookiesCallback; 39 typedef base::Callback<void(bool success)> SetCookiesCallback;
40 typedef base::Callback<void(int num_deleted)> DeleteCallback; 40 typedef base::Callback<void(int num_deleted)> DeleteCallback;
41 typedef base::Callback<void(const CanonicalCookie& cookie, bool removed)> 41 typedef base::Callback<void(const CanonicalCookie& cookie, bool removed)>
42 CookieChangedCallback; 42 CookieChangedCallback;
43 typedef base::CallbackList<void(const CanonicalCookie& cookie, bool removed)> 43 typedef base::CallbackList<void(const CanonicalCookie& cookie, bool removed)>
44 CookieChangedCallbackList; 44 CookieChangedCallbackList;
45 typedef CookieChangedCallbackList::Subscription CookieChangedSubscription; 45 typedef CookieChangedCallbackList::Subscription CookieChangedSubscription;
46 typedef base::Callback<bool(const CanonicalCookie& cookie)> CookiePredicate;
46 47
47 virtual ~CookieStore(); 48 virtual ~CookieStore();
48 49
49 // Returns the cookie line (e.g. "cookie1=value1; cookie2=value2") represented 50 // Returns the cookie line (e.g. "cookie1=value1; cookie2=value2") represented
50 // by |cookies|. The string is built in the same order as the given list. 51 // by |cookies|. The string is built in the same order as the given list.
51 // 52 //
52 // TODO(mkwst): We really should standardize on either 53 // TODO(mkwst): We really should standardize on either
53 // 'std::vector<CanonicalCookie>' or 'std::vector<CanonicalCookie*>'. 54 // 'std::vector<CanonicalCookie>' or 'std::vector<CanonicalCookie*>'.
54 static std::string BuildCookieLine( 55 static std::string BuildCookieLine(
55 const std::vector<CanonicalCookie>& cookies); 56 const std::vector<CanonicalCookie>& cookies);
56 static std::string BuildCookieLine( 57 static std::string BuildCookieLine(
57 const std::vector<CanonicalCookie*>& cookies); 58 const std::vector<CanonicalCookie*>& cookies);
58 59
60 // This creates a CookiePredicate that matches all host (NOT domain) cookies
61 // that match the host of |url|. This is intended to be used with
62 // DeleteAllCreatedBetweenWithPredicateAsync.
63 static CookiePredicate CreatePredicateForHostCookies(const GURL& url);
Mike West 2016/04/01 07:40:52 This is only used by StoragePartition, right? Did
dmurph 2016/04/01 23:16:46 Done.
64
59 // Sets the cookies specified by |cookie_list| returned from |url| 65 // Sets the cookies specified by |cookie_list| returned from |url|
60 // with options |options| in effect. Expects a cookie line, like 66 // with options |options| in effect. Expects a cookie line, like
61 // "a=1; domain=b.com". 67 // "a=1; domain=b.com".
62 // 68 //
63 // Fails either if the cookie is invalid or if this is a non-HTTPONLY cookie 69 // Fails either if the cookie is invalid or if this is a non-HTTPONLY cookie
64 // and it would overwrite an existing HTTPONLY cookie. 70 // and it would overwrite an existing HTTPONLY cookie.
65 // Returns true if the cookie is successfully set. 71 // Returns true if the cookie is successfully set.
66 virtual void SetCookieWithOptionsAsync( 72 virtual void SetCookieWithOptionsAsync(
67 const GURL& url, 73 const GURL& url,
68 const std::string& cookie_line, 74 const std::string& cookie_line,
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 const base::Closure& callback) = 0; 149 const base::Closure& callback) = 0;
144 150
145 // Deletes one specific cookie. |cookie| must have been returned by a previous 151 // Deletes one specific cookie. |cookie| must have been returned by a previous
146 // query on this CookieStore. Invokes |callback| with 1 if a cookie was 152 // query on this CookieStore. Invokes |callback| with 1 if a cookie was
147 // deleted, 0 otherwise. 153 // deleted, 0 otherwise.
148 virtual void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie, 154 virtual void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie,
149 const DeleteCallback& callback) = 0; 155 const DeleteCallback& callback) = 0;
150 156
151 // Deletes all of the cookies that have a creation_date greater than or equal 157 // Deletes all of the cookies that have a creation_date greater than or equal
152 // to |delete_begin| and less than |delete_end| 158 // to |delete_begin| and less than |delete_end|
153 // Returns the number of cookies that have been deleted. 159 // Calls |callback| with the number of cookies deleted.
154 virtual void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin, 160 virtual void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin,
155 const base::Time& delete_end, 161 const base::Time& delete_end,
156 const DeleteCallback& callback) = 0; 162 const DeleteCallback& callback) = 0;
157 163
158 // Deletes all of the cookies that match the host of the given URL 164 // Deletes all of the cookies that match the given predicate and that have a
159 // regardless of path and that have a creation_date greater than or 165 // creation_date greater than or equal to |delete_begin| and less then
160 // equal to |delete_begin| and less then |delete_end|. This includes 166 // |delete_end|. This includes all http_only and secure cookies. Make sure you
161 // all http_only and secure cookies, but does not include any domain 167 // know what you are doing here so you don't break the web.
Mike West 2016/04/01 07:40:52 This warning isn't very helpful. :) What should de
dmurph 2016/04/01 23:16:46 Changed.
162 // cookies that may apply to this host. 168 // Calls |callback| with the number of cookies deleted.
163 // Returns the number of cookies deleted. 169 virtual void DeleteAllCreatedBetweenWithPredicateAsync(
164 virtual void DeleteAllCreatedBetweenForHostAsync( 170 const base::Time& delete_begin,
165 const base::Time delete_begin, 171 const base::Time& delete_end,
166 const base::Time delete_end, 172 const CookiePredicate& predicate,
167 const GURL& url,
168 const DeleteCallback& callback) = 0; 173 const DeleteCallback& callback) = 0;
169 174
170 virtual void DeleteSessionCookiesAsync(const DeleteCallback&) = 0; 175 virtual void DeleteSessionCookiesAsync(const DeleteCallback&) = 0;
171 176
172 // Deletes all cookies in the store. 177 // Deletes all cookies in the store.
173 void DeleteAllAsync(const DeleteCallback& callback); 178 void DeleteAllAsync(const DeleteCallback& callback);
174 179
175 // Flush the backing store (if any) to disk and post the given callback when 180 // Flush the backing store (if any) to disk and post the given callback when
176 // done. 181 // done.
177 virtual void FlushStore(const base::Closure& callback) = 0; 182 virtual void FlushStore(const base::Closure& callback) = 0;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 int GetChannelIDServiceID(); 215 int GetChannelIDServiceID();
211 216
212 protected: 217 protected:
213 CookieStore(); 218 CookieStore();
214 int channel_id_service_id_; 219 int channel_id_service_id_;
215 }; 220 };
216 221
217 } // namespace net 222 } // namespace net
218 223
219 #endif // NET_COOKIES_COOKIE_STORE_H_ 224 #endif // NET_COOKIES_COOKIE_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698