Commit c9f6f551 authored by mlerman's avatar mlerman Committed by Commit bot

GaiaCookieServiceManager handles general request types. This is a prerequisite...

GaiaCookieServiceManager handles general request types. This is a prerequisite to the GCMS being able to handle ListAccounts requests as part if its queue. Remove the unused single-account LogOut() method, and rework LogOutInternal() method.

Still to do, in future CLs:
- Make the GaiaCookieManagerService independently check for freshness of ExternalCCConnections before executing any MergeSession (every 3 hours?)
- Move all /ListAccounts calls into the GaiaCookieManagerService, and have it publish to all observers when that fails/succeeds
- Move all logic that listens to cookie changes into GCMS, publish a notification when change happens
- Rename the MergeSessionComplete method of the signin_tracker
- Add retry (and backoff) logic for AddAccount calls
- Remove CrOS's direct calls to gaia_auth_fetcher->StartMergeSession

BUG=466799

Review URL: https://codereview.chromium.org/1044933002

Cr-Commit-Position: refs/heads/master@{#324218}
parent d3f2f69a
...@@ -36,6 +36,48 @@ class GaiaCookieManagerService : public KeyedService, ...@@ -36,6 +36,48 @@ class GaiaCookieManagerService : public KeyedService,
public UbertokenConsumer, public UbertokenConsumer,
public net::URLFetcherDelegate { public net::URLFetcherDelegate {
public: 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 CreateAddAccountRequest(
const std::string& account_id);
static GaiaCookieRequest CreateLogOutRequest();
static GaiaCookieRequest CreateListAccountsRequest(
const GaiaCookieManagerService::ListAccountsCallback&
list_accounts_callback);
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 { class Observer {
public: public:
// Called whenever a merge session is completed. The account that was // Called whenever a merge session is completed. The account that was
...@@ -124,6 +166,8 @@ class GaiaCookieManagerService : public KeyedService, ...@@ -124,6 +166,8 @@ class GaiaCookieManagerService : public KeyedService,
void AddAccountToCookie(const std::string& account_id); void AddAccountToCookie(const std::string& account_id);
void ListAccounts(const ListAccountsCallback& callback);
// Add or remove observers of this helper. // Add or remove observers of this helper.
void AddObserver(Observer* observer); void AddObserver(Observer* observer);
void RemoveObserver(Observer* observer); void RemoveObserver(Observer* observer);
...@@ -131,13 +175,6 @@ class GaiaCookieManagerService : public KeyedService, ...@@ -131,13 +175,6 @@ class GaiaCookieManagerService : public KeyedService,
// Cancel all login requests. // Cancel all login requests.
void CancelAll(); 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. // Signout all accounts.
void LogOutAllAccounts(); void LogOutAllAccounts();
...@@ -148,7 +185,7 @@ class GaiaCookieManagerService : public KeyedService, ...@@ -148,7 +185,7 @@ class GaiaCookieManagerService : public KeyedService,
const GoogleServiceAuthError& error); const GoogleServiceAuthError& error);
// Returns true of there are pending log ins or outs. // 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 // Start the process of fetching the external check connection result so that
// its ready when we try to perform a merge session. // its ready when we try to perform a merge session.
...@@ -167,12 +204,9 @@ class GaiaCookieManagerService : public KeyedService, ...@@ -167,12 +204,9 @@ class GaiaCookieManagerService : public KeyedService,
void OnMergeSessionSuccess(const std::string& data) override; void OnMergeSessionSuccess(const std::string& data) override;
void OnMergeSessionFailure(const GoogleServiceAuthError& error) override; void OnMergeSessionFailure(const GoogleServiceAuthError& error) override;
void LogOutInternal(const std::string& account_id, // Starts the proess of fetching the uber token and performing a merge session
const std::vector<std::string>& accounts); // for the next account. Virtual so that it can be overriden in tests.
virtual void StartFetchingUbertoken();
// Starts the process of fetching the uber token and then performing a merge
// session for the next account. Virtual so that it can be overriden in tests.
virtual void StartFetching();
// Virtual for testing purposes. // Virtual for testing purposes.
virtual void StartFetchingMergeSession(); virtual void StartFetchingMergeSession();
...@@ -180,8 +214,8 @@ class GaiaCookieManagerService : public KeyedService, ...@@ -180,8 +214,8 @@ class GaiaCookieManagerService : public KeyedService,
// Virtual for testing purpose. // Virtual for testing purpose.
virtual void StartLogOutUrlFetch(); virtual void StartLogOutUrlFetch();
// Start the next merge session, if needed. // Start the next request, if needed.
void HandleNextAccount(); void HandleNextRequest();
// Overridden from URLFetcherDelgate. // Overridden from URLFetcherDelgate.
void OnURLFetchComplete(const net::URLFetcher* source) override; void OnURLFetchComplete(const net::URLFetcher* source) override;
...@@ -200,10 +234,10 @@ class GaiaCookieManagerService : public KeyedService, ...@@ -200,10 +234,10 @@ class GaiaCookieManagerService : public KeyedService,
// The last fetched ubertoken, for use in MergeSession retries. // The last fetched ubertoken, for use in MergeSession retries.
std::string uber_token_; std::string uber_token_;
// A worklist for this class. Accounts names are stored here if // A worklist for this class. Stores any pending requests that couldn't be
// we are pending a signin action for that account. Empty strings // executed right away, since this class only permits one request to be
// represent a signout request. // executed at a time.
std::deque<std::string> accounts_; std::deque<GaiaCookieRequest> requests_;
// List of observers to notify when merge session completes. // List of observers to notify when merge session completes.
// Makes sure list is empty on destruction. // Makes sure list is empty on destruction.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment