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

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

Issue 1705753002: Evict non-secure cookies less agressively. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compiling is fun. Created 4 years, 10 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 static const size_t kDomainCookiesQuotaLow; 132 // The quota is specified as a percentage of the total number of cookies we
133 static const size_t kDomainCookiesQuotaMedium; 133 // intend to retain for a domain.
134 static const size_t kDomainCookiesQuotaHigh; 134 static const double kDomainCookiesQuotaLow;
135 static const double kDomainCookiesQuotaMedium;
136 static const double kDomainCookiesQuotaHigh;
135 137
136 // The store passed in should not have had Init() called on it yet. This 138 // 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 139 // 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 140 // 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 141 // 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 142 // updated. If |delegate| is non-NULL, it will be notified on
141 // creation/deletion of cookies. 143 // creation/deletion of cookies.
142 CookieMonster(PersistentCookieStore* store, CookieMonsterDelegate* delegate); 144 CookieMonster(PersistentCookieStore* store, CookieMonsterDelegate* delegate);
143 145
144 // Only used during unit testing. 146 // Only used during unit testing.
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
368 // directly before COOKIE_DELETE_EQUIVALENT_LAST_ENTRY and histograms.xml must 370 // directly before COOKIE_DELETE_EQUIVALENT_LAST_ENTRY and histograms.xml must
369 // be updated accordingly. 371 // be updated accordingly.
370 enum CookieDeleteEquivalent { 372 enum CookieDeleteEquivalent {
371 COOKIE_DELETE_EQUIVALENT_ATTEMPT = 0, 373 COOKIE_DELETE_EQUIVALENT_ATTEMPT = 0,
372 COOKIE_DELETE_EQUIVALENT_FOUND, 374 COOKIE_DELETE_EQUIVALENT_FOUND,
373 COOKIE_DELETE_EQUIVALENT_SKIPPING_SECURE, 375 COOKIE_DELETE_EQUIVALENT_SKIPPING_SECURE,
374 COOKIE_DELETE_EQUIVALENT_WOULD_HAVE_DELETED, 376 COOKIE_DELETE_EQUIVALENT_WOULD_HAVE_DELETED,
375 COOKIE_DELETE_EQUIVALENT_LAST_ENTRY 377 COOKIE_DELETE_EQUIVALENT_LAST_ENTRY
376 }; 378 };
377 379
380 enum GCType { GC_NONSECURE, GC_SECURE };
381
378 // The strategy for fetching cookies. Controlled by Finch experiment. 382 // The strategy for fetching cookies. Controlled by Finch experiment.
379 enum FetchStrategy { 383 enum FetchStrategy {
380 // Fetches all cookies only when they're needed. 384 // Fetches all cookies only when they're needed.
381 kFetchWhenNecessary = 0, 385 kFetchWhenNecessary = 0,
382 // Fetches all cookies as soon as any cookie is needed. 386 // Fetches all cookies as soon as any cookie is needed.
383 // This is the default behavior. 387 // This is the default behavior.
384 kAlwaysFetch, 388 kAlwaysFetch,
385 // The fetch strategy is not yet determined. 389 // The fetch strategy is not yet determined.
386 kUnknownFetch, 390 kUnknownFetch,
387 }; 391 };
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
584 CookieItVector::iterator cookie_its_end); 588 CookieItVector::iterator cookie_its_end);
585 589
586 // Helper for GarbageCollect(). Deletes cookies in |cookie_its| from least to 590 // Helper for GarbageCollect(). Deletes cookies in |cookie_its| from least to
587 // most recently used, but only before |safe_date|. Also will stop deleting 591 // most recently used, but only before |safe_date|. Also will stop deleting
588 // when the number of remaining cookies hits |purge_goal|. 592 // when the number of remaining cookies hits |purge_goal|.
589 size_t GarbageCollectLeastRecentlyAccessed(const base::Time& current, 593 size_t GarbageCollectLeastRecentlyAccessed(const base::Time& current,
590 const base::Time& safe_date, 594 const base::Time& safe_date,
591 size_t purge_goal, 595 size_t purge_goal,
592 CookieItVector cookie_its); 596 CookieItVector cookie_its);
593 597
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
594 // Find the key (for lookup in cookies_) based on the given domain. 619 // Find the key (for lookup in cookies_) based on the given domain.
595 // See comment on keys before the CookieMap typedef. 620 // See comment on keys before the CookieMap typedef.
596 std::string GetKey(const std::string& domain) const; 621 std::string GetKey(const std::string& domain) const;
597 622
598 bool HasCookieableScheme(const GURL& url); 623 bool HasCookieableScheme(const GURL& url);
599 624
600 // Statistics support 625 // Statistics support
601 626
602 // This function should be called repeatedly, and will record 627 // This function should be called repeatedly, and will record
603 // statistics if a sufficient time period has passed. 628 // statistics if a sufficient time period has passed.
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
791 virtual ~PersistentCookieStore() {} 816 virtual ~PersistentCookieStore() {}
792 817
793 private: 818 private:
794 friend class base::RefCountedThreadSafe<PersistentCookieStore>; 819 friend class base::RefCountedThreadSafe<PersistentCookieStore>;
795 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); 820 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore);
796 }; 821 };
797 822
798 } // namespace net 823 } // namespace net
799 824
800 #endif // NET_COOKIES_COOKIE_MONSTER_H_ 825 #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