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

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

Issue 1701063002: CookieStore: Remove reference counting. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@threadsafe
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
« no previous file with comments | « net/cookies/cookie_monster_unittest.cc ('k') | net/cookies/cookie_store.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 {
24 24
25 class CookieMonster; 25 class CookieMonster;
26 26
27 // An interface for storing and retrieving cookies. Implementations are not 27 // An interface for storing and retrieving cookies. Implementations are not
28 // thread safe, as with most other net classes. All methods must be invoked on 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 // the network thread, and all callbacks will be calle there.
30 // 30 //
31 // All async functions may either invoke the callback asynchronously, or they 31 // All async functions may either invoke the callback asynchronously, or they
32 // may be invoked immediately (prior to return of the asynchronous function). 32 // may be invoked immediately (prior to return of the asynchronous function).
33 // Destroying the CookieStore will cancel pending async callbacks. 33 // Destroying the CookieStore will cancel pending async callbacks.
34 class NET_EXPORT CookieStore : public base::RefCountedThreadSafe<CookieStore> { 34 class NET_EXPORT CookieStore {
35 public: 35 public:
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 46
47 virtual ~CookieStore();
48
47 // Returns the cookie line (e.g. "cookie1=value1; cookie2=value2") represented 49 // Returns the cookie line (e.g. "cookie1=value1; cookie2=value2") represented
48 // by |cookies|. The string is built in the same order as the given list. 50 // by |cookies|. The string is built in the same order as the given list.
49 // 51 //
50 // TODO(mkwst): We really should standardize on either 52 // TODO(mkwst): We really should standardize on either
51 // 'std::vector<CanonicalCookie>' or 'std::vector<CanonicalCookie*>'. 53 // 'std::vector<CanonicalCookie>' or 'std::vector<CanonicalCookie*>'.
52 static std::string BuildCookieLine( 54 static std::string BuildCookieLine(
53 const std::vector<CanonicalCookie>& cookies); 55 const std::vector<CanonicalCookie>& cookies);
54 static std::string BuildCookieLine( 56 static std::string BuildCookieLine(
55 const std::vector<CanonicalCookie*>& cookies); 57 const std::vector<CanonicalCookie*>& cookies);
56 58
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // registered that are still consumed even after all subscriptions for that 196 // registered that are still consumed even after all subscriptions for that
195 // (url, name) pair are removed. If this method ever needs to support an 197 // (url, name) pair are removed. If this method ever needs to support an
196 // unbounded amount of such pairs, this contract needs to change and 198 // unbounded amount of such pairs, this contract needs to change and
197 // implementors need to be improved to not behave this way. 199 // implementors need to be improved to not behave this way.
198 virtual scoped_ptr<CookieChangedSubscription> AddCallbackForCookie( 200 virtual scoped_ptr<CookieChangedSubscription> AddCallbackForCookie(
199 const GURL& url, 201 const GURL& url,
200 const std::string& name, 202 const std::string& name,
201 const CookieChangedCallback& callback) = 0; 203 const CookieChangedCallback& callback) = 0;
202 204
203 protected: 205 protected:
204 friend class base::RefCountedThreadSafe<CookieStore>;
205 CookieStore(); 206 CookieStore();
206 virtual ~CookieStore();
207 }; 207 };
208 208
209 } // namespace net 209 } // namespace net
210 210
211 #endif // NET_COOKIES_COOKIE_STORE_H_ 211 #endif // NET_COOKIES_COOKIE_STORE_H_
OLDNEW
« no previous file with comments | « net/cookies/cookie_monster_unittest.cc ('k') | net/cookies/cookie_store.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698