| Index: chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
|
| diff --git a/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc b/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
|
| index 730276710f4a99c440af5c371687a4f4e74855fb..e864c38cc6277356c1e6ee588cca6b36a1adeda0 100644
|
| --- a/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
|
| +++ b/chrome/browser/ui/webui/chromeos/login/encryption_migration_screen_handler.cc
|
| @@ -7,6 +7,9 @@
|
| #include <string>
|
| #include <utility>
|
|
|
| +#include "base/files/file_path.h"
|
| +#include "base/sys_info.h"
|
| +#include "base/task_scheduler/post_task.h"
|
| #include "chrome/browser/lifetime/application_lifetime.h"
|
| #include "chromeos/cryptohome/homedir_methods.h"
|
| #include "chromeos/dbus/cryptohome_client.h"
|
| @@ -16,6 +19,12 @@ namespace {
|
|
|
| constexpr char kJsScreenPath[] = "login.EncryptionMigrationScreen";
|
|
|
| +// Path to the mount point to check the available space.
|
| +constexpr char kCheckStoragePath[] = "/home";
|
| +
|
| +// The minimum size of available space to start the migration.
|
| +constexpr int64_t kMinimumAvailableStorage = 10LL * 1024 * 1024; // 10MB
|
| +
|
| // JS API callbacks names.
|
| constexpr char kJsApiStartMigration[] = "startMigration";
|
| constexpr char kJsApiSkipMigration[] = "skipMigration";
|
| @@ -59,10 +68,7 @@ void EncryptionMigrationScreenHandler::SetUserContext(
|
| }
|
|
|
| void EncryptionMigrationScreenHandler::SetShouldResume(bool should_resume) {
|
| - if (current_ui_state_ == INITIAL && should_resume) {
|
| - // TODO(fukino): Wait until the battery gets enough level.
|
| - StartMigration();
|
| - }
|
| + should_resume_ = should_resume;
|
| }
|
|
|
| void EncryptionMigrationScreenHandler::SetContinueLoginCallback(
|
| @@ -70,6 +76,10 @@ void EncryptionMigrationScreenHandler::SetContinueLoginCallback(
|
| continue_login_callback_ = std::move(callback);
|
| }
|
|
|
| +void EncryptionMigrationScreenHandler::SetupInitialView() {
|
| + CheckAvailableStorage();
|
| +}
|
| +
|
| void EncryptionMigrationScreenHandler::DeclareLocalizedValues(
|
| ::login::LocalizedValuesBuilder* builder) {}
|
|
|
| @@ -93,7 +103,6 @@ void EncryptionMigrationScreenHandler::RegisterMessages() {
|
| }
|
|
|
| void EncryptionMigrationScreenHandler::HandleStartMigration() {
|
| - // TODO(fukino): Wait until the battery gets enough level.
|
| StartMigration();
|
| }
|
|
|
| @@ -124,6 +133,31 @@ void EncryptionMigrationScreenHandler::UpdateUIState(UIState state) {
|
| CallJS("setUIState", static_cast<int>(state));
|
| }
|
|
|
| +void EncryptionMigrationScreenHandler::CheckAvailableStorage() {
|
| + base::PostTaskWithTraitsAndReplyWithResult(
|
| + FROM_HERE,
|
| + base::TaskTraits().MayBlock().WithPriority(
|
| + base::TaskPriority::USER_VISIBLE),
|
| + base::Bind(&base::SysInfo::AmountOfFreeDiskSpace,
|
| + base::FilePath(kCheckStoragePath)),
|
| + base::Bind(&EncryptionMigrationScreenHandler::OnGetAvailableStorage,
|
| + weak_ptr_factory_.GetWeakPtr()));
|
| +}
|
| +
|
| +void EncryptionMigrationScreenHandler::OnGetAvailableStorage(int64_t size) {
|
| + if (size < kMinimumAvailableStorage) {
|
| + UpdateUIState(NOT_ENOUGH_STORAGE);
|
| + CallJS("setIsResuming", should_resume_);
|
| + } else {
|
| + if (should_resume_) {
|
| + // TODO(fukino): Check the battery level.
|
| + StartMigration();
|
| + } else {
|
| + UpdateUIState(READY);
|
| + }
|
| + }
|
| +}
|
| +
|
| void EncryptionMigrationScreenHandler::StartMigration() {
|
| DBusThreadManager::Get()
|
| ->GetCryptohomeClient()
|
|
|