Commit df7a59ad authored by Sylvain Defresne's avatar Sylvain Defresne Committed by Commit Bot

Convert OAuthTokenFetchedCallback to as OnceCallback<>

The callback is only invoked once, so change the type from
base::Callback (which is an alias for RepeatingCallback) to
base::OnceCallback.

Bug: none
Change-Id: I88459dc79073fe890645aae5457678172d1bfc53
Reviewed-on: https://chromium-review.googlesource.com/c/1344142Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Commit-Queue: Sylvain Defresne <sdefresne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#610430}
parent 4fef5eab
...@@ -103,8 +103,8 @@ OneClickSigninSyncStarter::OneClickSigninSyncStarter( ...@@ -103,8 +103,8 @@ OneClickSigninSyncStarter::OneClickSigninSyncStarter(
DCHECK(!refresh_token.empty()); DCHECK(!refresh_token.empty());
SigninManagerFactory::GetForProfile(profile_)->StartSignInWithRefreshToken( SigninManagerFactory::GetForProfile(profile_)->StartSignInWithRefreshToken(
refresh_token, gaia_id, email, password, refresh_token, gaia_id, email, password,
base::Bind(&OneClickSigninSyncStarter::ConfirmSignin, base::BindOnce(&OneClickSigninSyncStarter::ConfirmSignin,
weak_pointer_factory_.GetWeakPtr(), profile_mode)); weak_pointer_factory_.GetWeakPtr(), profile_mode));
} }
void OneClickSigninSyncStarter::OnBrowserRemoved(Browser* browser) { void OneClickSigninSyncStarter::OnBrowserRemoved(Browser* browser) {
......
...@@ -75,7 +75,7 @@ void FakeSigninManager::StartSignInWithRefreshToken( ...@@ -75,7 +75,7 @@ void FakeSigninManager::StartSignInWithRefreshToken(
const std::string& gaia_id, const std::string& gaia_id,
const std::string& username, const std::string& username,
const std::string& password, const std::string& password,
const OAuthTokenFetchedCallback& oauth_fetched_callback) { OAuthTokenFetchedCallback oauth_fetched_callback) {
set_auth_in_progress( set_auth_in_progress(
account_tracker_service()->SeedAccountInfo(gaia_id, username)); account_tracker_service()->SeedAccountInfo(gaia_id, username));
set_password(password); set_password(password);
...@@ -85,7 +85,7 @@ void FakeSigninManager::StartSignInWithRefreshToken( ...@@ -85,7 +85,7 @@ void FakeSigninManager::StartSignInWithRefreshToken(
possibly_invalid_email_.assign(username); possibly_invalid_email_.assign(username);
if (!oauth_fetched_callback.is_null()) if (!oauth_fetched_callback.is_null())
oauth_fetched_callback.Run(refresh_token); std::move(oauth_fetched_callback).Run(refresh_token);
} }
void FakeSigninManager::CompletePendingSignin() { void FakeSigninManager::CompletePendingSignin() {
......
...@@ -71,7 +71,7 @@ class FakeSigninManager : public SigninManager { ...@@ -71,7 +71,7 @@ class FakeSigninManager : public SigninManager {
const std::string& gaia_id, const std::string& gaia_id,
const std::string& username, const std::string& username,
const std::string& password, const std::string& password,
const OAuthTokenFetchedCallback& oauth_fetched_callback) override; OAuthTokenFetchedCallback oauth_fetched_callback) override;
void CompletePendingSignin() override; void CompletePendingSignin() override;
......
...@@ -100,7 +100,7 @@ void SigninManager::StartSignInWithRefreshToken( ...@@ -100,7 +100,7 @@ void SigninManager::StartSignInWithRefreshToken(
const std::string& gaia_id, const std::string& gaia_id,
const std::string& username, const std::string& username,
const std::string& password, const std::string& password,
const OAuthTokenFetchedCallback& callback) { OAuthTokenFetchedCallback callback) {
DCHECK(!IsAuthenticated()); DCHECK(!IsAuthenticated());
SigninType signin_type = refresh_token.empty() SigninType signin_type = refresh_token.empty()
? SIGNIN_TYPE_WITHOUT_REFRESH_TOKEN ? SIGNIN_TYPE_WITHOUT_REFRESH_TOKEN
...@@ -114,7 +114,7 @@ void SigninManager::StartSignInWithRefreshToken( ...@@ -114,7 +114,7 @@ void SigninManager::StartSignInWithRefreshToken(
if (!callback.is_null()) { if (!callback.is_null()) {
// Callback present, let the caller complete the pending sign-in. // Callback present, let the caller complete the pending sign-in.
callback.Run(temp_refresh_token_); std::move(callback).Run(temp_refresh_token_);
} else { } else {
// No callback, so just complete the pending signin. // No callback, so just complete the pending signin.
CompletePendingSignin(); CompletePendingSignin();
......
...@@ -64,7 +64,8 @@ class SigninManager : public SigninManagerBase, ...@@ -64,7 +64,8 @@ class SigninManager : public SigninManagerBase,
// but before the profile transitions to the "signed-in" state. This allows // but before the profile transitions to the "signed-in" state. This allows
// callers to load policy and prompt the user appropriately before completing // callers to load policy and prompt the user appropriately before completing
// signin. The callback is passed the just-fetched OAuth login refresh token. // signin. The callback is passed the just-fetched OAuth login refresh token.
typedef base::Callback<void(const std::string&)> OAuthTokenFetchedCallback; using OAuthTokenFetchedCallback =
base::OnceCallback<void(const std::string&)>;
// Used to remove accounts from the token service and the account tracker. // Used to remove accounts from the token service and the account tracker.
enum class RemoveAccountsOption { enum class RemoveAccountsOption {
...@@ -108,7 +109,7 @@ class SigninManager : public SigninManagerBase, ...@@ -108,7 +109,7 @@ class SigninManager : public SigninManagerBase,
const std::string& gaia_id, const std::string& gaia_id,
const std::string& username, const std::string& username,
const std::string& password, const std::string& password,
const OAuthTokenFetchedCallback& oauth_fetched_callback); OAuthTokenFetchedCallback oauth_fetched_callback);
// Copies auth credentials from one SigninManager to this one. This is used // Copies auth credentials from one SigninManager to this one. This is used
// when creating a new profile during the signin process to transfer the // when creating a new profile during the signin process to transfer the
......
...@@ -193,10 +193,10 @@ TEST_F(SigninManagerTest, SignInWithRefreshTokenCallbackComplete) { ...@@ -193,10 +193,10 @@ TEST_F(SigninManagerTest, SignInWithRefreshTokenCallbackComplete) {
EXPECT_FALSE(manager_->IsAuthenticated()); EXPECT_FALSE(manager_->IsAuthenticated());
// Since the password is empty, must verify the gaia cookies first. // Since the password is empty, must verify the gaia cookies first.
SigninManager::OAuthTokenFetchedCallback callback = base::Bind( manager_->StartSignInWithRefreshToken(
&SigninManagerTest::CompleteSigninCallback, base::Unretained(this)); "rt", "gaia_id", "user@gmail.com", "password",
manager_->StartSignInWithRefreshToken("rt", "gaia_id", "user@gmail.com", base::BindOnce(&SigninManagerTest::CompleteSigninCallback,
"password", callback); base::Unretained(this)));
ExpectSignInWithRefreshTokenSuccess(); ExpectSignInWithRefreshTokenSuccess();
ASSERT_EQ(1U, oauth_tokens_fetched_.size()); ASSERT_EQ(1U, oauth_tokens_fetched_.size());
......
...@@ -85,7 +85,7 @@ class PrimaryAccountMutator { ...@@ -85,7 +85,7 @@ class PrimaryAccountMutator {
const std::string& gaia_id, const std::string& gaia_id,
const std::string& username, const std::string& username,
const std::string& password, const std::string& password,
base::RepeatingCallback<void(const std::string&)> callback) = 0; base::OnceCallback<void(const std::string&)> callback) = 0;
// Complete the in-process sign-in (legacy, pre-DICE workflow). // Complete the in-process sign-in (legacy, pre-DICE workflow).
virtual void LegacyCompletePendingPrimaryAccountSignin() = 0; virtual void LegacyCompletePendingPrimaryAccountSignin() = 0;
......
...@@ -72,7 +72,7 @@ void PrimaryAccountMutatorImpl:: ...@@ -72,7 +72,7 @@ void PrimaryAccountMutatorImpl::
const std::string& gaia_id, const std::string& gaia_id,
const std::string& username, const std::string& username,
const std::string& password, const std::string& password,
base::RepeatingCallback<void(const std::string&)> callback) { base::OnceCallback<void(const std::string&)> callback) {
NOTIMPLEMENTED(); NOTIMPLEMENTED();
} }
......
...@@ -36,7 +36,7 @@ class PrimaryAccountMutatorImpl : public PrimaryAccountMutator { ...@@ -36,7 +36,7 @@ class PrimaryAccountMutatorImpl : public PrimaryAccountMutator {
const std::string& gaia_id, const std::string& gaia_id,
const std::string& username, const std::string& username,
const std::string& password, const std::string& password,
base::RepeatingCallback<void(const std::string&)> callback) override; base::OnceCallback<void(const std::string&)> callback) override;
void LegacyCompletePendingPrimaryAccountSignin() override; void LegacyCompletePendingPrimaryAccountSignin() override;
void LegacyMergeSigninCredentialIntoCookieJar() override; void LegacyMergeSigninCredentialIntoCookieJar() override;
bool LegacyIsPrimaryAccountAuthInProgress() const override; bool LegacyIsPrimaryAccountAuthInProgress() const override;
......
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