Commit 61881e05 authored by Jason Lin's avatar Jason Lin Committed by Commit Bot

Reland "Factor non-ui logic out of CrostiniInstallerView"

This is a reland of bbe68ab3

This reland resolves the following issues:

* CrostiniInstallerViewBrowserTest fails to pass MSAN
* CrostiniInstallerTest is flaky

Also note that the original description links to the wrong issue
crbug.com/912638 instead of crbug.com/929571.

Original change's description:
> Factor non-ui logic out of CrostiniInstallerView
>
> The current CrostiniInstallerView contains a lot of non-ui logic such as
> histogram recording and somewhat complex interaction with CrostiniManager. This
> CL factors out the non-ui logic into new class CrostiniInstaller. This not only
> makes the code cleaner, but also allows us to port the installer UI to WebUI
> much more easily.
>
>
> Bug: 912638
> Change-Id: Ie0195c8580518aa39e59aa539ef2fb614978776b
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1701024
> Reviewed-by: Ben Wells <benwells@chromium.org>
> Reviewed-by: Timothy Loh <timloh@chromium.org>
> Commit-Queue: Jason Lin <lxj@google.com>
> Cr-Commit-Position: refs/heads/master@{#688021}

Bug: 929571,995261,992298
Change-Id: I85809d7760ee99fa1100e303aadf04837db9666b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1760640Reviewed-by: default avatarTimothy Loh <timloh@chromium.org>
Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Commit-Queue: Jason Lin <lxj@google.com>
Cr-Commit-Position: refs/heads/master@{#689347}
parent 41763903
...@@ -3378,10 +3378,7 @@ ...@@ -3378,10 +3378,7 @@
<message name="IDS_CROSTINI_INSTALLER_ERROR_TITLE" desc="Title of the Crostini installer when an error occurs."> <message name="IDS_CROSTINI_INSTALLER_ERROR_TITLE" desc="Title of the Crostini installer when an error occurs.">
Error installing Linux... Error installing Linux...
</message> </message>
<message name="IDS_CROSTINI_INSTALLER_COMPLETE" desc="Text shown in the Crostini installer dialog when installation is complete."> <message name="IDS_CROSTINI_INSTALLER_LOAD_TERMINA_MESSAGE" desc="Text shown in the Crostini installer dialog when the VM component is loading">
Linux installation is complete.
</message>
<message name="IDS_CROSTINI_INSTALLER_LOAD_TERMINA_MESSAGE" desc="Text shown in the Crostini installer dialog when the VM component is loading">
This process may take a few minutes. Downloading the virtual machine. This process may take a few minutes. Downloading the virtual machine.
</message> </message>
<message name="IDS_CROSTINI_INSTALLER_START_CONCIERGE_MESSAGE" desc="Text shown in the Crostini installer dialog when the VM service is starting"> <message name="IDS_CROSTINI_INSTALLER_START_CONCIERGE_MESSAGE" desc="Text shown in the Crostini installer dialog when the VM service is starting">
......
...@@ -737,6 +737,9 @@ source_set("chromeos") { ...@@ -737,6 +737,9 @@ source_set("chromeos") {
"crostini/crostini_export_import.h", "crostini/crostini_export_import.h",
"crostini/crostini_export_import_notification.cc", "crostini/crostini_export_import_notification.cc",
"crostini/crostini_export_import_notification.h", "crostini/crostini_export_import_notification.h",
"crostini/crostini_installer.cc",
"crostini/crostini_installer.h",
"crostini/crostini_installer_ui_delegate.h",
"crostini/crostini_manager.cc", "crostini/crostini_manager.cc",
"crostini/crostini_manager.h", "crostini/crostini_manager.h",
"crostini/crostini_manager_factory.cc", "crostini/crostini_manager_factory.cc",
...@@ -771,6 +774,8 @@ source_set("chromeos") { ...@@ -771,6 +774,8 @@ source_set("chromeos") {
"crostini/crosvm_metrics.h", "crostini/crosvm_metrics.h",
"crostini/crosvm_process_list.cc", "crostini/crosvm_process_list.cc",
"crostini/crosvm_process_list.h", "crostini/crosvm_process_list.h",
"crostini/fake_crostini_installer_ui_delegate.cc",
"crostini/fake_crostini_installer_ui_delegate.h",
"cryptauth/client_app_metadata_provider_service.cc", "cryptauth/client_app_metadata_provider_service.cc",
"cryptauth/client_app_metadata_provider_service.h", "cryptauth/client_app_metadata_provider_service.h",
"cryptauth/client_app_metadata_provider_service_factory.cc", "cryptauth/client_app_metadata_provider_service_factory.cc",
...@@ -2438,6 +2443,7 @@ source_set("unit_tests") { ...@@ -2438,6 +2443,7 @@ source_set("unit_tests") {
"chrome_content_browser_client_chromeos_part_unittest.cc", "chrome_content_browser_client_chromeos_part_unittest.cc",
"crostini/crostini_ansible_management_service_unittest.cc", "crostini/crostini_ansible_management_service_unittest.cc",
"crostini/crostini_export_import_unittest.cc", "crostini/crostini_export_import_unittest.cc",
"crostini/crostini_installer_unittest.cc",
"crostini/crostini_manager_unittest.cc", "crostini/crostini_manager_unittest.cc",
"crostini/crostini_mime_types_service_unittest.cc", "crostini/crostini_mime_types_service_unittest.cc",
"crostini/crostini_package_notification_unittest.cc", "crostini/crostini_package_notification_unittest.cc",
......
This diff is collapsed.
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_CROSTINI_CROSTINI_INSTALLER_H_
#define CHROME_BROWSER_CHROMEOS_CROSTINI_CROSTINI_INSTALLER_H_
#include "base/callback_forward.h"
#include "base/macros.h"
#include "chrome/browser/chromeos/crostini/crostini_installer_ui_delegate.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "components/keyed_service/core/keyed_service.h"
class Profile;
namespace base {
class RepeatingTimer;
} // namespace base
namespace crostini {
class CrostiniInstaller : public KeyedService,
public CrostiniManager::RestartObserver,
public CrostiniInstallerUIDelegate {
public:
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
enum class SetupResult {
kNotStarted = 0,
// kUserCancelled = 1,
kSuccess = 2,
kErrorLoadingTermina = 3,
kErrorStartingConcierge = 4,
kErrorCreatingDiskImage = 5,
kErrorStartingTermina = 6,
kErrorStartingContainer = 7,
kErrorOffline = 8,
kErrorFetchingSshKeys = 9,
kErrorMountingContainer = 10,
kErrorSettingUpContainer = 11,
kUserCancelledStart = 12,
kUserCancelledInstallImageLoader = 13,
kUserCancelledStartConcierge = 14,
kUserCancelledCreateDiskImage = 15,
kUserCancelledStartTerminaVm = 16,
kUserCancelledCreateContainer = 17,
kUserCancelledStartContainer = 18,
kUserCancelledSetupContainer = 19,
kUserCancelledFetchSshKeys = 20,
kUserCancelledMountContainer = 21,
kErrorInsufficientDiskSpace = 22,
kMaxValue = kErrorInsufficientDiskSpace,
};
static CrostiniInstaller* GetForProfile(Profile* profile);
explicit CrostiniInstaller(Profile* profile);
~CrostiniInstaller() override;
void Shutdown() override;
// CrostiniInstallerUIDelegate:
void Install(ProgressCallback progress_callback,
ResultCallback result_callback) override;
void Cancel(base::OnceClosure callback) override;
void CancelBeforeStart() override;
// CrostiniManager::RestartObserver:
void OnComponentLoaded(crostini::CrostiniResult result) override;
void OnConciergeStarted(bool success) override;
void OnDiskImageCreated(bool success,
vm_tools::concierge::DiskImageStatus status,
int64_t disk_size_available) override;
void OnVmStarted(bool success) override;
void OnContainerDownloading(int32_t download_percent) override;
void OnContainerCreated(crostini::CrostiniResult result) override;
void OnContainerSetup(bool success) override;
void OnContainerStarted(crostini::CrostiniResult result) override;
void OnSshKeysFetched(bool success) override;
// Return true if internal state allows starting installation.
bool CanInstall();
void set_require_cleanup_for_testing(bool require_cleanup) {
require_cleanup_ = require_cleanup;
}
void set_skip_launching_terminal_for_testing() {
skip_launching_terminal_for_testing_ = true;
}
private:
enum class State {
IDLE,
INSTALLING,
ERROR, // Something unexpected happened.
CANCEL_CLEANUP, // Deleting a partial installation.
CANCEL_ABORT_CHECK_DISK, // Don't proceed after checking disk.
};
void RunProgressCallback();
void UpdateState(State new_state);
void UpdateInstallingState(InstallationState new_installing_state,
bool run_callback = true);
void HandleError(Error error);
void FinishCleanup(crostini::CrostiniResult result);
void RecordSetupResult(SetupResult result);
void OnCrostiniRestartFinished(crostini::CrostiniResult result);
void OnAvailableDiskSpace(int64_t bytes);
Profile* profile_;
State state_ = State::IDLE;
InstallationState installing_state_;
base::TimeTicks install_start_time_;
base::Time installing_state_start_time_;
base::RepeatingTimer state_progress_timer_;
bool require_cleanup_;
int64_t free_disk_space_;
int32_t container_download_percent_;
crostini::CrostiniManager::RestartId restart_id_ =
crostini::CrostiniManager::kUninitializedRestartId;
bool skip_launching_terminal_for_testing_ = false;
ProgressCallback progress_callback_;
ResultCallback result_callback_;
base::OnceClosure cancel_callback_;
base::WeakPtrFactory<CrostiniInstaller> weak_ptr_factory_{this};
DISALLOW_COPY_AND_ASSIGN(CrostiniInstaller);
};
} // namespace crostini
#endif // CHROME_BROWSER_CHROMEOS_CROSTINI_CROSTINI_INSTALLER_H_
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_CROSTINI_CROSTINI_INSTALLER_UI_DELEGATE_H_
#define CHROME_BROWSER_CHROMEOS_CROSTINI_CROSTINI_INSTALLER_UI_DELEGATE_H_
#include "base/callback_forward.h"
#include "base/strings/string16.h"
namespace crostini {
class CrostiniInstallerUIDelegate {
public:
// The size of the download for the VM image.
// TODO(timloh): This is just a placeholder.
static constexpr int64_t kDownloadSizeInBytes = 300 * 1024 * 1024;
// The minimum feasible size for a VM disk image.
static constexpr int64_t kMinimumDiskSize =
1ll * 1024 * 1024 * 1024; // 1 GiB
// Minimum amount of free disk space to install crostini successfully.
static constexpr int64_t kMinimumFreeDiskSpace =
crostini::CrostiniInstallerUIDelegate::kDownloadSizeInBytes +
kMinimumDiskSize;
enum class InstallationState {
START, // Just started installation
INSTALL_IMAGE_LOADER, // Loading the Termina VM component.
START_CONCIERGE, // Starting the Concierge D-Bus client.
CREATE_DISK_IMAGE, // Creating the image for the Termina VM.
START_TERMINA_VM, // Starting the Termina VM.
CREATE_CONTAINER, // Creating the container inside the Termina VM.
SETUP_CONTAINER, // Setting up the container inside the Termina VM.
START_CONTAINER, // Starting the container inside the Termina VM.
FETCH_SSH_KEYS, // Fetch ssh keys from concierge.
MOUNT_CONTAINER, // Do sshfs mount of container.
};
enum class Error {
NONE,
ERROR_LOADING_TERMINA,
ERROR_STARTING_CONCIERGE,
ERROR_CREATING_DISK_IMAGE,
ERROR_STARTING_TERMINA,
ERROR_STARTING_CONTAINER,
ERROR_OFFLINE,
ERROR_FETCHING_SSH_KEYS,
ERROR_MOUNTING_CONTAINER,
ERROR_SETTING_UP_CONTAINER,
ERROR_INSUFFICIENT_DISK_SPACE,
};
// |progress_fraction| ranges from 0.0 to 1.0.
using ProgressCallback =
base::RepeatingCallback<void(InstallationState state,
double progress_fraction)>;
using ResultCallback = base::OnceCallback<void(Error error)>;
// Start the installation. |progress_callback| will be called multiple times
// until |result_callback| is called. The crostini terminal will be launched
// when the installation succeeds.
virtual void Install(ProgressCallback progress_callback,
ResultCallback result_callback) = 0;
// Cancel the ongoing installation. |callback| will be called when it
// finishes. The callbacks passed to |Install()| will not be called anymore.
// A closing UI should call this if installation has started but hasn't
// finished.
virtual void Cancel(base::OnceClosure callback) = 0;
// UI should call this if the user cancels without starting installation so
// metrics can be recorded.
virtual void CancelBeforeStart() = 0;
};
} // namespace crostini
#endif // CHROME_BROWSER_CHROMEOS_CROSTINI_CROSTINI_INSTALLER_UI_DELEGATE_H_
...@@ -373,7 +373,9 @@ class CrostiniManager : public KeyedService, ...@@ -373,7 +373,9 @@ class CrostiniManager : public KeyedService,
using RestartId = int; using RestartId = int;
static const RestartId kUninitializedRestartId = -1; static const RestartId kUninitializedRestartId = -1;
// Runs all the steps required to restart the given crostini vm and container. // Runs all the steps required to restart the given crostini vm and container.
// The optional |observer| tracks progress. // The optional |observer| tracks progress. If provided, it must be alive
// until the restart completes (i.e. when |callback| is called) or the restart
// is aborted via |AbortRestartCrostini|.
RestartId RestartCrostini(std::string vm_name, RestartId RestartCrostini(std::string vm_name,
std::string container_name, std::string container_name,
CrostiniResultCallback callback, CrostiniResultCallback callback,
......
...@@ -36,7 +36,7 @@ CrostiniTestHelper::CrostiniTestHelper(TestingProfile* profile, ...@@ -36,7 +36,7 @@ CrostiniTestHelper::CrostiniTestHelper(TestingProfile* profile,
std::make_unique<chromeos::FakeChromeUserManager>()); std::make_unique<chromeos::FakeChromeUserManager>());
auto* fake_user_manager = static_cast<chromeos::FakeChromeUserManager*>( auto* fake_user_manager = static_cast<chromeos::FakeChromeUserManager*>(
user_manager::UserManager::Get()); user_manager::UserManager::Get());
auto account = AccountId::FromUserEmail("test@example.com"); auto account = AccountId::FromUserEmailGaiaId("test@example.com", "12345");
fake_user_manager->AddUserWithAffiliationAndTypeAndProfile( fake_user_manager->AddUserWithAffiliationAndTypeAndProfile(
account, false, user_manager::USER_TYPE_REGULAR, profile); account, false, user_manager::USER_TYPE_REGULAR, profile);
fake_user_manager->LoginUser(account); fake_user_manager->LoginUser(account);
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/chromeos/crostini/fake_crostini_installer_ui_delegate.h"
namespace crostini {
FakeCrostiniInstallerUIDelegate::FakeCrostiniInstallerUIDelegate() = default;
FakeCrostiniInstallerUIDelegate::~FakeCrostiniInstallerUIDelegate() = default;
void FakeCrostiniInstallerUIDelegate::Install(
ProgressCallback progress_callback,
ResultCallback result_callback) {
progress_callback_ = std::move(progress_callback);
result_callback_ = std::move(result_callback);
}
void FakeCrostiniInstallerUIDelegate::Cancel(base::OnceClosure callback) {
cancel_callback_ = std::move(callback);
}
void FakeCrostiniInstallerUIDelegate::CancelBeforeStart() {
cancel_before_start_called_ = true;
}
} // namespace crostini
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CHROMEOS_CROSTINI_FAKE_CROSTINI_INSTALLER_UI_DELEGATE_H_
#define CHROME_BROWSER_CHROMEOS_CROSTINI_FAKE_CROSTINI_INSTALLER_UI_DELEGATE_H_
#include "base/callback.h"
#include "chrome/browser/chromeos/crostini/crostini_installer_ui_delegate.h"
namespace crostini {
class FakeCrostiniInstallerUIDelegate : public CrostiniInstallerUIDelegate {
public:
FakeCrostiniInstallerUIDelegate();
~FakeCrostiniInstallerUIDelegate();
void Install(ProgressCallback progress_callback,
ResultCallback result_callback) override;
void Cancel(base::OnceClosure callback) override;
void CancelBeforeStart() override;
ProgressCallback progress_callback_;
ResultCallback result_callback_;
base::OnceClosure cancel_callback_;
bool cancel_before_start_called_ = false;
};
} // namespace crostini
#endif // CHROME_BROWSER_CHROMEOS_CROSTINI_FAKE_CROSTINI_INSTALLER_UI_DELEGATE_H_
...@@ -44,6 +44,7 @@ ...@@ -44,6 +44,7 @@
#include "chrome/browser/chromeos/arc/arc_util.h" #include "chrome/browser/chromeos/arc/arc_util.h"
#include "chrome/browser/chromeos/assistant/assistant_util.h" #include "chrome/browser/chromeos/assistant/assistant_util.h"
#include "chrome/browser/chromeos/crostini/crostini_export_import.h" #include "chrome/browser/chromeos/crostini/crostini_export_import.h"
#include "chrome/browser/chromeos/crostini/crostini_installer.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h" #include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/chromeos/crostini/crostini_pref_names.h" #include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
#include "chrome/browser/chromeos/crostini/crostini_registry_service.h" #include "chrome/browser/chromeos/crostini/crostini_registry_service.h"
...@@ -1185,7 +1186,8 @@ AutotestPrivateRunCrostiniInstallerFunction::Run() { ...@@ -1185,7 +1186,8 @@ AutotestPrivateRunCrostiniInstallerFunction::Run() {
// start terminal app on completion. After starting the installer, // start terminal app on completion. After starting the installer,
// we call RestartCrostini and we will be put in the pending restarters // we call RestartCrostini and we will be put in the pending restarters
// queue and be notified on success/otherwise of installation. // queue and be notified on success/otherwise of installation.
CrostiniInstallerView::Show(profile); CrostiniInstallerView::Show(
profile, crostini::CrostiniInstaller::GetForProfile(profile));
CrostiniInstallerView::GetActiveViewForTesting()->Accept(); CrostiniInstallerView::GetActiveViewForTesting()->Accept();
crostini::CrostiniManager::GetForProfile(profile)->RestartCrostini( crostini::CrostiniManager::GetForProfile(profile)->RestartCrostini(
crostini::kCrostiniDefaultVmName, crostini::kCrostiniDefaultContainerName, crostini::kCrostiniDefaultVmName, crostini::kCrostiniDefaultContainerName,
......
...@@ -7,10 +7,7 @@ ...@@ -7,10 +7,7 @@
#include "base/macros.h" #include "base/macros.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
#include "base/time/time.h" #include "chrome/browser/chromeos/crostini/crostini_installer_ui_delegate.h"
#include "base/timer/timer.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/component_updater/cros_component_installer_chromeos.h"
#include "ui/views/controls/link_listener.h" #include "ui/views/controls/link_listener.h"
#include "ui/views/window/dialog_delegate.h" #include "ui/views/window/dialog_delegate.h"
...@@ -21,54 +18,16 @@ class Link; ...@@ -21,54 +18,16 @@ class Link;
class ProgressBar; class ProgressBar;
} // namespace views } // namespace views
namespace crostini {
enum class CrostiniResult;
} // namespace crostini
class Profile; class Profile;
// The Crostini installer. Provides details about Crostini to the user and // The Crostini installer. Provides details about Crostini to the user and
// installs it if the user chooses to do so. // installs it if the user chooses to do so.
class CrostiniInstallerView class CrostiniInstallerView : public views::DialogDelegateView,
: public views::DialogDelegateView, public views::LinkListener {
public views::LinkListener,
public crostini::CrostiniManager::RestartObserver {
public: public:
// These values are persisted to logs. Entries should not be renumbered and static void Show(Profile* profile,
// numeric values should never be reused. crostini::CrostiniInstallerUIDelegate* delegate);
enum class SetupResult { static CrostiniInstallerView* GetActiveViewForTesting();
kNotStarted = 0,
// Deprecated, use the more specific cancelled values further down
kUserCancelled = 1,
kSuccess = 2,
kErrorLoadingTermina = 3,
kErrorStartingConcierge = 4,
kErrorCreatingDiskImage = 5,
kErrorStartingTermina = 6,
kErrorStartingContainer = 7,
kErrorOffline = 8,
kErrorFetchingSshKeys = 9,
kErrorMountingContainer = 10,
kErrorSettingUpContainer = 11,
kErrorInsufficientDiskSpace = 22,
kUserCancelledStart = 12,
kUserCancelledInstallImageLoader = 13,
kUserCancelledStartConcierge = 14,
kUserCancelledCreateDiskImage = 15,
kUserCancelledStartTerminaVm = 16,
kUserCancelledCreateContainer = 17,
kUserCancelledStartContainer = 18,
kUserCancelledSetupContainer = 19,
kUserCancelledFetchSshKeys = 20,
kUserCancelledMountContainer = 21,
kCount
};
static void Show(Profile* profile);
// views::DialogDelegateView: // views::DialogDelegateView:
int GetDialogButtons() const override; int GetDialogButtons() const override;
...@@ -83,94 +42,42 @@ class CrostiniInstallerView ...@@ -83,94 +42,42 @@ class CrostiniInstallerView
// views::LinkListener: // views::LinkListener:
void LinkClicked(views::Link* source, int event_flags) override; void LinkClicked(views::Link* source, int event_flags) override;
// crostini::CrostiniManager::RestartObserver
void OnComponentLoaded(crostini::CrostiniResult result) override;
void OnConciergeStarted(bool success) override;
void OnDiskImageCreated(bool success,
vm_tools::concierge::DiskImageStatus status,
int64_t disk_size_available) override;
void OnVmStarted(bool success) override;
void OnContainerDownloading(int32_t download_percent) override;
void OnContainerCreated(crostini::CrostiniResult result) override;
void OnContainerSetup(bool success) override;
void OnContainerStarted(crostini::CrostiniResult result) override;
void OnSshKeysFetched(bool success) override;
static CrostiniInstallerView* GetActiveViewForTesting();
void SetCloseCallbackForTesting(base::OnceClosure quit_closure);
void SetProgressBarCallbackForTesting(
base::RepeatingCallback<void(double)> callback);
void SetGetFreeDiskSpaceCallbackForTesting(base::OnceClosure quit_closure);
private: private:
using InstallationState =
crostini::CrostiniInstallerUIDelegate::InstallationState;
using Error = crostini::CrostiniInstallerUIDelegate::Error;
enum class State { enum class State {
PROMPT, // Prompting the user to allow installation. PROMPT,
ERROR, // Something unexpected happened. INSTALLING,
CLEANUP, // Deleting a partial installed SUCCESS,
CLEANUP_FINISHED, // Finished deleting partial install ERROR,
// We automatically progress through the following steps. CANCELING,
INSTALL_START, // The user has just clicked 'Install'. CANCELED,
INSTALL_IMAGE_LOADER, // Loading the Termina VM component.
START_CONCIERGE, // Starting the Concierge D-Bus client.
CREATE_DISK_IMAGE, // Creating the image for the Termina VM.
START_TERMINA_VM, // Starting the Termina VM.
CREATE_CONTAINER, // Creating the container inside the Termina VM.
START_CONTAINER, // Starting the container inside the Termina VM.
SETUP_CONTAINER, // Setting up the container inside the Termina VM.
FETCH_SSH_KEYS, // Fetch ssh keys from concierge.
MOUNT_CONTAINER, // Do sshfs mount of container.
SHOW_LOGIN_SHELL, // Showing a new crosh window.
INSTALL_END = SHOW_LOGIN_SHELL, // Marker enum for last install state.
}; };
explicit CrostiniInstallerView(Profile* profile); explicit CrostiniInstallerView(
Profile* profile,
crostini::CrostiniInstallerUIDelegate* delegate);
~CrostiniInstallerView() override; ~CrostiniInstallerView() override;
void FinishCleanup(crostini::CrostiniResult result); void OnProgressUpdate(InstallationState installing_state,
void HandleError(const base::string16& error_message, SetupResult result); double progress_fraction);
void MountContainerFinished(crostini::CrostiniResult result); void OnInstallFinished(Error error);
void ShowLoginShell(); void OnCanceled();
void StepProgress();
void UpdateState(State new_state);
void SetMessageLabel(); void SetMessageLabel();
void SetBigMessageLabel();
void RecordSetupResultHistogram(SetupResult result);
void OnAvailableDiskSpace(int64_t bytes);
void PressAccept();
State state_ = State::PROMPT; State state_ = State::PROMPT;
InstallationState installing_state_;
Profile* profile_;
crostini::CrostiniInstallerUIDelegate* delegate_;
views::ImageView* logo_image_ = nullptr; views::ImageView* logo_image_ = nullptr;
views::Label* big_message_label_ = nullptr; views::Label* big_message_label_ = nullptr;
views::Label* message_label_ = nullptr; views::Label* message_label_ = nullptr;
views::Link* learn_more_link_ = nullptr; views::Link* learn_more_link_ = nullptr;
views::ImageView* big_image_ = nullptr; views::ImageView* big_image_ = nullptr;
views::ProgressBar* progress_bar_ = nullptr; views::ProgressBar* progress_bar_ = nullptr;
Profile* profile_;
crostini::CrostiniManager::RestartId restart_id_ =
crostini::CrostiniManager::kUninitializedRestartId;
int32_t container_download_percent_ = 0;
base::Time state_start_time_;
std::unique_ptr<base::RepeatingTimer> state_progress_timer_;
bool do_cleanup_ = true;
base::TimeTicks install_start_time_;
int64_t free_disk_space_;
// Whether the result has been logged or not is stored to prevent multiple
// results being logged for a given setup flow. This can happen due to
// multiple error callbacks happening in some cases, as well as the user being
// able to hit Cancel after any errors occur.
bool has_logged_result_ = false;
bool has_logged_timing_result_ = false;
bool has_logged_free_disk_result_ = false;
base::RepeatingCallback<void(double)> progress_bar_callback_for_testing_;
base::OnceClosure quit_closure_for_testing_;
base::OnceClosure free_disk_space_callback_for_testing_;
base::WeakPtrFactory<CrostiniInstallerView> weak_ptr_factory_{this}; base::WeakPtrFactory<CrostiniInstallerView> weak_ptr_factory_{this};
......
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