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

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

Issue 1052373003: Add Finch experiment to cookie monster. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
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 <deque> 10 #include <deque>
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 DELETE_COOKIE_EXPIRED_OVERWRITE, 398 DELETE_COOKIE_EXPIRED_OVERWRITE,
399 399
400 // Cookies are not allowed to contain control characters in the name or 400 // Cookies are not allowed to contain control characters in the name or
401 // value. However, we used to allow them, so we are now evicting any such 401 // value. However, we used to allow them, so we are now evicting any such
402 // cookies as we load them. See http://crbug.com/238041. 402 // cookies as we load them. See http://crbug.com/238041.
403 DELETE_COOKIE_CONTROL_CHAR, 403 DELETE_COOKIE_CONTROL_CHAR,
404 404
405 DELETE_COOKIE_LAST_ENTRY 405 DELETE_COOKIE_LAST_ENTRY
406 }; 406 };
407 407
408 // The strategy for fetching cookies. Controlled by Finch experiment.
409 enum FetchStrategy {
410 // Fetches all cookies only when they're needed.
411 kFetchWhenNecessary = 0,
412 // Fetches all cookies as soon as any cookie is needed.
413 // This is the default behavior.
414 kAlwaysFetch,
415 // The fetch strategy is not yet determined.
416 kUnknownFetch,
417 };
418
408 // The number of days since last access that cookies will not be subject 419 // The number of days since last access that cookies will not be subject
409 // to global garbage collection. 420 // to global garbage collection.
410 static const int kSafeFromGlobalPurgeDays; 421 static const int kSafeFromGlobalPurgeDays;
411 422
412 // Record statistics every kRecordStatisticsIntervalSeconds of uptime. 423 // Record statistics every kRecordStatisticsIntervalSeconds of uptime.
413 static const int kRecordStatisticsIntervalSeconds = 10 * 60; 424 static const int kRecordStatisticsIntervalSeconds = 10 * 60;
414 425
415 ~CookieMonster() override; 426 ~CookieMonster() override;
416 427
417 // The following are synchronous calls to which the asynchronous methods 428 // The following are synchronous calls to which the asynchronous methods
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
457 void DeleteCookie(const GURL& url, const std::string& cookie_name); 468 void DeleteCookie(const GURL& url, const std::string& cookie_name);
458 469
459 bool SetCookieWithCreationTime(const GURL& url, 470 bool SetCookieWithCreationTime(const GURL& url,
460 const std::string& cookie_line, 471 const std::string& cookie_line,
461 const base::Time& creation_time); 472 const base::Time& creation_time);
462 473
463 int DeleteSessionCookies(); 474 int DeleteSessionCookies();
464 475
465 bool HasCookiesForETLDP1(const std::string& etldp1); 476 bool HasCookiesForETLDP1(const std::string& etldp1);
466 477
467 // Called by all non-static functions to ensure that the cookies store has 478 // The first access to the cookie store initializes it. This method should be
468 // been initialized. This is not done during creating so it doesn't block 479 // called before any access to the cookie store.
469 // the window showing. 480 void MarkCookieStoreAsInitialized();
481
482 // Fetches all cookies if the backing store exists and they're not already
483 // being fetched.
470 // Note: this method should always be called with lock_ held. 484 // Note: this method should always be called with lock_ held.
471 void InitIfNecessary() { 485 void FetchAllCookiesIfNecessary();
472 if (!initialized_) {
473 if (store_.get()) {
474 InitStore();
475 } else {
476 loaded_ = true;
477 }
478 initialized_ = true;
479 }
480 }
481 486
482 // Initializes the backing store and reads existing cookies from it. 487 // Fetches all cookies from the backing store.
483 // Should only be called by InitIfNecessary(). 488 // Note: this method should always be called with lock_ held.
484 void InitStore(); 489 void FetchAllCookies();
490
491 // Whether all cookies should be fetched as soon as any is requested.
492 bool ShouldFetchAllCookiesWhenFetchingAnyCookie();
485 493
486 // Stores cookies loaded from the backing store and invokes any deferred 494 // Stores cookies loaded from the backing store and invokes any deferred
487 // calls. |beginning_time| should be the moment PersistentCookieStore::Load 495 // calls. |beginning_time| should be the moment PersistentCookieStore::Load
488 // was invoked and is used for reporting histogram_time_blocked_on_load_. 496 // was invoked and is used for reporting histogram_time_blocked_on_load_.
489 // See PersistentCookieStore::Load for details on the contents of cookies. 497 // See PersistentCookieStore::Load for details on the contents of cookies.
490 void OnLoaded(base::TimeTicks beginning_time, 498 void OnLoaded(base::TimeTicks beginning_time,
491 const std::vector<CanonicalCookie*>& cookies); 499 const std::vector<CanonicalCookie*>& cookies);
492 500
493 // Stores cookies loaded from the backing store and invokes the deferred 501 // Stores cookies loaded from the backing store and invokes the deferred
494 // task(s) pending loading of cookies associated with the domain key 502 // task(s) pending loading of cookies associated with the domain key
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 base::HistogramBase* histogram_domain_count_; 658 base::HistogramBase* histogram_domain_count_;
651 base::HistogramBase* histogram_etldp1_count_; 659 base::HistogramBase* histogram_etldp1_count_;
652 base::HistogramBase* histogram_domain_per_etldp1_count_; 660 base::HistogramBase* histogram_domain_per_etldp1_count_;
653 base::HistogramBase* histogram_number_duplicate_db_cookies_; 661 base::HistogramBase* histogram_number_duplicate_db_cookies_;
654 base::HistogramBase* histogram_cookie_deletion_cause_; 662 base::HistogramBase* histogram_cookie_deletion_cause_;
655 base::HistogramBase* histogram_time_mac_; 663 base::HistogramBase* histogram_time_mac_;
656 base::HistogramBase* histogram_time_blocked_on_load_; 664 base::HistogramBase* histogram_time_blocked_on_load_;
657 665
658 CookieMap cookies_; 666 CookieMap cookies_;
659 667
660 // Indicates whether the cookie store has been initialized. This happens 668 // Indicates whether the cookie store has been initialized.
661 // lazily in InitStoreIfNecessary().
662 bool initialized_; 669 bool initialized_;
663 670
664 // Indicates whether loading from the backend store is completed and 671 // Indicates whether the cookie store has started fetching all cookies.
665 // calls may be immediately processed. 672 bool started_fetching_all_cookies_;
666 bool loaded_; 673 // Indicates whether the cookie store has finished fetching all cookies.
674 bool finished_fetching_all_cookies_;
675 // The strategy to use for fetching cookies.
676 FetchStrategy fetch_strategy_;
667 677
668 // List of domain keys that have been loaded from the DB. 678 // List of domain keys that have been loaded from the DB.
669 std::set<std::string> keys_loaded_; 679 std::set<std::string> keys_loaded_;
670 680
671 // Map of domain keys to their associated task queues. These tasks are blocked 681 // Map of domain keys to their associated task queues. These tasks are blocked
672 // until all cookies for the associated domain key eTLD+1 are loaded from the 682 // until all cookies for the associated domain key eTLD+1 are loaded from the
673 // backend store. 683 // backend store.
674 std::map<std::string, std::deque<scoped_refptr<CookieMonsterTask>>> 684 std::map<std::string, std::deque<scoped_refptr<CookieMonsterTask>>>
675 tasks_pending_for_key_; 685 tasks_pending_for_key_;
676 686
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 virtual ~PersistentCookieStore() {} 811 virtual ~PersistentCookieStore() {}
802 812
803 private: 813 private:
804 friend class base::RefCountedThreadSafe<PersistentCookieStore>; 814 friend class base::RefCountedThreadSafe<PersistentCookieStore>;
805 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore); 815 DISALLOW_COPY_AND_ASSIGN(PersistentCookieStore);
806 }; 816 };
807 817
808 } // namespace net 818 } // namespace net
809 819
810 #endif // NET_COOKIES_COOKIE_MONSTER_H_ 820 #endif // NET_COOKIES_COOKIE_MONSTER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698