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 20 matching lines...) Expand all Loading... |
31 #include "net/cookies/cookie_constants.h" | 31 #include "net/cookies/cookie_constants.h" |
32 #include "net/cookies/cookie_store.h" | 32 #include "net/cookies/cookie_store.h" |
33 #include "url/gurl.h" | 33 #include "url/gurl.h" |
34 | 34 |
35 namespace base { | 35 namespace base { |
36 class HistogramBase; | 36 class HistogramBase; |
37 } // namespace base | 37 } // namespace base |
38 | 38 |
39 namespace net { | 39 namespace net { |
40 | 40 |
| 41 class ChannelIDService; |
41 class CookieMonsterDelegate; | 42 class CookieMonsterDelegate; |
42 | 43 |
43 // The cookie monster is the system for storing and retrieving cookies. It has | 44 // The cookie monster is the system for storing and retrieving cookies. It has |
44 // an in-memory list of all cookies, and synchronizes non-session cookies to an | 45 // an in-memory list of all cookies, and synchronizes non-session cookies to an |
45 // optional permanent storage that implements the PersistentCookieStore | 46 // optional permanent storage that implements the PersistentCookieStore |
46 // interface. | 47 // interface. |
47 // | 48 // |
48 // Tasks may be deferred if all affected cookies are not yet loaded from the | 49 // Tasks may be deferred if all affected cookies are not yet loaded from the |
49 // backing store. Otherwise, callbacks may be invoked immediately. | 50 // backing store. Otherwise, callbacks may be invoked immediately. |
50 // | 51 // |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 static const size_t kDomainCookiesQuotaHigh; | 128 static const size_t kDomainCookiesQuotaHigh; |
128 | 129 |
129 // The store passed in should not have had Init() called on it yet. This | 130 // The store passed in should not have had Init() called on it yet. This |
130 // class will take care of initializing it. The backing store is NOT owned by | 131 // class will take care of initializing it. The backing store is NOT owned by |
131 // this class, but it must remain valid for the duration of the cookie | 132 // this class, but it must remain valid for the duration of the cookie |
132 // monster's existence. If |store| is NULL, then no backing store will be | 133 // monster's existence. If |store| is NULL, then no backing store will be |
133 // updated. If |delegate| is non-NULL, it will be notified on | 134 // updated. If |delegate| is non-NULL, it will be notified on |
134 // creation/deletion of cookies. | 135 // creation/deletion of cookies. |
135 CookieMonster(PersistentCookieStore* store, CookieMonsterDelegate* delegate); | 136 CookieMonster(PersistentCookieStore* store, CookieMonsterDelegate* delegate); |
136 | 137 |
| 138 // Like above, but includes a non-owning pointer |channel_id_service| for the |
| 139 // corresponding ChannelIDService used with this CookieStore. The |
| 140 // |channel_id_service| must outlive the CookieMonster. |
| 141 CookieMonster(PersistentCookieStore* store, |
| 142 CookieMonsterDelegate* delegate, |
| 143 ChannelIDService* channel_id_service); |
| 144 |
137 // Only used during unit testing. | 145 // Only used during unit testing. |
138 CookieMonster(PersistentCookieStore* store, | 146 CookieMonster(PersistentCookieStore* store, |
139 CookieMonsterDelegate* delegate, | 147 CookieMonsterDelegate* delegate, |
140 base::TimeDelta last_access_threshold); | 148 base::TimeDelta last_access_threshold); |
141 | 149 |
142 ~CookieMonster() override; | 150 ~CookieMonster() override; |
143 | 151 |
144 // Replaces all the cookies by |list|. This method does not flush the backend. | 152 // Replaces all the cookies by |list|. This method does not flush the backend. |
145 // This method does not support setting secure cookies, which need source | 153 // This method does not support setting secure cookies, which need source |
146 // URLs. | 154 // URLs. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 static const int kDefaultCookieableSchemesCount; | 218 static const int kDefaultCookieableSchemesCount; |
211 | 219 |
212 std::unique_ptr<CookieChangedSubscription> AddCallbackForCookie( | 220 std::unique_ptr<CookieChangedSubscription> AddCallbackForCookie( |
213 const GURL& url, | 221 const GURL& url, |
214 const std::string& name, | 222 const std::string& name, |
215 const CookieChangedCallback& callback) override; | 223 const CookieChangedCallback& callback) override; |
216 | 224 |
217 bool IsEphemeral() override; | 225 bool IsEphemeral() override; |
218 | 226 |
219 private: | 227 private: |
| 228 CookieMonster(PersistentCookieStore* store, |
| 229 CookieMonsterDelegate* delegate, |
| 230 ChannelIDService* channel_id_service, |
| 231 base::TimeDelta last_access_threshold); |
| 232 |
220 // For queueing the cookie monster calls. | 233 // For queueing the cookie monster calls. |
221 class CookieMonsterTask; | 234 class CookieMonsterTask; |
222 template <typename Result> | 235 template <typename Result> |
223 class DeleteTask; | 236 class DeleteTask; |
224 class DeleteAllCreatedBetweenTask; | 237 class DeleteAllCreatedBetweenTask; |
225 class DeleteAllCreatedBetweenWithPredicateTask; | 238 class DeleteAllCreatedBetweenWithPredicateTask; |
226 class DeleteCookieTask; | 239 class DeleteCookieTask; |
227 class DeleteCanonicalCookieTask; | 240 class DeleteCanonicalCookieTask; |
228 class GetCookieListForURLWithOptionsTask; | 241 class GetCookieListForURLWithOptionsTask; |
229 class GetAllCookiesTask; | 242 class GetAllCookiesTask; |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
709 | 722 |
710 // During loading, holds the set of all loaded cookie creation times. Used to | 723 // During loading, holds the set of all loaded cookie creation times. Used to |
711 // avoid ever letting cookies with duplicate creation times into the store; | 724 // avoid ever letting cookies with duplicate creation times into the store; |
712 // that way we don't have to worry about what sections of code are safe | 725 // that way we don't have to worry about what sections of code are safe |
713 // to call while it's in that state. | 726 // to call while it's in that state. |
714 std::set<int64_t> creation_times_; | 727 std::set<int64_t> creation_times_; |
715 | 728 |
716 std::vector<std::string> cookieable_schemes_; | 729 std::vector<std::string> cookieable_schemes_; |
717 | 730 |
718 scoped_refptr<CookieMonsterDelegate> delegate_; | 731 scoped_refptr<CookieMonsterDelegate> delegate_; |
| 732 ChannelIDService* channel_id_service_; |
719 | 733 |
720 base::Time last_statistic_record_time_; | 734 base::Time last_statistic_record_time_; |
721 | 735 |
722 bool persist_session_cookies_; | 736 bool persist_session_cookies_; |
723 | 737 |
724 using CookieChangedHookMap = | 738 using CookieChangedHookMap = |
725 std::map<std::pair<GURL, std::string>, | 739 std::map<std::pair<GURL, std::string>, |
726 std::unique_ptr<CookieChangedCallbackList>>; | 740 std::unique_ptr<CookieChangedCallbackList>>; |
727 CookieChangedHookMap hook_map_; | 741 CookieChangedHookMap hook_map_; |
728 | 742 |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
802 virtual ~PersistentCookieStore() {} | 816 virtual ~PersistentCookieStore() {} |
803 | 817 |
804 private: | 818 private: |
805 friend class base::RefCountedThreadSafe<PersistentCookieStore>; | 819 friend class base::RefCountedThreadSafe<PersistentCookieStore>; |
806 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); | 820 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); |
807 }; | 821 }; |
808 | 822 |
809 } // namespace net | 823 } // namespace net |
810 | 824 |
811 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 825 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
OLD | NEW |