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

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

Issue 1762693002: Revert of Evict non-secure cookies less agressively. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
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 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // directly before COOKIE_DELETE_EQUIVALENT_LAST_ENTRY and histograms.xml must 368 // directly before COOKIE_DELETE_EQUIVALENT_LAST_ENTRY and histograms.xml must
371 // be updated accordingly. 369 // be updated accordingly.
372 enum CookieDeleteEquivalent { 370 enum CookieDeleteEquivalent {
373 COOKIE_DELETE_EQUIVALENT_ATTEMPT = 0, 371 COOKIE_DELETE_EQUIVALENT_ATTEMPT = 0,
374 COOKIE_DELETE_EQUIVALENT_FOUND, 372 COOKIE_DELETE_EQUIVALENT_FOUND,
375 COOKIE_DELETE_EQUIVALENT_SKIPPING_SECURE, 373 COOKIE_DELETE_EQUIVALENT_SKIPPING_SECURE,
376 COOKIE_DELETE_EQUIVALENT_WOULD_HAVE_DELETED, 374 COOKIE_DELETE_EQUIVALENT_WOULD_HAVE_DELETED,
377 COOKIE_DELETE_EQUIVALENT_LAST_ENTRY 375 COOKIE_DELETE_EQUIVALENT_LAST_ENTRY
378 }; 376 };
379 377
380 enum GCType { GC_NONSECURE, GC_SECURE };
381
382 // The strategy for fetching cookies. Controlled by Finch experiment. 378 // The strategy for fetching cookies. Controlled by Finch experiment.
383 enum FetchStrategy { 379 enum FetchStrategy {
384 // Fetches all cookies only when they're needed. 380 // Fetches all cookies only when they're needed.
385 kFetchWhenNecessary = 0, 381 kFetchWhenNecessary = 0,
386 // Fetches all cookies as soon as any cookie is needed. 382 // Fetches all cookies as soon as any cookie is needed.
387 // This is the default behavior. 383 // This is the default behavior.
388 kAlwaysFetch, 384 kAlwaysFetch,
389 // The fetch strategy is not yet determined. 385 // The fetch strategy is not yet determined.
390 kUnknownFetch, 386 kUnknownFetch,
391 }; 387 };
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 CookieItVector::iterator cookie_its_end); 584 CookieItVector::iterator cookie_its_end);
589 585
590 // Helper for GarbageCollect(). Deletes cookies in |cookie_its| from least to 586 // Helper for GarbageCollect(). Deletes cookies in |cookie_its| from least to
591 // most recently used, but only before |safe_date|. Also will stop deleting 587 // most recently used, but only before |safe_date|. Also will stop deleting
592 // when the number of remaining cookies hits |purge_goal|. 588 // when the number of remaining cookies hits |purge_goal|.
593 size_t GarbageCollectLeastRecentlyAccessed(const base::Time& current, 589 size_t GarbageCollectLeastRecentlyAccessed(const base::Time& current,
594 const base::Time& safe_date, 590 const base::Time& safe_date,
595 size_t purge_goal, 591 size_t purge_goal,
596 CookieItVector cookie_its); 592 CookieItVector cookie_its);
597 593
598 // Helper for GarbageCollect(). Deletes |purge_goal| cookies of type |type|
599 // from the ranges specified in |it_bdd|. Returns the number of cookies
600 // deleted.
601 //
602 // |it_bdd| is a bit of a complicated beast: it must be a 7-element array
603 // of 'CookieItVector::Iterator' objects that demarcate the boundaries of
604 // a list of cookies sorted first by secure/non-secure, and then by priority,
605 // low to high. That is, it ought to look something like:
606 //
607 // LLLLMMMMHHHHHLLLLMMMMHHHH
608 // ^ ^ ^ ^ ^ ^ ^
609 // 0 1 2 3 4 5 6
610 //
611 // TODO(mkwst): This is super-complicated. We should determine whether we
612 // can simplify our implementation of "priority".
613 size_t GarbageCollectNumFromRangeWithQuota(const base::Time& current,
614 const base::Time& safe_date,
615 size_t purge_goal,
616 CookieItVector::iterator* it_bdd,
617 GCType type);
618
619 // Find the key (for lookup in cookies_) based on the given domain. 594 // Find the key (for lookup in cookies_) based on the given domain.
620 // See comment on keys before the CookieMap typedef. 595 // See comment on keys before the CookieMap typedef.
621 std::string GetKey(const std::string& domain) const; 596 std::string GetKey(const std::string& domain) const;
622 597
623 bool HasCookieableScheme(const GURL& url); 598 bool HasCookieableScheme(const GURL& url);
624 599
625 // Statistics support 600 // Statistics support
626 601
627 // This function should be called repeatedly, and will record 602 // This function should be called repeatedly, and will record
628 // statistics if a sufficient time period has passed. 603 // statistics if a sufficient time period has passed.
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
816 virtual ~PersistentCookieStore() {} 791 virtual ~PersistentCookieStore() {}
817 792
818 private: 793 private:
819 friend class base::RefCountedThreadSafe<PersistentCookieStore>; 794 friend class base::RefCountedThreadSafe<PersistentCookieStore>;
820 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); 795 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore);
821 }; 796 };
822 797
823 } // namespace net 798 } // namespace net
824 799
825 #endif // NET_COOKIES_COOKIE_MONSTER_H_ 800 #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