Chromium Code Reviews| Index: components/signin/core/browser/gaia_cookie_manager_service.h |
| diff --git a/components/signin/core/browser/gaia_cookie_manager_service.h b/components/signin/core/browser/gaia_cookie_manager_service.h |
| index d11ea3da6d6b0f23c020df3cc70bdcf991ac6180..b3b7e6de7c72aa51d96e702d5aa2132a6dfdf4a0 100644 |
| --- a/components/signin/core/browser/gaia_cookie_manager_service.h |
| +++ b/components/signin/core/browser/gaia_cookie_manager_service.h |
| @@ -15,6 +15,7 @@ |
| #include "net/url_request/url_fetcher_delegate.h" |
| class GaiaAuthFetcher; |
| +class GaiaCookieRequest; |
|
Roger Tawa OOO till Jul 10th
2015/03/30 18:57:23
What is this forward declare for?
Mike Lerman
2015/04/01 16:39:35
For... no good reason.
|
| class GoogleServiceAuthError; |
| class OAuth2TokenService; |
| @@ -35,6 +36,48 @@ class GaiaCookieManagerService : public KeyedService, |
| public UbertokenConsumer, |
| public net::URLFetcherDelegate { |
| public: |
| + typedef base::Callback<void(const std::string& data, |
| + const GoogleServiceAuthError& error)> |
| + ListAccountsCallback; |
| + |
| + |
| + enum GaiaCookieRequestType { |
| + ADD_ACCOUNT, |
| + LOG_OUT, |
| + LIST_ACCOUNTS |
| + }; |
| + |
| + // Contains the information and parameters for any request. |
| + class GaiaCookieRequest { |
| + public: |
| + ~GaiaCookieRequest(); |
| + |
| + GaiaCookieRequestType request_type() const { return request_type_; } |
| + const std::string& account_id() const {return account_id_; } |
| + const GaiaCookieManagerService::ListAccountsCallback& |
| + list_accounts_callback() const { |
| + return list_accounts_callback_; |
| + } |
| + |
| + static GaiaCookieRequest AddAccountRequest( |
| + const std::string& account_id); |
| + static GaiaCookieRequest LogOutRequest(); |
| + static GaiaCookieRequest ListAccountsRequest( |
| + const GaiaCookieManagerService::ListAccountsCallback& |
| + list_accounts_callback); |
|
Roger Tawa OOO till Jul 10th
2015/03/30 18:57:23
Should these be called CreateXXX() ?
Mike Lerman
2015/04/01 16:39:35
Sure.
|
| + |
| + private: |
| + GaiaCookieRequest( |
| + GaiaCookieRequestType request_type, |
| + const std::string& account_id, |
| + const GaiaCookieManagerService::ListAccountsCallback& |
| + list_accounts_callback); |
| + |
| + GaiaCookieRequestType request_type_; |
| + std::string account_id_; |
| + GaiaCookieManagerService::ListAccountsCallback list_accounts_callback_; |
| + }; |
| + |
| class Observer { |
| public: |
| // Called whenever a merge session is completed. The account that was |
| @@ -123,6 +166,8 @@ class GaiaCookieManagerService : public KeyedService, |
| void AddAccountToCookie(const std::string& account_id); |
| + void ListAccounts(const ListAccountsCallback& callback); |
| + |
| // Add or remove observers of this helper. |
| void AddObserver(Observer* observer); |
| void RemoveObserver(Observer* observer); |
| @@ -130,13 +175,6 @@ class GaiaCookieManagerService : public KeyedService, |
| // Cancel all login requests. |
| void CancelAll(); |
| - // Signout of |account_id| given a list of accounts already signed in. |
| - // Since this involves signing out of all accounts and resigning back in, |
| - // the order which |accounts| are given is important as it will dictate |
| - // the sign in order. |account_id| does not have to be in |accounts|. |
| - void LogOut(const std::string& account_id, |
| - const std::vector<std::string>& accounts); |
| - |
| // Signout all accounts. |
| void LogOutAllAccounts(); |
| @@ -147,7 +185,7 @@ class GaiaCookieManagerService : public KeyedService, |
| const GoogleServiceAuthError& error); |
| // Returns true of there are pending log ins or outs. |
| - bool is_running() const { return accounts_.size() > 0; } |
| + bool is_running() const { return requests_.size() > 0; } |
| // Start the process of fetching the external check connection result so that |
| // its ready when we try to perform a merge session. |
| @@ -166,18 +204,15 @@ class GaiaCookieManagerService : public KeyedService, |
| void OnMergeSessionSuccess(const std::string& data) override; |
| void OnMergeSessionFailure(const GoogleServiceAuthError& error) override; |
| - void LogOutInternal(const std::string& account_id, |
| - const std::vector<std::string>& accounts); |
| - |
| // Starts the proess of fetching the uber token and performing a merge session |
| // for the next account. Virtual so that it can be overriden in tests. |
| - virtual void StartFetching(); |
| + virtual void StartFetchingUbertoken(); |
| // Virtual for testing purpose. |
| virtual void StartLogOutUrlFetch(); |
| - // Start the next merge session, if needed. |
| - void HandleNextAccount(); |
| + // Start the next request, if needed. |
| + void HandleNextRequest(); |
| // Overridden from URLFetcherDelgate. |
| void OnURLFetchComplete(const net::URLFetcher* source) override; |
| @@ -188,10 +223,10 @@ class GaiaCookieManagerService : public KeyedService, |
| scoped_ptr<UbertokenFetcher> uber_token_fetcher_; |
| ExternalCcResultFetcher external_cc_result_fetcher_; |
| - // A worklist for this class. Accounts names are stored here if |
| - // we are pending a signin action for that account. Empty strings |
| - // represent a signout request. |
| - std::deque<std::string> accounts_; |
| + // A worklist for this class. Stores any pending requests that couldn't be |
| + // executed right away, since this class only permits one request to be |
| + // executed at a time. |
| + std::deque<GaiaCookieRequest> requests_; |
| // List of observers to notify when merge session completes. |
| // Makes sure list is empty on destruction. |