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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 // Testing support. | 250 // Testing support. |
251 // For SetCookieWithCreationTime. | 251 // For SetCookieWithCreationTime. |
252 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, | 252 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, |
253 TestCookieDeleteAllCreatedBetweenTimestamps); | 253 TestCookieDeleteAllCreatedBetweenTimestamps); |
254 FRIEND_TEST_ALL_PREFIXES( | 254 FRIEND_TEST_ALL_PREFIXES( |
255 CookieMonsterTest, | 255 CookieMonsterTest, |
256 TestCookieDeleteAllCreatedBetweenTimestampsWithPredicate); | 256 TestCookieDeleteAllCreatedBetweenTimestampsWithPredicate); |
257 | 257 |
258 // For garbage collection constants. | 258 // For garbage collection constants. |
259 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestHostGarbageCollection); | 259 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestHostGarbageCollection); |
260 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestTotalGarbageCollection); | |
261 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, GarbageCollectionTriggers); | 260 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, GarbageCollectionTriggers); |
| 261 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, |
| 262 GarbageCollectWithSecureCookiesOnly); |
262 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestGCTimes); | 263 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestGCTimes); |
263 | 264 |
264 // For validation of key values. | 265 // For validation of key values. |
265 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestDomainTree); | 266 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestDomainTree); |
266 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestImport); | 267 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestImport); |
267 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, GetKey); | 268 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, GetKey); |
268 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestGetKey); | 269 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, TestGetKey); |
269 | 270 |
270 // For FindCookiesForKey. | 271 // For FindCookiesForKey. |
271 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, ShortLivedSessionCookies); | 272 FRIEND_TEST_ALL_PREFIXES(CookieMonsterTest, ShortLivedSessionCookies); |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
598 // Helper for GarbageCollect(). Deletes all cookies in the range specified by | 599 // Helper for GarbageCollect(). Deletes all cookies in the range specified by |
599 // [|it_begin|, |it_end|). Returns the number of cookies deleted. | 600 // [|it_begin|, |it_end|). Returns the number of cookies deleted. |
600 size_t GarbageCollectDeleteRange(const base::Time& current, | 601 size_t GarbageCollectDeleteRange(const base::Time& current, |
601 DeletionCause cause, | 602 DeletionCause cause, |
602 CookieItVector::iterator cookie_its_begin, | 603 CookieItVector::iterator cookie_its_begin, |
603 CookieItVector::iterator cookie_its_end); | 604 CookieItVector::iterator cookie_its_end); |
604 | 605 |
605 // Helper for GarbageCollect(). Deletes cookies in |cookie_its| from least to | 606 // Helper for GarbageCollect(). Deletes cookies in |cookie_its| from least to |
606 // most recently used, but only before |safe_date|. Also will stop deleting | 607 // most recently used, but only before |safe_date|. Also will stop deleting |
607 // when the number of remaining cookies hits |purge_goal|. | 608 // when the number of remaining cookies hits |purge_goal|. |
| 609 // |
| 610 // Sets |earliest_time| to be the earliest last access time of a cookie that |
| 611 // was not deleted, or base::Time() if no such cookie exists. |
608 size_t GarbageCollectLeastRecentlyAccessed(const base::Time& current, | 612 size_t GarbageCollectLeastRecentlyAccessed(const base::Time& current, |
609 const base::Time& safe_date, | 613 const base::Time& safe_date, |
610 size_t purge_goal, | 614 size_t purge_goal, |
611 CookieItVector cookie_its); | 615 CookieItVector cookie_its, |
| 616 base::Time* earliest_time); |
612 | 617 |
613 // Find the key (for lookup in cookies_) based on the given domain. | 618 // Find the key (for lookup in cookies_) based on the given domain. |
614 // See comment on keys before the CookieMap typedef. | 619 // See comment on keys before the CookieMap typedef. |
615 std::string GetKey(const std::string& domain) const; | 620 std::string GetKey(const std::string& domain) const; |
616 | 621 |
617 bool HasCookieableScheme(const GURL& url); | 622 bool HasCookieableScheme(const GURL& url); |
618 | 623 |
619 // Statistics support | 624 // Statistics support |
620 | 625 |
621 // This function should be called repeatedly, and will record | 626 // This function should be called repeatedly, and will record |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
705 | 710 |
706 base::Time last_time_seen_; | 711 base::Time last_time_seen_; |
707 | 712 |
708 // Minimum delay after updating a cookie's LastAccessDate before we will | 713 // Minimum delay after updating a cookie's LastAccessDate before we will |
709 // update it again. | 714 // update it again. |
710 const base::TimeDelta last_access_threshold_; | 715 const base::TimeDelta last_access_threshold_; |
711 | 716 |
712 // Approximate date of access time of least recently accessed cookie | 717 // Approximate date of access time of least recently accessed cookie |
713 // in |cookies_|. Note that this is not guaranteed to be accurate, only a) | 718 // in |cookies_|. Note that this is not guaranteed to be accurate, only a) |
714 // to be before or equal to the actual time, and b) to be accurate | 719 // to be before or equal to the actual time, and b) to be accurate |
715 // immediately after a garbage collection that scans through all the cookies. | 720 // immediately after a garbage collection that scans through all the cookies |
716 // This value is used to determine whether global garbage collection might | 721 // (When garbage collection does not scan through all cookies, it may not be |
717 // find cookies to purge. | 722 // updated). This value is used to determine whether global garbage collection |
718 // Note: The default Time() constructor will create a value that compares | 723 // might find cookies to purge. Note: The default Time() constructor will |
719 // earlier than any other time value, which is wanted. Thus this | 724 // create a value that compares earlier than any other time value, which is |
720 // value is not initialized. | 725 // wanted. Thus this value is not initialized. |
721 base::Time earliest_access_time_; | 726 base::Time earliest_access_time_; |
722 | 727 |
723 // During loading, holds the set of all loaded cookie creation times. Used to | 728 // During loading, holds the set of all loaded cookie creation times. Used to |
724 // avoid ever letting cookies with duplicate creation times into the store; | 729 // avoid ever letting cookies with duplicate creation times into the store; |
725 // that way we don't have to worry about what sections of code are safe | 730 // that way we don't have to worry about what sections of code are safe |
726 // to call while it's in that state. | 731 // to call while it's in that state. |
727 std::set<int64_t> creation_times_; | 732 std::set<int64_t> creation_times_; |
728 | 733 |
729 std::vector<std::string> cookieable_schemes_; | 734 std::vector<std::string> cookieable_schemes_; |
730 | 735 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
816 virtual ~PersistentCookieStore() {} | 821 virtual ~PersistentCookieStore() {} |
817 | 822 |
818 private: | 823 private: |
819 friend class base::RefCountedThreadSafe<PersistentCookieStore>; | 824 friend class base::RefCountedThreadSafe<PersistentCookieStore>; |
820 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); | 825 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); |
821 }; | 826 }; |
822 | 827 |
823 } // namespace net | 828 } // namespace net |
824 | 829 |
825 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 830 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
OLD | NEW |