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

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

Issue 1698693002: Make CookieStore no longer threadsafe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@getcookiemonster
Patch Set: merge Created 4 years, 9 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.h"
14 #include "base/callback_list.h" 14 #include "base/callback_list.h"
15 #include "base/memory/ref_counted.h" 15 #include "base/memory/ref_counted.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 {
24 24
25 class CookieMonster; 25 class CookieMonster;
26 26
27 // An interface for storing and retrieving cookies. Implementations need to 27 // An interface for storing and retrieving cookies. Implementations are not
28 // be thread safe as its methods can be accessed from IO as well as UI threads. 28 // thread safe, as with most other net classes. All methods must be invoked on
29 // the network thread, and all callbacks will be calle there.
29 // 30 //
30 // All async functions may either invoke the callback asynchronously on the same 31 // All async functions may either invoke the callback asynchronously, or they
31 // thread, or they may be invoked immediately (prior to return of the 32 // may be invoked immediately (prior to return of the asynchronous function).
32 // asynchronous function). 33 // Destroying the CookieStore will cancel pending async callbacks.
33 class NET_EXPORT CookieStore : public base::RefCountedThreadSafe<CookieStore> { 34 class NET_EXPORT CookieStore : public base::RefCountedThreadSafe<CookieStore> {
34 public: 35 public:
35 // Callback definitions. 36 // Callback definitions.
36 typedef base::Callback<void(const CookieList& cookies)> GetCookieListCallback; 37 typedef base::Callback<void(const CookieList& cookies)> GetCookieListCallback;
37 typedef base::Callback<void(const std::string& cookie)> GetCookiesCallback; 38 typedef base::Callback<void(const std::string& cookie)> GetCookiesCallback;
38 typedef base::Callback<void(bool success)> SetCookiesCallback; 39 typedef base::Callback<void(bool success)> SetCookiesCallback;
39 typedef base::Callback<void(int num_deleted)> DeleteCallback; 40 typedef base::Callback<void(int num_deleted)> DeleteCallback;
40 typedef base::Callback<void(const CanonicalCookie& cookie, bool removed)> 41 typedef base::Callback<void(const CanonicalCookie& cookie, bool removed)>
41 CookieChangedCallback; 42 CookieChangedCallback;
42 typedef base::CallbackList<void(const CanonicalCookie& cookie, bool removed)> 43 typedef base::CallbackList<void(const CanonicalCookie& cookie, bool removed)>
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 const GURL& url, 165 const GURL& url,
165 const DeleteCallback& callback) = 0; 166 const DeleteCallback& callback) = 0;
166 167
167 virtual void DeleteSessionCookiesAsync(const DeleteCallback&) = 0; 168 virtual void DeleteSessionCookiesAsync(const DeleteCallback&) = 0;
168 169
169 // Deletes all cookies in the store. 170 // Deletes all cookies in the store.
170 void DeleteAllAsync(const DeleteCallback& callback); 171 void DeleteAllAsync(const DeleteCallback& callback);
171 172
172 // Flush the backing store (if any) to disk and post the given callback when 173 // Flush the backing store (if any) to disk and post the given callback when
173 // done. 174 // done.
174 // WARNING: THE CALLBACK WILL RUN ON A RANDOM THREAD. IT MUST BE THREAD SAFE.
175 // It may be posted to the current thread, or it may run on the thread that
176 // actually does the flushing. Your Task should generally post a notification
177 // to the thread you actually want to be notified on.
178 // TODO(mmenke): Once this class is no longer thread-safe, this will always
179 // be invoked on the CookieStore's thread, and this comment can be removed.
180 // https://crbug.com/46185
181 virtual void FlushStore(const base::Closure& callback) = 0; 175 virtual void FlushStore(const base::Closure& callback) = 0;
182 176
183 // Protects session cookies from deletion on shutdown, if the underlying 177 // Protects session cookies from deletion on shutdown, if the underlying
184 // CookieStore implemention is currently configured to store them to disk. 178 // CookieStore implemention is currently configured to store them to disk.
185 // Otherwise, does nothing. 179 // Otherwise, does nothing.
186 virtual void SetForceKeepSessionState(); 180 virtual void SetForceKeepSessionState();
187 181
188 // Add a callback to be notified when the set of cookies named |name| that 182 // Add a callback to be notified when the set of cookies named |name| that
189 // would be sent for a request to |url| changes. The returned handle is 183 // would be sent for a request to |url| changes. The returned handle is
190 // guaranteed not to hold a hard reference to the CookieStore object. 184 // guaranteed not to hold a hard reference to the CookieStore object.
(...skipping 17 matching lines...) Expand all
208 202
209 protected: 203 protected:
210 friend class base::RefCountedThreadSafe<CookieStore>; 204 friend class base::RefCountedThreadSafe<CookieStore>;
211 CookieStore(); 205 CookieStore();
212 virtual ~CookieStore(); 206 virtual ~CookieStore();
213 }; 207 };
214 208
215 } // namespace net 209 } // namespace net
216 210
217 #endif // NET_COOKIES_COOKIE_STORE_H_ 211 #endif // NET_COOKIES_COOKIE_STORE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698