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 #pragma once | 9 #pragma once |
10 | 10 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
185 // "enable_file_scheme_". | 185 // "enable_file_scheme_". |
186 // If this this method is called, it must be called before first use of | 186 // If this this method is called, it must be called before first use of |
187 // the instance (i.e. as part of the instance initialization process). | 187 // the instance (i.e. as part of the instance initialization process). |
188 void SetCookieableSchemes(const char* schemes[], size_t num_schemes); | 188 void SetCookieableSchemes(const char* schemes[], size_t num_schemes); |
189 | 189 |
190 // Instructs the cookie monster to not delete expired cookies. This is used | 190 // Instructs the cookie monster to not delete expired cookies. This is used |
191 // in cases where the cookie monster is used as a data structure to keep | 191 // in cases where the cookie monster is used as a data structure to keep |
192 // arbitrary cookies. | 192 // arbitrary cookies. |
193 void SetKeepExpiredCookies(); | 193 void SetKeepExpiredCookies(); |
194 | 194 |
195 // Delegates the call to set the |clear_local_store_on_exit_| flag of the | 195 // Protects session cookies from deletion on shutdown. |
196 // PersistentStore if it exists. | 196 void SetForceKeepSessionState(); |
197 void SetClearPersistentStoreOnExit(bool clear_local_store); | |
198 | 197 |
199 // There are some unknowns about how to correctly handle file:// cookies, | 198 // There are some unknowns about how to correctly handle file:// cookies, |
200 // and our implementation for this is not robust enough. This allows you | 199 // and our implementation for this is not robust enough. This allows you |
201 // to enable support, but it should only be used for testing. Bug 1157243. | 200 // to enable support, but it should only be used for testing. Bug 1157243. |
202 // Must be called before creating a CookieMonster instance. | 201 // Must be called before creating a CookieMonster instance. |
203 static void EnableFileScheme(); | 202 static void EnableFileScheme(); |
204 | 203 |
205 // Flush the backing store (if any) to disk and post the given callback when | 204 // Flush the backing store (if any) to disk and post the given callback when |
206 // done. | 205 // done. |
207 // WARNING: THE CALLBACK WILL RUN ON A RANDOM THREAD. IT MUST BE THREAD SAFE. | 206 // WARNING: THE CALLBACK WILL RUN ON A RANDOM THREAD. IT MUST BE THREAD SAFE. |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
248 | 247 |
249 virtual void DeleteSessionCookiesAsync(const DeleteCallback&) OVERRIDE; | 248 virtual void DeleteSessionCookiesAsync(const DeleteCallback&) OVERRIDE; |
250 | 249 |
251 virtual CookieMonster* GetCookieMonster() OVERRIDE; | 250 virtual CookieMonster* GetCookieMonster() OVERRIDE; |
252 | 251 |
253 // Enables writing session cookies into the cookie database. If this this | 252 // Enables writing session cookies into the cookie database. If this this |
254 // method is called, it must be called before first use of the instance | 253 // method is called, it must be called before first use of the instance |
255 // (i.e. as part of the instance initialization process). | 254 // (i.e. as part of the instance initialization process). |
256 void SetPersistSessionCookies(bool persist_session_cookies); | 255 void SetPersistSessionCookies(bool persist_session_cookies); |
257 | 256 |
258 // Protects session cookies from deletion on shutdown. | |
259 void SaveSessionCookies(); | |
260 | |
261 // Debugging method to perform various validation checks on the map. | 257 // Debugging method to perform various validation checks on the map. |
262 // Currently just checking that there are no null CanonicalCookie pointers | 258 // Currently just checking that there are no null CanonicalCookie pointers |
263 // in the map. | 259 // in the map. |
264 // Argument |arg| is to allow retaining of arbitrary data if the CHECKs | 260 // Argument |arg| is to allow retaining of arbitrary data if the CHECKs |
265 // in the function trip. TODO(rdsmith):Remove hack. | 261 // in the function trip. TODO(rdsmith):Remove hack. |
266 void ValidateMap(int arg); | 262 void ValidateMap(int arg); |
267 | 263 |
268 // The default list of schemes the cookie monster can handle. | 264 // The default list of schemes the cookie monster can handle. |
269 static const char* kDefaultCookieableSchemes[]; | 265 static const char* kDefaultCookieableSchemes[]; |
270 static const int kDefaultCookieableSchemesCount; | 266 static const int kDefaultCookieableSchemesCount; |
(...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 // loads, which includes cookies for the requested domain key if they are not | 941 // loads, which includes cookies for the requested domain key if they are not |
946 // already returned, plus all cookies that are chain-loaded and not yet | 942 // already returned, plus all cookies that are chain-loaded and not yet |
947 // returned to CookieMonster. | 943 // returned to CookieMonster. |
948 virtual void LoadCookiesForKey(const std::string& key, | 944 virtual void LoadCookiesForKey(const std::string& key, |
949 const LoadedCallback& loaded_callback) = 0; | 945 const LoadedCallback& loaded_callback) = 0; |
950 | 946 |
951 virtual void AddCookie(const CanonicalCookie& cc) = 0; | 947 virtual void AddCookie(const CanonicalCookie& cc) = 0; |
952 virtual void UpdateCookieAccessTime(const CanonicalCookie& cc) = 0; | 948 virtual void UpdateCookieAccessTime(const CanonicalCookie& cc) = 0; |
953 virtual void DeleteCookie(const CanonicalCookie& cc) = 0; | 949 virtual void DeleteCookie(const CanonicalCookie& cc) = 0; |
954 | 950 |
955 // Sets the value of the user preference whether the persistent storage | 951 // Instructs the store to not discard session only cookies on shutdown. |
956 // must be deleted upon destruction. | 952 virtual void SetForceKeepSessionState() = 0; |
957 virtual void SetClearLocalStateOnExit(bool clear_local_state) = 0; | |
958 | 953 |
959 // Flushes the store and posts |callback| when complete. | 954 // Flushes the store and posts |callback| when complete. |
960 virtual void Flush(const base::Closure& callback) = 0; | 955 virtual void Flush(const base::Closure& callback) = 0; |
961 | 956 |
962 protected: | 957 protected: |
963 PersistentCookieStore() {} | 958 PersistentCookieStore() {} |
964 virtual ~PersistentCookieStore() {} | 959 virtual ~PersistentCookieStore() {} |
965 | 960 |
966 private: | 961 private: |
967 friend class base::RefCountedThreadSafe<PersistentCookieStore>; | 962 friend class base::RefCountedThreadSafe<PersistentCookieStore>; |
968 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); | 963 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); |
969 }; | 964 }; |
970 | 965 |
971 class CookieList : public std::vector<CookieMonster::CanonicalCookie> { | 966 class CookieList : public std::vector<CookieMonster::CanonicalCookie> { |
972 }; | 967 }; |
973 | 968 |
974 } // namespace net | 969 } // namespace net |
975 | 970 |
976 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 971 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
OLD | NEW |