Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(125)

Side by Side Diff: net/cookies/cookie_monster.h

Issue 1770183003: Revert of Evict non-secure cookies less agressively. (patchset #4 id:60001 of https://codereview.ch… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | net/cookies/cookie_monster.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // The quota is specified as a percentage of the total number of cookies we 132 static const size_t kDomainCookiesQuotaLow;
133 // intend to retain for a domain. 133 static const size_t kDomainCookiesQuotaMedium;
134 static const double kDomainCookiesQuotaLow; 134 static const size_t kDomainCookiesQuotaHigh;
135 static const double kDomainCookiesQuotaMedium;
136 static const double kDomainCookiesQuotaHigh;
137 135
138 // 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
139 // 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
140 // 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
141 // 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
142 // updated. If |delegate| is non-NULL, it will be notified on 140 // updated. If |delegate| is non-NULL, it will be notified on
143 // creation/deletion of cookies. 141 // creation/deletion of cookies.
144 CookieMonster(PersistentCookieStore* store, CookieMonsterDelegate* delegate); 142 CookieMonster(PersistentCookieStore* store, CookieMonsterDelegate* delegate);
145 143
146 // Only used during unit testing. 144 // Only used during unit testing.
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
361 // directly before COOKIE_DELETE_EQUIVALENT_LAST_ENTRY and histograms.xml must 359 // directly before COOKIE_DELETE_EQUIVALENT_LAST_ENTRY and histograms.xml must
362 // be updated accordingly. 360 // be updated accordingly.
363 enum CookieDeleteEquivalent { 361 enum CookieDeleteEquivalent {
364 COOKIE_DELETE_EQUIVALENT_ATTEMPT = 0, 362 COOKIE_DELETE_EQUIVALENT_ATTEMPT = 0,
365 COOKIE_DELETE_EQUIVALENT_FOUND, 363 COOKIE_DELETE_EQUIVALENT_FOUND,
366 COOKIE_DELETE_EQUIVALENT_SKIPPING_SECURE, 364 COOKIE_DELETE_EQUIVALENT_SKIPPING_SECURE,
367 COOKIE_DELETE_EQUIVALENT_WOULD_HAVE_DELETED, 365 COOKIE_DELETE_EQUIVALENT_WOULD_HAVE_DELETED,
368 COOKIE_DELETE_EQUIVALENT_LAST_ENTRY 366 COOKIE_DELETE_EQUIVALENT_LAST_ENTRY
369 }; 367 };
370 368
371 enum GCType { GC_NONSECURE, GC_SECURE };
372
373 // The strategy for fetching cookies. Controlled by Finch experiment. 369 // The strategy for fetching cookies. Controlled by Finch experiment.
374 enum FetchStrategy { 370 enum FetchStrategy {
375 // Fetches all cookies only when they're needed. 371 // Fetches all cookies only when they're needed.
376 kFetchWhenNecessary = 0, 372 kFetchWhenNecessary = 0,
377 // Fetches all cookies as soon as any cookie is needed. 373 // Fetches all cookies as soon as any cookie is needed.
378 // This is the default behavior. 374 // This is the default behavior.
379 kAlwaysFetch, 375 kAlwaysFetch,
380 // The fetch strategy is not yet determined. 376 // The fetch strategy is not yet determined.
381 kUnknownFetch, 377 kUnknownFetch,
382 }; 378 };
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 CookieItVector::iterator cookie_its_end); 573 CookieItVector::iterator cookie_its_end);
578 574
579 // Helper for GarbageCollect(). Deletes cookies in |cookie_its| from least to 575 // Helper for GarbageCollect(). Deletes cookies in |cookie_its| from least to
580 // most recently used, but only before |safe_date|. Also will stop deleting 576 // most recently used, but only before |safe_date|. Also will stop deleting
581 // when the number of remaining cookies hits |purge_goal|. 577 // when the number of remaining cookies hits |purge_goal|.
582 size_t GarbageCollectLeastRecentlyAccessed(const base::Time& current, 578 size_t GarbageCollectLeastRecentlyAccessed(const base::Time& current,
583 const base::Time& safe_date, 579 const base::Time& safe_date,
584 size_t purge_goal, 580 size_t purge_goal,
585 CookieItVector cookie_its); 581 CookieItVector cookie_its);
586 582
587 // Helper for GarbageCollect(). Deletes |purge_goal| cookies of type |type|
588 // from the ranges specified in |it_bdd|. Returns the number of cookies
589 // deleted.
590 //
591 // |it_bdd| is a bit of a complicated beast: it must be a 7-element array
592 // of 'CookieItVector::Iterator' objects that demarcate the boundaries of
593 // a list of cookies sorted first by secure/non-secure, and then by priority,
594 // low to high. That is, it ought to look something like:
595 //
596 // LLLLMMMMHHHHHLLLLMMMMHHHH
597 // ^ ^ ^ ^ ^ ^ ^
598 // 0 1 2 3 4 5 6
599 //
600 // TODO(mkwst): This is super-complicated. We should determine whether we
601 // can simplify our implementation of "priority".
602 size_t GarbageCollectNumFromRangeWithQuota(const base::Time& current,
603 const base::Time& safe_date,
604 size_t purge_goal,
605 CookieItVector::iterator* it_bdd,
606 GCType type);
607
608 // Find the key (for lookup in cookies_) based on the given domain. 583 // Find the key (for lookup in cookies_) based on the given domain.
609 // See comment on keys before the CookieMap typedef. 584 // See comment on keys before the CookieMap typedef.
610 std::string GetKey(const std::string& domain) const; 585 std::string GetKey(const std::string& domain) const;
611 586
612 bool HasCookieableScheme(const GURL& url); 587 bool HasCookieableScheme(const GURL& url);
613 588
614 // Statistics support 589 // Statistics support
615 590
616 // This function should be called repeatedly, and will record 591 // This function should be called repeatedly, and will record
617 // statistics if a sufficient time period has passed. 592 // statistics if a sufficient time period has passed.
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 virtual ~PersistentCookieStore() {} 780 virtual ~PersistentCookieStore() {}
806 781
807 private: 782 private:
808 friend class base::RefCountedThreadSafe<PersistentCookieStore>; 783 friend class base::RefCountedThreadSafe<PersistentCookieStore>;
809 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); 784 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore);
810 }; 785 };
811 786
812 } // namespace net 787 } // namespace net
813 788
814 #endif // NET_COOKIES_COOKIE_MONSTER_H_ 789 #endif // NET_COOKIES_COOKIE_MONSTER_H_
OLDNEW
« no previous file with comments | « no previous file | net/cookies/cookie_monster.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698