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 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
273 // Internal reasons for deletion, used to populate informative histograms | 273 // Internal reasons for deletion, used to populate informative histograms |
274 // and to provide a public cause for onCookieChange notifications. | 274 // and to provide a public cause for onCookieChange notifications. |
275 // | 275 // |
276 // If you add or remove causes from this list, please be sure to also update | 276 // If you add or remove causes from this list, please be sure to also update |
277 // the CookieMonsterDelegate::ChangeCause mapping inside ChangeCauseMapping. | 277 // the CookieMonsterDelegate::ChangeCause mapping inside ChangeCauseMapping. |
278 // Moreover, these are used as array indexes, so avoid reordering to keep the | 278 // Moreover, these are used as array indexes, so avoid reordering to keep the |
279 // histogram buckets consistent. New items (if necessary) should be added | 279 // histogram buckets consistent. New items (if necessary) should be added |
280 // at the end of the list, just before DELETE_COOKIE_LAST_ENTRY. | 280 // at the end of the list, just before DELETE_COOKIE_LAST_ENTRY. |
281 enum DeletionCause { | 281 enum DeletionCause { |
282 DELETE_COOKIE_EXPLICIT = 0, | 282 DELETE_COOKIE_EXPLICIT = 0, |
283 DELETE_COOKIE_OVERWRITE, | 283 DELETE_COOKIE_OVERWRITE = 1, |
284 DELETE_COOKIE_EXPIRED, | 284 DELETE_COOKIE_EXPIRED = 2, |
285 DELETE_COOKIE_EVICTED, | 285 DELETE_COOKIE_EVICTED = 3, |
286 DELETE_COOKIE_DUPLICATE_IN_BACKING_STORE, | 286 DELETE_COOKIE_DUPLICATE_IN_BACKING_STORE = 4, |
287 DELETE_COOKIE_DONT_RECORD, // e.g. For final cleanup after flush to store. | 287 DELETE_COOKIE_DONT_RECORD = 5, // For final cleanup after flush to store. |
288 DELETE_COOKIE_EVICTED_DOMAIN, | |
289 DELETE_COOKIE_EVICTED_GLOBAL, | |
290 | 288 |
291 // Cookies evicted during domain level garbage collection that | 289 // Cookies evicted during domain-level garbage collection. |
292 // were accessed longer ago than kSafeFromGlobalPurgeDays | 290 DELETE_COOKIE_EVICTED_DOMAIN = 6, |
293 DELETE_COOKIE_EVICTED_DOMAIN_PRE_SAFE, | |
294 | 291 |
295 // Cookies evicted during domain level garbage collection that | 292 // Cookies evicted during global garbage collection (which takes place after |
296 // were accessed more recently than kSafeFromGlobalPurgeDays | 293 // domain-level garbage collection fails to bring the cookie store under |
297 // (and thus would have been preserved by global garbage collection). | 294 // the overall quota. |
298 DELETE_COOKIE_EVICTED_DOMAIN_POST_SAFE, | 295 DELETE_COOKIE_EVICTED_GLOBAL = 7, |
| 296 |
| 297 // #8 was DELETE_COOKIE_EVICTED_DOMAIN_PRE_SAFE |
| 298 // #9 was DELETE_COOKIE_EVICTED_DOMAIN_POST_SAFE |
299 | 299 |
300 // A common idiom is to remove a cookie by overwriting it with an | 300 // A common idiom is to remove a cookie by overwriting it with an |
301 // already-expired expiration date. This captures that case. | 301 // already-expired expiration date. This captures that case. |
302 DELETE_COOKIE_EXPIRED_OVERWRITE, | 302 DELETE_COOKIE_EXPIRED_OVERWRITE = 10, |
303 | 303 |
304 // Cookies are not allowed to contain control characters in the name or | 304 // Cookies are not allowed to contain control characters in the name or |
305 // value. However, we used to allow them, so we are now evicting any such | 305 // value. However, we used to allow them, so we are now evicting any such |
306 // cookies as we load them. See http://crbug.com/238041. | 306 // cookies as we load them. See http://crbug.com/238041. |
307 DELETE_COOKIE_CONTROL_CHAR, | 307 DELETE_COOKIE_CONTROL_CHAR = 11, |
308 | 308 |
309 // When strict secure cookies is enabled, non-secure cookies are evicted | 309 // When strict secure cookies is enabled, non-secure cookies are evicted |
310 // right after expired cookies. | 310 // right after expired cookies. |
311 DELETE_COOKIE_NON_SECURE, | 311 DELETE_COOKIE_NON_SECURE = 12, |
312 | 312 |
313 DELETE_COOKIE_LAST_ENTRY | 313 DELETE_COOKIE_LAST_ENTRY = 13 |
314 }; | 314 }; |
315 | 315 |
316 // This enum is used to generate a histogramed bitmask measureing the types | 316 // This enum is used to generate a histogramed bitmask measureing the types |
317 // of stored cookies. Please do not reorder the list when adding new entries. | 317 // of stored cookies. Please do not reorder the list when adding new entries. |
318 // New items MUST be added at the end of the list, just before | 318 // New items MUST be added at the end of the list, just before |
319 // COOKIE_TYPE_LAST_ENTRY; | 319 // COOKIE_TYPE_LAST_ENTRY; |
320 enum CookieType { | 320 enum CookieType { |
321 COOKIE_TYPE_SAME_SITE = 0, | 321 COOKIE_TYPE_SAME_SITE = 0, |
322 COOKIE_TYPE_HTTPONLY, | 322 COOKIE_TYPE_HTTPONLY, |
323 COOKIE_TYPE_SECURE, | 323 COOKIE_TYPE_SECURE, |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 size_t GarbageCollect(const base::Time& current, | 540 size_t GarbageCollect(const base::Time& current, |
541 const std::string& key, | 541 const std::string& key, |
542 bool enforce_strict_secure); | 542 bool enforce_strict_secure); |
543 | 543 |
544 // Helper for GarbageCollect(). Deletes up to |purge_goal| cookies with a | 544 // Helper for GarbageCollect(). Deletes up to |purge_goal| cookies with a |
545 // priority less than or equal to |priority| from |cookies|, while ensuring | 545 // priority less than or equal to |priority| from |cookies|, while ensuring |
546 // that at least the |to_protect| most-recent cookies are retained. | 546 // that at least the |to_protect| most-recent cookies are retained. |
547 // | 547 // |
548 // |cookies| must be sorted from least-recent to most-recent. | 548 // |cookies| must be sorted from least-recent to most-recent. |
549 // | 549 // |
550 // |safe_date| is only used to determine the deletion cause for histograms. | |
551 // | |
552 // Returns the number of cookies deleted. | 550 // Returns the number of cookies deleted. |
553 size_t PurgeLeastRecentMatches(CookieItVector* cookies, | 551 size_t PurgeLeastRecentMatches(CookieItVector* cookies, |
554 CookiePriority priority, | 552 CookiePriority priority, |
555 size_t to_protect, | 553 size_t to_protect, |
556 size_t purge_goal, | 554 size_t purge_goal); |
557 const base::Time& safe_date); | |
558 | 555 |
559 // Helper for GarbageCollect(); can be called directly as well. Deletes all | 556 // Helper for GarbageCollect(); can be called directly as well. Deletes all |
560 // expired cookies in |itpair|. If |cookie_its| is non-NULL, all the | 557 // expired cookies in |itpair|. If |cookie_its| is non-NULL, all the |
561 // non-expired cookies from |itpair| are appended to |cookie_its|. | 558 // non-expired cookies from |itpair| are appended to |cookie_its|. |
562 // | 559 // |
563 // Returns the number of cookies deleted. | 560 // Returns the number of cookies deleted. |
564 size_t GarbageCollectExpired(const base::Time& current, | 561 size_t GarbageCollectExpired(const base::Time& current, |
565 const CookieMapItPair& itpair, | 562 const CookieMapItPair& itpair, |
566 CookieItVector* cookie_its); | 563 CookieItVector* cookie_its); |
567 | 564 |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
805 virtual ~PersistentCookieStore() {} | 802 virtual ~PersistentCookieStore() {} |
806 | 803 |
807 private: | 804 private: |
808 friend class base::RefCountedThreadSafe<PersistentCookieStore>; | 805 friend class base::RefCountedThreadSafe<PersistentCookieStore>; |
809 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); | 806 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); |
810 }; | 807 }; |
811 | 808 |
812 } // namespace net | 809 } // namespace net |
813 | 810 |
814 #endif // NET_COOKIES_COOKIE_MONSTER_H_ | 811 #endif // NET_COOKIES_COOKIE_MONSTER_H_ |
OLD | NEW |