OLD | NEW |
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 Loading... |
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 // Returns if we should clear the given cookie. |
| 47 typedef base::Callback<bool(const CanonicalCookie& cookie)> |
| 48 ClearCookiesPredicate; |
46 | 49 |
47 virtual ~CookieStore(); | 50 virtual ~CookieStore(); |
48 | 51 |
49 // Returns the cookie line (e.g. "cookie1=value1; cookie2=value2") represented | 52 // 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. | 53 // by |cookies|. The string is built in the same order as the given list. |
51 // | 54 // |
52 // TODO(mkwst): We really should standardize on either | 55 // TODO(mkwst): We really should standardize on either |
53 // 'std::vector<CanonicalCookie>' or 'std::vector<CanonicalCookie*>'. | 56 // 'std::vector<CanonicalCookie>' or 'std::vector<CanonicalCookie*>'. |
54 static std::string BuildCookieLine( | 57 static std::string BuildCookieLine( |
55 const std::vector<CanonicalCookie>& cookies); | 58 const std::vector<CanonicalCookie>& cookies); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 // equal to |delete_begin| and less then |delete_end|. This includes | 163 // equal to |delete_begin| and less then |delete_end|. This includes |
161 // all http_only and secure cookies, but does not include any domain | 164 // all http_only and secure cookies, but does not include any domain |
162 // cookies that may apply to this host. | 165 // cookies that may apply to this host. |
163 // Returns the number of cookies deleted. | 166 // Returns the number of cookies deleted. |
164 virtual void DeleteAllCreatedBetweenForHostAsync( | 167 virtual void DeleteAllCreatedBetweenForHostAsync( |
165 const base::Time delete_begin, | 168 const base::Time delete_begin, |
166 const base::Time delete_end, | 169 const base::Time delete_end, |
167 const GURL& url, | 170 const GURL& url, |
168 const DeleteCallback& callback) = 0; | 171 const DeleteCallback& callback) = 0; |
169 | 172 |
| 173 // Deletes all of the cookies that match the given predicate and that have a |
| 174 // creation_date greater than or equal to |delete_begin| and less then |
| 175 // |delete_end|. |
| 176 // Returns the number of cookies deleted. |
| 177 virtual void DeleteAllCreatedBetweenWithPredicateAsync( |
| 178 const base::Time& delete_begin, |
| 179 const base::Time& delete_end, |
| 180 const ClearCookiesPredicate& predicate, |
| 181 const DeleteCallback& callback) = 0; |
| 182 |
170 virtual void DeleteSessionCookiesAsync(const DeleteCallback&) = 0; | 183 virtual void DeleteSessionCookiesAsync(const DeleteCallback&) = 0; |
171 | 184 |
172 // Deletes all cookies in the store. | 185 // Deletes all cookies in the store. |
173 void DeleteAllAsync(const DeleteCallback& callback); | 186 void DeleteAllAsync(const DeleteCallback& callback); |
174 | 187 |
175 // Flush the backing store (if any) to disk and post the given callback when | 188 // Flush the backing store (if any) to disk and post the given callback when |
176 // done. | 189 // done. |
177 virtual void FlushStore(const base::Closure& callback) = 0; | 190 virtual void FlushStore(const base::Closure& callback) = 0; |
178 | 191 |
179 // Protects session cookies from deletion on shutdown, if the underlying | 192 // Protects session cookies from deletion on shutdown, if the underlying |
(...skipping 22 matching lines...) Expand all Loading... |
202 const std::string& name, | 215 const std::string& name, |
203 const CookieChangedCallback& callback) = 0; | 216 const CookieChangedCallback& callback) = 0; |
204 | 217 |
205 protected: | 218 protected: |
206 CookieStore(); | 219 CookieStore(); |
207 }; | 220 }; |
208 | 221 |
209 } // namespace net | 222 } // namespace net |
210 | 223 |
211 #endif // NET_COOKIES_COOKIE_STORE_H_ | 224 #endif // NET_COOKIES_COOKIE_STORE_H_ |
OLD | NEW |