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

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

Issue 676073003: Add AddCallbackForCookie method to CookieStore. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix PrerenderCookieStore build Created 6 years, 1 month 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_test_helpers.h » ('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/basictypes.h" 13 #include "base/basictypes.h"
14 #include "base/callback.h" 14 #include "base/callback.h"
15 #include "base/callback_list.h"
15 #include "base/memory/ref_counted.h" 16 #include "base/memory/ref_counted.h"
16 #include "base/time/time.h" 17 #include "base/time/time.h"
17 #include "net/base/net_export.h" 18 #include "net/base/net_export.h"
18 #include "net/cookies/canonical_cookie.h" 19 #include "net/cookies/canonical_cookie.h"
19 #include "net/cookies/cookie_options.h" 20 #include "net/cookies/cookie_options.h"
20 21
21 class GURL; 22 class GURL;
22 23
23 namespace net { 24 namespace net {
24 25
25 class CookieMonster; 26 class CookieMonster;
26 27
27 // An interface for storing and retrieving cookies. Implementations need to 28 // An interface for storing and retrieving cookies. Implementations need to
28 // be thread safe as its methods can be accessed from IO as well as UI threads. 29 // be thread safe as its methods can be accessed from IO as well as UI threads.
29 class NET_EXPORT CookieStore : public base::RefCountedThreadSafe<CookieStore> { 30 class NET_EXPORT CookieStore : public base::RefCountedThreadSafe<CookieStore> {
30 public: 31 public:
31 // Callback definitions. 32 // Callback definitions.
32 typedef base::Callback<void(const CookieList& cookies)> GetCookieListCallback; 33 typedef base::Callback<void(const CookieList& cookies)> GetCookieListCallback;
33 typedef base::Callback<void(const std::string& cookie)> GetCookiesCallback; 34 typedef base::Callback<void(const std::string& cookie)> GetCookiesCallback;
34 typedef base::Callback<void(bool success)> SetCookiesCallback; 35 typedef base::Callback<void(bool success)> SetCookiesCallback;
35 typedef base::Callback<void(int num_deleted)> DeleteCallback; 36 typedef base::Callback<void(int num_deleted)> DeleteCallback;
37 typedef base::Closure CookieChangedCallback;
38 typedef base::CallbackList<void(void)> CookieChangedCallbackList;
39 typedef CookieChangedCallbackList::Subscription CookieChangedSubscription;
36 40
37 // Sets a single cookie. Expects a cookie line, like "a=1; domain=b.com". 41 // Sets a single cookie. Expects a cookie line, like "a=1; domain=b.com".
38 // 42 //
39 // Fails either if the cookie is invalid or if this is a non-HTTPONLY cookie 43 // Fails either if the cookie is invalid or if this is a non-HTTPONLY cookie
40 // and it would overwrite an existing HTTPONLY cookie. 44 // and it would overwrite an existing HTTPONLY cookie.
41 // Returns true if the cookie is successfully set. 45 // Returns true if the cookie is successfully set.
42 virtual void SetCookieWithOptionsAsync( 46 virtual void SetCookieWithOptionsAsync(
43 const GURL& url, 47 const GURL& url,
44 const std::string& cookie_line, 48 const std::string& cookie_line,
45 const CookieOptions& options, 49 const CookieOptions& options,
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 const base::Time delete_begin, 88 const base::Time delete_begin,
85 const base::Time delete_end, 89 const base::Time delete_end,
86 const GURL& url, 90 const GURL& url,
87 const DeleteCallback& callback) = 0; 91 const DeleteCallback& callback) = 0;
88 92
89 virtual void DeleteSessionCookiesAsync(const DeleteCallback&) = 0; 93 virtual void DeleteSessionCookiesAsync(const DeleteCallback&) = 0;
90 94
91 // Returns the underlying CookieMonster. 95 // Returns the underlying CookieMonster.
92 virtual CookieMonster* GetCookieMonster() = 0; 96 virtual CookieMonster* GetCookieMonster() = 0;
93 97
98 // Add a callback to be notified when the set of cookies named |name| that
99 // would be sent for a request to |url| changes. The returned handle is
100 // guaranteed not to hold a hard reference to the CookieStore object.
101 //
102 // Note that this method consumes memory and CPU per (url, name) pair ever
103 // registered that are still consumed even after all subscriptions for that
104 // (url, name) pair are removed. If this method ever needs to support an
105 // unbounded amount of such pairs, this contract needs to change and
106 // implementors need to be improved to not behave this way.
107 virtual scoped_ptr<CookieChangedSubscription> AddCallbackForCookie(
108 const GURL& url,
109 const std::string& name,
110 const CookieChangedCallback& callback) = 0;
111
94 protected: 112 protected:
95 friend class base::RefCountedThreadSafe<CookieStore>; 113 friend class base::RefCountedThreadSafe<CookieStore>;
96 CookieStore(); 114 CookieStore();
97 virtual ~CookieStore(); 115 virtual ~CookieStore();
98 }; 116 };
99 117
100 } // namespace net 118 } // namespace net
101 119
102 #endif // NET_COOKIES_COOKIE_STORE_H_ 120 #endif // NET_COOKIES_COOKIE_STORE_H_
OLDNEW
« no previous file with comments | « net/cookies/cookie_monster_unittest.cc ('k') | net/cookies/cookie_store_test_helpers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698