Chromium Code Reviews| Index: ios/net/cookies/cookie_store_ios.h |
| diff --git a/ios/net/cookies/cookie_store_ios.h b/ios/net/cookies/cookie_store_ios.h |
| index b58d14aaf3eec4638bd5849a10098c686423298d..1290847b82d388eac7af3bcaadfa5fffd512f333 100644 |
| --- a/ios/net/cookies/cookie_store_ios.h |
| +++ b/ios/net/cookies/cookie_store_ios.h |
| @@ -41,35 +41,26 @@ class CookieNotificationObserver { |
| // The CookieStoreIOS is an implementation of CookieStore relying on |
| // NSHTTPCookieStorage, ensuring that the cookies are consistent between the |
| -// network stack and NSHTTPCookieStorage. |
| -// CookieStoreIOS is not thread safe. |
| +// network stack and NSHTTPCookieStorage. CookieStoreIOS is not thread safe. |
| // |
| -// CookieStoreIOS can be created synchronized with the system cookie store (via |
| -// CreateCookieStore) or not (other constructors). If a CookieStoreIOS is not |
| -// synchronized with the system store, changes are written back to the backing |
| -// CookieStore. If a CookieStoreIOS is synchronized with the system store, |
| +// CookieStoreIOS is created synchronized with the system cookie store - |
| // changes are written directly to the system cookie store, then propagated to |
| // the backing store by OnSystemCookiesChanged, which is called by the system |
| // store once the change to the system store is written back. |
| +// For not synchronized CookieStore, please see CookieStoreIOSPersistent. |
| class CookieStoreIOS : public net::CookieStore, |
| public CookieNotificationObserver { |
| public: |
| - // Creates a CookieStoreIOS with a default value of |
| - // |NSHTTPCookieStorage sharedCookieStorage| as the system's cookie store. |
| - explicit CookieStoreIOS( |
| - net::CookieMonster::PersistentCookieStore* persistent_store); |
| - |
| - ~CookieStoreIOS() override; |
| - |
| - enum CookiePolicy { ALLOW, BLOCK }; |
| - |
| // Create an instance of CookieStoreIOS that is generated from the cookies |
|
Eugene But (OOO till 7-30)
2017/01/23 17:37:47
nit: s/Create/Creates
I realize that this is just
maksims (do not use this acc)
2017/01/24 10:23:46
Done.
|
| // stored in |cookie_storage|. The CookieStoreIOS uses the |cookie_storage| |
| // as its default backend and is initially synchronized with it. |
| // Apple does not persist the cookies' creation dates in NSHTTPCookieStorage, |
| // so callers should not expect these values to be populated. |
| - static std::unique_ptr<CookieStoreIOS> CreateCookieStore( |
|
Eugene But (OOO till 7-30)
2017/01/23 17:37:47
This will break compilation in close source Chrome
maksims (do not use this acc)
2017/01/24 10:23:46
Oh, that what you meant. I though If it could comp
|
| - NSHTTPCookieStorage* cookie_storage); |
| + explicit CookieStoreIOS(NSHTTPCookieStorage* cookie_storage); |
| + |
| + ~CookieStoreIOS() override; |
| + |
| + enum CookiePolicy { ALLOW, BLOCK }; |
| // Must be called when the state of |
| // |NSHTTPCookieStorage sharedHTTPCookieStorage| changes. |
| @@ -131,21 +122,37 @@ class CookieStoreIOS : public net::CookieStore, |
| bool IsEphemeral() override; |
| - private: |
| - CookieStoreIOS( |
| - net::CookieMonster::PersistentCookieStore* persistent_store, |
| - NSHTTPCookieStorage* system_store); |
| - |
| - // For tests. |
| - friend struct CookieStoreIOSTestTraits; |
| - |
| + protected: |
| enum SynchronizationState { |
| NOT_SYNCHRONIZED, // Uses CookieMonster as backend. |
| SYNCHRONIZED // Uses NSHTTPCookieStorage as backend. |
| }; |
| - // Cookie fliter for DeleteCookiesWithFilter(). |
| - // Takes a cookie and a creation time and returns true if the cookie must be |
| + CookieStoreIOS(SynchronizationState state, |
| + net::CookieMonster::PersistentCookieStore* persistent_store, |
| + NSHTTPCookieStorage* system_store); |
| + |
| + // These three functions are used for wrapping user-supplied callbacks given |
| + // to CookieStoreIOS mutator methods. Given a callback, they return a new |
| + // callback that invokes UpdateCachesFromCookieMonster() to schedule an |
| + // asynchronous synchronization of the cookie cache and then calls the |
| + // original callback. |
| + SetCookiesCallback WrapSetCallback(const SetCookiesCallback& callback); |
| + DeleteCallback WrapDeleteCallback(const DeleteCallback& callback); |
| + base::Closure WrapClosure(const base::Closure& callback); |
| + |
| + bool metrics_enabled() { return metrics_enabled_; } |
| + |
| + net::CookieMonster* cookie_monster() { return cookie_monster_.get(); } |
| + |
| + const base::ThreadChecker& thread_checker() { return thread_checker_; } |
| + |
| + private: |
| + // For tests. |
| + friend struct CookieStoreIOSTestTraits; |
| + |
| + // Cookie filter for DeleteCookiesWithFilter(). |
| + // Takes a cookie and a creation time and returns true the cookie must be |
| // deleted. |
| typedef base::Callback<bool(NSHTTPCookie*, base::Time)> CookieFilterFunction; |
| @@ -265,16 +272,6 @@ class CookieStoreIOS : public net::CookieStore, |
| // creation date. |
| net::CookieList CanonicalCookieListFromSystemCookies(NSArray* cookies); |
| - // These three functions are used for wrapping user-supplied callbacks given |
| - // to CookieStoreIOS mutator methods. Given a callback, they return a new |
| - // callback that invokes UpdateCachesFromCookieMonster() to schedule an |
| - // asynchronous synchronization of the cookie cache and then calls the |
| - // original callback. |
| - |
| - SetCookiesCallback WrapSetCallback(const SetCookiesCallback& callback); |
| - DeleteCallback WrapDeleteCallback(const DeleteCallback& callback); |
| - base::Closure WrapClosure(const base::Closure& callback); |
| - |
| // Cached values of system cookies. Only cookies which have an observer added |
| // with AddCallbackForCookie are kept in this cache. |
| std::unique_ptr<CookieCache> cookie_cache_; |