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,7 +103,7 @@ OneClickSigninSyncStarter::OneClickSigninSyncStarter(
DCHECK(!refresh_token.empty());
SigninManagerFactory::GetForProfile(profile_)->StartSignInWithRefreshToken(
refresh_token, gaia_id, email, password,
base::Bind(&OneClickSigninSyncStarter::ConfirmSignin,
base::BindOnce(&OneClickSigninSyncStarter::ConfirmSignin,
weak_pointer_factory_.GetWeakPtr(), profile_mode));
}
......
......@@ -75,7 +75,7 @@ void FakeSigninManager::StartSignInWithRefreshToken(
const std::string& gaia_id,
const std::string& username,
const std::string& password,
const OAuthTokenFetchedCallback& oauth_fetched_callback) {
OAuthTokenFetchedCallback oauth_fetched_callback) {
set_auth_in_progress(
account_tracker_service()->SeedAccountInfo(gaia_id, username));
set_password(password);
......@@ -85,7 +85,7 @@ void FakeSigninManager::StartSignInWithRefreshToken(
possibly_invalid_email_.assign(username);
if (!oauth_fetched_callback.is_null())
oauth_fetched_callback.Run(refresh_token);
std::move(oauth_fetched_callback).Run(refresh_token);
}
void FakeSigninManager::CompletePendingSignin() {
......
......@@ -71,7 +71,7 @@ class FakeSigninManager : public SigninManager {
const std::string& gaia_id,
const std::string& username,
const std::string& password,
const OAuthTokenFetchedCallback& oauth_fetched_callback) override;
OAuthTokenFetchedCallback oauth_fetched_callback) override;
void CompletePendingSignin() override;
......
......@@ -100,7 +100,7 @@ void SigninManager::StartSignInWithRefreshToken(
const std::string& gaia_id,
const std::string& username,
const std::string& password,
const OAuthTokenFetchedCallback& callback) {
OAuthTokenFetchedCallback callback) {
DCHECK(!IsAuthenticated());
SigninType signin_type = refresh_token.empty()
? SIGNIN_TYPE_WITHOUT_REFRESH_TOKEN
......@@ -114,7 +114,7 @@ void SigninManager::StartSignInWithRefreshToken(
if (!callback.is_null()) {
// Callback present, let the caller complete the pending sign-in.
callback.Run(temp_refresh_token_);
std::move(callback).Run(temp_refresh_token_);
} else {
// No callback, so just complete the pending signin.
CompletePendingSignin();
......
......@@ -64,7 +64,8 @@ class SigninManager : public SigninManagerBase,
// but before the profile transitions to the "signed-in" state. This allows
// callers to load policy and prompt the user appropriately before completing
// 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.
enum class RemoveAccountsOption {
......@@ -108,7 +109,7 @@ class SigninManager : public SigninManagerBase,
const std::string& gaia_id,
const std::string& username,
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
// when creating a new profile during the signin process to transfer the
......
......@@ -193,10 +193,10 @@ TEST_F(SigninManagerTest, SignInWithRefreshTokenCallbackComplete) {
EXPECT_FALSE(manager_->IsAuthenticated());
// Since the password is empty, must verify the gaia cookies first.
SigninManager::OAuthTokenFetchedCallback callback = base::Bind(
&SigninManagerTest::CompleteSigninCallback, base::Unretained(this));
manager_->StartSignInWithRefreshToken("rt", "gaia_id", "user@gmail.com",
"password", callback);
manager_->StartSignInWithRefreshToken(
"rt", "gaia_id", "user@gmail.com", "password",
base::BindOnce(&SigninManagerTest::CompleteSigninCallback,
base::Unretained(this)));
ExpectSignInWithRefreshTokenSuccess();
ASSERT_EQ(1U, oauth_tokens_fetched_.size());
......
......@@ -85,7 +85,7 @@ class PrimaryAccountMutator {
const std::string& gaia_id,
const std::string& username,
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).
virtual void LegacyCompletePendingPrimaryAccountSignin() = 0;
......
......@@ -72,7 +72,7 @@ void PrimaryAccountMutatorImpl::
const std::string& gaia_id,
const std::string& username,
const std::string& password,
base::RepeatingCallback<void(const std::string&)> callback) {
base::OnceCallback<void(const std::string&)> callback) {
NOTIMPLEMENTED();
}
......
......@@ -36,7 +36,7 @@ class PrimaryAccountMutatorImpl : public PrimaryAccountMutator {
const std::string& gaia_id,
const std::string& username,
const std::string& password,
base::RepeatingCallback<void(const std::string&)> callback) override;
base::OnceCallback<void(const std::string&)> callback) override;
void LegacyCompletePendingPrimaryAccountSignin() override;
void LegacyMergeSigninCredentialIntoCookieJar() 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