| 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 the letter D and the number 2. | 5 // Brought to you by the letter D and the number 2. |
| 6 | 6 |
| 7 #ifndef NET_COOKIES_COOKIE_MONSTER_H_ | 7 #ifndef NET_COOKIES_COOKIE_MONSTER_H_ |
| 8 #define NET_COOKIES_COOKIE_MONSTER_H_ | 8 #define NET_COOKIES_COOKIE_MONSTER_H_ |
| 9 | 9 |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 class ParsedCookie; | 44 class ParsedCookie; |
| 45 | 45 |
| 46 // The cookie monster is the system for storing and retrieving cookies. It has | 46 // The cookie monster is the system for storing and retrieving cookies. It has |
| 47 // an in-memory list of all cookies, and synchronizes non-session cookies to an | 47 // an in-memory list of all cookies, and synchronizes non-session cookies to an |
| 48 // optional permanent storage that implements the PersistentCookieStore | 48 // optional permanent storage that implements the PersistentCookieStore |
| 49 // interface. | 49 // interface. |
| 50 // | 50 // |
| 51 // This class IS thread-safe. Normally, it is only used on the I/O thread, but | 51 // This class IS thread-safe. Normally, it is only used on the I/O thread, but |
| 52 // is also accessed directly through Automation for UI testing. | 52 // is also accessed directly through Automation for UI testing. |
| 53 // | 53 // |
| 54 // All cookie tasks are handled asynchronously. Tasks may be deferred if | 54 // Tasks may be deferred if all affected cookies are not yet loaded from the |
| 55 // all affected cookies are not yet loaded from the backing store. Otherwise, | 55 // backing store. Otherwise, callbacks may be invoked immediately. |
| 56 // the callback may be invoked immediately (prior to return of the asynchronous | |
| 57 // function). | |
| 58 // | 56 // |
| 59 // A cookie task is either pending loading of the entire cookie store, or | 57 // A cookie task is either pending loading of the entire cookie store, or |
| 60 // loading of cookies for a specfic domain key(eTLD+1). In the former case, the | 58 // loading of cookies for a specfic domain key(eTLD+1). In the former case, the |
| 61 // cookie task will be queued in tasks_pending_ while PersistentCookieStore | 59 // cookie task will be queued in tasks_pending_ while PersistentCookieStore |
| 62 // chain loads the cookie store on DB thread. In the latter case, the cookie | 60 // chain loads the cookie store on DB thread. In the latter case, the cookie |
| 63 // task will be queued in tasks_pending_for_key_ while PermanentCookieStore | 61 // task will be queued in tasks_pending_for_key_ while PermanentCookieStore |
| 64 // loads cookies for the specified domain key(eTLD+1) on DB thread. | 62 // loads cookies for the specified domain key(eTLD+1) on DB thread. |
| 65 // | 63 // |
| 66 // Callbacks are guaranteed to be invoked on the calling thread. | 64 // Callbacks are guaranteed to be invoked on the calling thread. |
| 67 // | 65 // |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // Deletes all cookies that match the host of the given URL | 195 // Deletes all cookies that match the host of the given URL |
| 198 // regardless of path. This includes all http_only and secure cookies, | 196 // regardless of path. This includes all http_only and secure cookies, |
| 199 // but does not include any domain cookies that may apply to this host. | 197 // but does not include any domain cookies that may apply to this host. |
| 200 // Returns the number of cookies deleted. | 198 // Returns the number of cookies deleted. |
| 201 void DeleteAllForHostAsync(const GURL& url, const DeleteCallback& callback); | 199 void DeleteAllForHostAsync(const GURL& url, const DeleteCallback& callback); |
| 202 | 200 |
| 203 // Deletes one specific cookie. | 201 // Deletes one specific cookie. |
| 204 void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie, | 202 void DeleteCanonicalCookieAsync(const CanonicalCookie& cookie, |
| 205 const DeleteCookieCallback& callback); | 203 const DeleteCookieCallback& callback); |
| 206 | 204 |
| 207 // Flush the backing store (if any) to disk and post the given callback when | |
| 208 // done. | |
| 209 // WARNING: THE CALLBACK WILL RUN ON A RANDOM THREAD. IT MUST BE THREAD SAFE. | |
| 210 // It may be posted to the current thread, or it may run on the thread that | |
| 211 // actually does the flushing. Your Task should generally post a notification | |
| 212 // to the thread you actually want to be notified on. | |
| 213 void FlushStore(const base::Closure& callback); | |
| 214 | |
| 215 // Replaces all the cookies by |list|. This method does not flush the backend. | 205 // Replaces all the cookies by |list|. This method does not flush the backend. |
| 216 void SetAllCookiesAsync(const CookieList& list, | 206 void SetAllCookiesAsync(const CookieList& list, |
| 217 const SetCookiesCallback& callback); | 207 const SetCookiesCallback& callback); |
| 218 | 208 |
| 219 // CookieStore implementation. | 209 // CookieStore implementation. |
| 220 | |
| 221 // Sets the cookies specified by |cookie_list| returned from |url| | |
| 222 // with options |options| in effect. | |
| 223 void SetCookieWithOptionsAsync(const GURL& url, | 210 void SetCookieWithOptionsAsync(const GURL& url, |
| 224 const std::string& cookie_line, | 211 const std::string& cookie_line, |
| 225 const CookieOptions& options, | 212 const CookieOptions& options, |
| 226 const SetCookiesCallback& callback) override; | 213 const SetCookiesCallback& callback) override; |
| 227 | |
| 228 // Gets all cookies that apply to |url| given |options|. | |
| 229 // The returned cookies are ordered by longest path, then earliest | |
| 230 // creation date. | |
| 231 void GetCookiesWithOptionsAsync(const GURL& url, | 214 void GetCookiesWithOptionsAsync(const GURL& url, |
| 232 const CookieOptions& options, | 215 const CookieOptions& options, |
| 233 const GetCookiesCallback& callback) override; | 216 const GetCookiesCallback& callback) override; |
| 234 | |
| 235 // Invokes GetAllCookiesForURLWithOptions with options set to include HTTP | |
| 236 // only cookies. | |
| 237 void GetAllCookiesForURLAsync(const GURL& url, | 217 void GetAllCookiesForURLAsync(const GURL& url, |
| 238 const GetCookieListCallback& callback) override; | 218 const GetCookieListCallback& callback) override; |
| 239 | |
| 240 // Deletes all cookies with that might apply to |url| that has |cookie_name|. | |
| 241 void DeleteCookieAsync(const GURL& url, | 219 void DeleteCookieAsync(const GURL& url, |
| 242 const std::string& cookie_name, | 220 const std::string& cookie_name, |
| 243 const base::Closure& callback) override; | 221 const base::Closure& callback) override; |
| 244 | |
| 245 // Deletes all of the cookies that have a creation_date greater than or equal | |
| 246 // to |delete_begin| and less than |delete_end|. | |
| 247 // Returns the number of cookies that have been deleted. | |
| 248 void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin, | 222 void DeleteAllCreatedBetweenAsync(const base::Time& delete_begin, |
| 249 const base::Time& delete_end, | 223 const base::Time& delete_end, |
| 250 const DeleteCallback& callback) override; | 224 const DeleteCallback& callback) override; |
| 251 | |
| 252 // Deletes all of the cookies that match the host of the given URL | |
| 253 // regardless of path and that have a creation_date greater than or | |
| 254 // equal to |delete_begin| and less then |delete_end|. This includes | |
| 255 // all http_only and secure cookies, but does not include any domain | |
| 256 // cookies that may apply to this host. | |
| 257 // Returns the number of cookies deleted. | |
| 258 void DeleteAllCreatedBetweenForHostAsync( | 225 void DeleteAllCreatedBetweenForHostAsync( |
| 259 const base::Time delete_begin, | 226 const base::Time delete_begin, |
| 260 const base::Time delete_end, | 227 const base::Time delete_end, |
| 261 const GURL& url, | 228 const GURL& url, |
| 262 const DeleteCallback& callback) override; | 229 const DeleteCallback& callback) override; |
| 263 | |
| 264 void DeleteSessionCookiesAsync(const DeleteCallback&) override; | 230 void DeleteSessionCookiesAsync(const DeleteCallback&) override; |
| 231 void FlushStore(const base::Closure& callback) override; |
| 265 | 232 |
| 266 CookieMonster* GetCookieMonster() override; | 233 CookieMonster* GetCookieMonster() override; |
| 267 | 234 |
| 268 // Resets the list of cookieable schemes to the supplied schemes. Does | 235 // Resets the list of cookieable schemes to the supplied schemes. Does |
| 269 // nothing if called after first use of the instance (i.e. after the | 236 // nothing if called after first use of the instance (i.e. after the |
| 270 // instance initialization process). | 237 // instance initialization process). |
| 271 void SetCookieableSchemes(const char* const schemes[], size_t num_schemes); | 238 void SetCookieableSchemes(const char* const schemes[], size_t num_schemes); |
| 272 | 239 |
| 273 // Instructs the cookie monster to not delete expired cookies. This is used | 240 // Instructs the cookie monster to not delete expired cookies. This is used |
| 274 // in cases where the cookie monster is used as a data structure to keep | 241 // in cases where the cookie monster is used as a data structure to keep |
| (...skipping 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 virtual ~PersistentCookieStore() {} | 855 virtual ~PersistentCookieStore() {} |
| 889 | 856 |
| 890 private: | 857 private: |
| 891 friend class base::RefCountedThreadSafe<PersistentCookieStore>; | 858 friend class base::RefCountedThreadSafe<PersistentCookieStore>; |
| 892 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); | 859 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); |
| 893 }; | 860 }; |
| 894 | 861 |
| 895 } // namespace net | 862 } // namespace net |
| 896 | 863 |
| 897 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 864 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
| OLD | NEW |