Commit a1c6c1a6 authored by Kush Sinha's avatar Kush Sinha Committed by Commit Bot

Add an API to expose results of Account Manager migrations

Chrome OS Account Manager migrator currently does not expose the results
of its migration runs. Add a
|AccountManagerMigrator::GetLastMigrationRunResult|.

This will be used to retry migrations in ARC.

Bug: 998111
Change-Id: I528c9fe04d144d3c883aebc45f1cd30da1e52bdb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1773218Reviewed-by: default avatarAlexander Hendrich <hendrich@chromium.org>
Commit-Queue: Kush Sinha <sinhak@chromium.org>
Cr-Commit-Position: refs/heads/master@{#690780}
parent 15476cef
......@@ -567,6 +567,11 @@ AccountMigrationRunner::Status AccountManagerMigrator::GetStatus() const {
return migration_runner_.GetStatus();
}
base::Optional<AccountMigrationRunner::MigrationResult>
AccountManagerMigrator::GetLastMigrationRunResult() const {
return last_migration_run_result_;
}
void AccountManagerMigrator::OnMigrationRunComplete(
const AccountMigrationRunner::MigrationResult& result) {
DCHECK_NE(AccountMigrationRunner::Status::kNotStarted,
......@@ -574,6 +579,8 @@ void AccountManagerMigrator::OnMigrationRunComplete(
DCHECK_NE(AccountMigrationRunner::Status::kRunning,
migration_runner_.GetStatus());
last_migration_run_result_ = base::make_optional(result);
VLOG(1) << "Account migrations completed with result: "
<< static_cast<int>(result.final_status);
if (result.final_status == AccountMigrationRunner::Status::kFailure)
......
......@@ -7,6 +7,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "base/optional.h"
#include "chrome/browser/chromeos/account_manager/account_migration_runner.h"
#include "components/keyed_service/content/browser_context_keyed_service_factory.h"
#include "components/keyed_service/core/keyed_service.h"
......@@ -31,6 +32,11 @@ class AccountManagerMigrator : public KeyedService {
// Gets the current status of migration.
AccountMigrationRunner::Status GetStatus() const;
// Gets the result of the last migration run. If migrations have not been run
// before, the optional will be empty.
base::Optional<AccountMigrationRunner::MigrationResult>
GetLastMigrationRunResult() const;
private:
// Returns whether migrations should be run or skipped.
bool ShouldRunMigrations() const;
......@@ -55,6 +61,11 @@ class AccountManagerMigrator : public KeyedService {
// migration flow to be a no-op, in which case this will be |false|.
bool ran_migration_steps_ = false;
// Result of the last migration run. Empty if migrations have not been run
// before.
base::Optional<AccountMigrationRunner::MigrationResult>
last_migration_run_result_;
base::WeakPtrFactory<AccountManagerMigrator> weak_factory_{this};
DISALLOW_COPY_AND_ASSIGN(AccountManagerMigrator);
};
......
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