Index: net/cookies/cookie_monster.h |
diff --git a/net/cookies/cookie_monster.h b/net/cookies/cookie_monster.h |
index 73df0040b75a03b6904f22b13768ef1c8eafa145..ce57437cc23bcd2d8cc85d3db77ef47f2c631e7c 100644 |
--- a/net/cookies/cookie_monster.h |
+++ b/net/cookies/cookie_monster.h |
@@ -405,6 +405,17 @@ class NET_EXPORT CookieMonster : public CookieStore { |
DELETE_COOKIE_LAST_ENTRY |
}; |
+ // The strategy for fetching cookies. Controlled by Finch experiment. |
+ enum FetchStrategy { |
+ // Fetches all cookies only when they're needed. |
+ kFetchWhenNecessary = 0, |
+ // Fetches all cookies as soon as any cookie is needed. |
+ // This is the default behavior. |
+ kAlwaysFetch, |
+ // The fetch strategy is not yet determined. |
+ kUnknownFetch, |
+ }; |
+ |
// The number of days since last access that cookies will not be subject |
// to global garbage collection. |
static const int kSafeFromGlobalPurgeDays; |
@@ -464,24 +475,21 @@ class NET_EXPORT CookieMonster : public CookieStore { |
bool HasCookiesForETLDP1(const std::string& etldp1); |
- // Called by all non-static functions to ensure that the cookies store has |
- // been initialized. This is not done during creating so it doesn't block |
- // the window showing. |
+ // The first access to the cookie store initializes it. This method should be |
+ // called before any access to the cookie store. |
+ void MarkCookieStoreAsInitialized(); |
+ |
+ // Fetches all cookies if the backing store exists and they're not already |
+ // being fetched. |
// Note: this method should always be called with lock_ held. |
- void InitIfNecessary() { |
- if (!initialized_) { |
- if (store_.get()) { |
- InitStore(); |
- } else { |
- loaded_ = true; |
- } |
- initialized_ = true; |
- } |
- } |
- |
- // Initializes the backing store and reads existing cookies from it. |
- // Should only be called by InitIfNecessary(). |
- void InitStore(); |
+ void FetchAllCookiesIfNecessary(); |
+ |
+ // Fetches all cookies from the backing store. |
+ // Note: this method should always be called with lock_ held. |
+ void FetchAllCookies(); |
+ |
+ // Whether all cookies should be fetched as soon as any is requested. |
+ bool ShouldFetchAllCookiesWhenFetchingAnyCookie(); |
// Stores cookies loaded from the backing store and invokes any deferred |
// calls. |beginning_time| should be the moment PersistentCookieStore::Load |
@@ -657,13 +665,15 @@ class NET_EXPORT CookieMonster : public CookieStore { |
CookieMap cookies_; |
- // Indicates whether the cookie store has been initialized. This happens |
- // lazily in InitStoreIfNecessary(). |
+ // Indicates whether the cookie store has been initialized. |
bool initialized_; |
- // Indicates whether loading from the backend store is completed and |
- // calls may be immediately processed. |
- bool loaded_; |
+ // Indicates whether the cookie store has started fetching all cookies. |
+ bool started_fetching_all_cookies_; |
+ // Indicates whether the cookie store has finished fetching all cookies. |
+ bool finished_fetching_all_cookies_; |
+ // The strategy to use for fetching cookies. |
+ FetchStrategy fetch_strategy_; |
// List of domain keys that have been loaded from the DB. |
std::set<std::string> keys_loaded_; |