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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
122 // | 122 // |
123 // Any cookies accessed more recently than kSafeFromGlobalPurgeDays will not | 123 // Any cookies accessed more recently than kSafeFromGlobalPurgeDays will not |
124 // be evicted by global garbage collection, even if we have more than | 124 // be evicted by global garbage collection, even if we have more than |
125 // kMaxCookies. This does not affect domain garbage collection. | 125 // kMaxCookies. This does not affect domain garbage collection. |
126 static const size_t kDomainMaxCookies; | 126 static const size_t kDomainMaxCookies; |
127 static const size_t kDomainPurgeCookies; | 127 static const size_t kDomainPurgeCookies; |
128 static const size_t kMaxCookies; | 128 static const size_t kMaxCookies; |
129 static const size_t kPurgeCookies; | 129 static const size_t kPurgeCookies; |
130 | 130 |
131 // Quota for cookies with {low, medium, high} priorities within a domain. | 131 // Quota for cookies with {low, medium, high} priorities within a domain. |
132 static const size_t kDomainCookiesQuotaLow; | 132 static const float kDomainCookiesQuotaLow; |
jww
2016/02/18 01:05:19
I think an explanation of this being a float is ne
| |
133 static const size_t kDomainCookiesQuotaMedium; | 133 static const float kDomainCookiesQuotaMedium; |
134 static const size_t kDomainCookiesQuotaHigh; | 134 static const float kDomainCookiesQuotaHigh; |
135 | 135 |
136 // The store passed in should not have had Init() called on it yet. This | 136 // The store passed in should not have had Init() called on it yet. This |
137 // class will take care of initializing it. The backing store is NOT owned by | 137 // class will take care of initializing it. The backing store is NOT owned by |
138 // this class, but it must remain valid for the duration of the cookie | 138 // this class, but it must remain valid for the duration of the cookie |
139 // monster's existence. If |store| is NULL, then no backing store will be | 139 // monster's existence. If |store| is NULL, then no backing store will be |
140 // updated. If |delegate| is non-NULL, it will be notified on | 140 // updated. If |delegate| is non-NULL, it will be notified on |
141 // creation/deletion of cookies. | 141 // creation/deletion of cookies. |
142 CookieMonster(PersistentCookieStore* store, CookieMonsterDelegate* delegate); | 142 CookieMonster(PersistentCookieStore* store, CookieMonsterDelegate* delegate); |
143 | 143 |
144 // Only used during unit testing. | 144 // Only used during unit testing. |
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
368 // directly before COOKIE_DELETE_EQUIVALENT_LAST_ENTRY and histograms.xml must | 368 // directly before COOKIE_DELETE_EQUIVALENT_LAST_ENTRY and histograms.xml must |
369 // be updated accordingly. | 369 // be updated accordingly. |
370 enum CookieDeleteEquivalent { | 370 enum CookieDeleteEquivalent { |
371 COOKIE_DELETE_EQUIVALENT_ATTEMPT = 0, | 371 COOKIE_DELETE_EQUIVALENT_ATTEMPT = 0, |
372 COOKIE_DELETE_EQUIVALENT_FOUND, | 372 COOKIE_DELETE_EQUIVALENT_FOUND, |
373 COOKIE_DELETE_EQUIVALENT_SKIPPING_SECURE, | 373 COOKIE_DELETE_EQUIVALENT_SKIPPING_SECURE, |
374 COOKIE_DELETE_EQUIVALENT_WOULD_HAVE_DELETED, | 374 COOKIE_DELETE_EQUIVALENT_WOULD_HAVE_DELETED, |
375 COOKIE_DELETE_EQUIVALENT_LAST_ENTRY | 375 COOKIE_DELETE_EQUIVALENT_LAST_ENTRY |
376 }; | 376 }; |
377 | 377 |
378 enum GCType { GC_NONSECURE, GC_SECURE }; | |
379 | |
378 // The strategy for fetching cookies. Controlled by Finch experiment. | 380 // The strategy for fetching cookies. Controlled by Finch experiment. |
379 enum FetchStrategy { | 381 enum FetchStrategy { |
380 // Fetches all cookies only when they're needed. | 382 // Fetches all cookies only when they're needed. |
381 kFetchWhenNecessary = 0, | 383 kFetchWhenNecessary = 0, |
382 // Fetches all cookies as soon as any cookie is needed. | 384 // Fetches all cookies as soon as any cookie is needed. |
383 // This is the default behavior. | 385 // This is the default behavior. |
384 kAlwaysFetch, | 386 kAlwaysFetch, |
385 // The fetch strategy is not yet determined. | 387 // The fetch strategy is not yet determined. |
386 kUnknownFetch, | 388 kUnknownFetch, |
387 }; | 389 }; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
584 CookieItVector::iterator cookie_its_end); | 586 CookieItVector::iterator cookie_its_end); |
585 | 587 |
586 // Helper for GarbageCollect(). Deletes cookies in |cookie_its| from least to | 588 // Helper for GarbageCollect(). Deletes cookies in |cookie_its| from least to |
587 // most recently used, but only before |safe_date|. Also will stop deleting | 589 // most recently used, but only before |safe_date|. Also will stop deleting |
588 // when the number of remaining cookies hits |purge_goal|. | 590 // when the number of remaining cookies hits |purge_goal|. |
589 size_t GarbageCollectLeastRecentlyAccessed(const base::Time& current, | 591 size_t GarbageCollectLeastRecentlyAccessed(const base::Time& current, |
590 const base::Time& safe_date, | 592 const base::Time& safe_date, |
591 size_t purge_goal, | 593 size_t purge_goal, |
592 CookieItVector cookie_its); | 594 CookieItVector cookie_its); |
593 | 595 |
596 size_t GarbageCollectNumFromRangeWithQuota(const base::Time& current, | |
597 const base::Time& safe_date, | |
598 size_t purge_goal, | |
599 CookieItVector::iterator* it_bdd, | |
600 GCType type); | |
601 | |
594 // Find the key (for lookup in cookies_) based on the given domain. | 602 // Find the key (for lookup in cookies_) based on the given domain. |
595 // See comment on keys before the CookieMap typedef. | 603 // See comment on keys before the CookieMap typedef. |
596 std::string GetKey(const std::string& domain) const; | 604 std::string GetKey(const std::string& domain) const; |
597 | 605 |
598 bool HasCookieableScheme(const GURL& url); | 606 bool HasCookieableScheme(const GURL& url); |
599 | 607 |
600 // Statistics support | 608 // Statistics support |
601 | 609 |
602 // This function should be called repeatedly, and will record | 610 // This function should be called repeatedly, and will record |
603 // statistics if a sufficient time period has passed. | 611 // statistics if a sufficient time period has passed. |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
791 virtual ~PersistentCookieStore() {} | 799 virtual ~PersistentCookieStore() {} |
792 | 800 |
793 private: | 801 private: |
794 friend class base::RefCountedThreadSafe<PersistentCookieStore>; | 802 friend class base::RefCountedThreadSafe<PersistentCookieStore>; |
795 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); | 803 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); |
796 }; | 804 }; |
797 | 805 |
798 } // namespace net | 806 } // namespace net |
799 | 807 |
800 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 808 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
OLD | NEW |