Commit f3435d9d authored by Kushagra Sinha's avatar Kushagra Sinha Committed by Commit Bot

Accept a callback in chromeos::AccountManager::InitializeInEphemeralMode

Allow clients to provide a callback in

for now.

chromeos: :AccountManager::InitializeInEphemeralMode. Used only in tests
Change-Id: Ib1da37327d9d3c87865957b3286c59d6d48ed8a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2421813
Commit-Queue: Kush Sinha <sinhak@chromium.org>
Reviewed-by: default avatarHidehiko Abe <hidehiko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#809984}
parent da311cd1
......@@ -171,12 +171,19 @@ void AccountManager::SetPrefService(PrefService* pref_service) {
void AccountManager::InitializeInEphemeralMode(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory) {
InitializeInEphemeralMode(url_loader_factory,
/* initialization_callback= */
base::DoNothing());
}
void AccountManager::InitializeInEphemeralMode(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
base::OnceClosure initialization_callback) {
Initialize(/* home_dir= */ base::FilePath(), url_loader_factory,
/* delay_network_call_runner= */
base::BindRepeating(
[](base::OnceClosure closure) { std::move(closure).Run(); }),
/* task_runner= */ nullptr, /* initialization_callback= */
base::DoNothing());
/* task_runner= */ nullptr, std::move(initialization_callback));
}
void AccountManager::Initialize(
......
......@@ -157,6 +157,12 @@ class COMPONENT_EXPORT(ACCOUNT_MANAGER) AccountManager {
void InitializeInEphemeralMode(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory);
// Same as above, except it allows clients to provide a callback which will be
// called after initialization.
void InitializeInEphemeralMode(
scoped_refptr<network::SharedURLLoaderFactory> url_loader_factory,
base::OnceClosure initialization_callback);
// Returns |true| if |AccountManager| has been fully initialized.
bool IsInitialized() const;
......
......@@ -171,6 +171,10 @@ class AccountManagerTest : public testing::Test {
return account_manager_.get();
}
scoped_refptr<network::SharedURLLoaderFactory> test_url_loader_factory() {
return test_url_loader_factory_.GetSafeWeakWrapper();
}
private:
void InitializeAccountManager(AccountManager* account_manager,
const base::FilePath& home_dir,
......@@ -385,6 +389,14 @@ TEST_F(AccountManagerTest, TestEphemeralMode) {
EXPECT_EQ(0UL, accounts.size());
}
TEST_F(AccountManagerTest, TestEphemeralModeInitializationCallback) {
base::RunLoop run_loop;
AccountManager account_manager;
account_manager.InitializeInEphemeralMode(test_url_loader_factory(),
run_loop.QuitClosure());
run_loop.Run();
}
TEST_F(AccountManagerTest, TestAccountEmailPersistence) {
account_manager()->UpsertAccount(kGaiaAccountKey, kRawUserEmail, kGaiaToken);
RunAllPendingTasks();
......
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