Commit 59d97751 authored by Nicholas Verne's avatar Nicholas Verne Committed by Commit Bot

Show Download% in crostini installer.

Tremplin now sends a signal indication percent downloaded for a container.
This is bounced to the appropriate observers (in this case, the
CrostiniInstallerView). The install progress bar now indicates install
progress based on download percent and estimated time for each stage.

Bug: 860094
Change-Id: Iaa4dfe3464e30931d8ae1fce15a46f2d5ffbe7b5
Reviewed-on: https://chromium-review.googlesource.com/1201647Reviewed-by: default avatarTimothy Loh <timloh@chromium.org>
Commit-Queue: Nicholas Verne <nverne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#589439}
parent c0035ff3
...@@ -94,7 +94,7 @@ class CrostiniManager::CrostiniRestarter ...@@ -94,7 +94,7 @@ class CrostiniManager::CrostiniRestarter
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
if (is_aborted_) if (is_aborted_)
return; return;
is_running_ = true;
// Skip to the end immediately if testing. // Skip to the end immediately if testing.
if (crostini_manager_->skip_restart_for_testing()) { if (crostini_manager_->skip_restart_for_testing()) {
content::BrowserThread::PostTask( content::BrowserThread::PostTask(
...@@ -122,6 +122,16 @@ class CrostiniManager::CrostiniRestarter ...@@ -122,6 +122,16 @@ class CrostiniManager::CrostiniRestarter
observer_list_.Clear(); observer_list_.Clear();
} }
void OnContainerDownloading(int download_percent) {
if (!is_running_) {
return;
}
// Tell observers.
for (auto& observer : observer_list_) {
observer.OnContainerDownloading(download_percent);
}
}
CrostiniManager::RestartId restart_id() const { return restart_id_; } CrostiniManager::RestartId restart_id() const { return restart_id_; }
std::string vm_name() const { return vm_name_; } std::string vm_name() const { return vm_name_; }
std::string container_name() const { return container_name_; } std::string container_name() const { return container_name_; }
...@@ -218,7 +228,10 @@ class CrostiniManager::CrostiniRestarter ...@@ -218,7 +228,10 @@ class CrostiniManager::CrostiniRestarter
void CreateLxdContainerFinished(ConciergeClientResult result) { void CreateLxdContainerFinished(ConciergeClientResult result) {
DCHECK_CURRENTLY_ON(content::BrowserThread::UI); DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
// TODO(timloh): Does this need an observer callback? // Tell observers.
for (auto& observer : observer_list_) {
observer.OnContainerCreated(result);
}
if (is_aborted_) if (is_aborted_)
return; return;
if (result != ConciergeClientResult::SUCCESS) { if (result != ConciergeClientResult::SUCCESS) {
...@@ -360,6 +373,7 @@ class CrostiniManager::CrostiniRestarter ...@@ -360,6 +373,7 @@ class CrostiniManager::CrostiniRestarter
observer_list_; observer_list_;
CrostiniManager::RestartId restart_id_; CrostiniManager::RestartId restart_id_;
bool is_aborted_ = false; bool is_aborted_ = false;
bool is_running_ = false;
static CrostiniManager::RestartId next_restart_id_; static CrostiniManager::RestartId next_restart_id_;
}; };
...@@ -1368,7 +1382,17 @@ void CrostiniManager::OnLxdContainerCreated( ...@@ -1368,7 +1382,17 @@ void CrostiniManager::OnLxdContainerCreated(
} }
void CrostiniManager::OnLxdContainerDownloading( void CrostiniManager::OnLxdContainerDownloading(
const vm_tools::cicerone::LxdContainerDownloadingSignal& signal) {} const vm_tools::cicerone::LxdContainerDownloadingSignal& signal) {
if (owner_id_ != signal.owner_id()) {
return;
}
auto range = restarters_by_container_.equal_range(
std::make_pair(signal.vm_name(), signal.container_name()));
for (auto it = range.first; it != range.second; ++it) {
restarters_by_id_[it->second]->OnContainerDownloading(
signal.download_progress());
}
}
void CrostiniManager::OnTremplinStarted( void CrostiniManager::OnTremplinStarted(
const vm_tools::cicerone::TremplinStartedSignal& signal) { const vm_tools::cicerone::TremplinStartedSignal& signal) {
......
...@@ -146,6 +146,8 @@ class CrostiniManager : public KeyedService, ...@@ -146,6 +146,8 @@ class CrostiniManager : public KeyedService,
virtual void OnConciergeStarted(ConciergeClientResult result) = 0; virtual void OnConciergeStarted(ConciergeClientResult result) = 0;
virtual void OnDiskImageCreated(ConciergeClientResult result) = 0; virtual void OnDiskImageCreated(ConciergeClientResult result) = 0;
virtual void OnVmStarted(ConciergeClientResult result) = 0; virtual void OnVmStarted(ConciergeClientResult result) = 0;
virtual void OnContainerDownloading(int32_t download_percent) = 0;
virtual void OnContainerCreated(ConciergeClientResult result) = 0;
virtual void OnContainerStarted(ConciergeClientResult result) = 0; virtual void OnContainerStarted(ConciergeClientResult result) = 0;
virtual void OnSshKeysFetched(ConciergeClientResult result) = 0; virtual void OnSshKeysFetched(ConciergeClientResult result) = 0;
}; };
......
...@@ -368,6 +368,14 @@ class CrostiniManagerRestartTest : public CrostiniManagerTest, ...@@ -368,6 +368,14 @@ class CrostiniManagerRestartTest : public CrostiniManagerTest,
} }
} }
void OnContainerDownloading(int32_t download_percent) override {}
void OnContainerCreated(ConciergeClientResult result) override {
if (abort_on_container_created_) {
Abort();
}
}
void OnContainerStarted(ConciergeClientResult result) override { void OnContainerStarted(ConciergeClientResult result) override {
if (abort_on_container_started_) { if (abort_on_container_started_) {
Abort(); Abort();
...@@ -407,6 +415,7 @@ class CrostiniManagerRestartTest : public CrostiniManagerTest, ...@@ -407,6 +415,7 @@ class CrostiniManagerRestartTest : public CrostiniManagerTest,
bool abort_on_concierge_started_ = false; bool abort_on_concierge_started_ = false;
bool abort_on_disk_image_created_ = false; bool abort_on_disk_image_created_ = false;
bool abort_on_vm_started_ = false; bool abort_on_vm_started_ = false;
bool abort_on_container_created_ = false;
bool abort_on_container_started_ = false; bool abort_on_container_started_ = false;
bool abort_on_ssh_keys_fetched_ = false; bool abort_on_ssh_keys_fetched_ = false;
int restart_crostini_callback_count_ = 0; int restart_crostini_callback_count_ = 0;
...@@ -483,6 +492,21 @@ TEST_F(CrostiniManagerRestartTest, AbortOnVmStarted) { ...@@ -483,6 +492,21 @@ TEST_F(CrostiniManagerRestartTest, AbortOnVmStarted) {
EXPECT_EQ(0, restart_crostini_callback_count_); EXPECT_EQ(0, restart_crostini_callback_count_);
} }
TEST_F(CrostiniManagerRestartTest, AbortOnContainerCreated) {
abort_on_container_created_ = true;
// Use termina/penguin names to allow fetch ssh keys.
restart_id_ = crostini_manager()->RestartCrostini(
kCrostiniDefaultVmName, kCrostiniDefaultContainerName,
base::BindOnce(&CrostiniManagerRestartTest::RestartCrostiniCallback,
base::Unretained(this), run_loop()->QuitClosure()),
this);
run_loop()->Run();
EXPECT_TRUE(fake_concierge_client_->create_disk_image_called());
EXPECT_TRUE(fake_concierge_client_->start_termina_vm_called());
EXPECT_FALSE(fake_concierge_client_->get_container_ssh_keys_called());
EXPECT_EQ(0, restart_crostini_callback_count_);
}
TEST_F(CrostiniManagerRestartTest, AbortOnContainerStarted) { TEST_F(CrostiniManagerRestartTest, AbortOnContainerStarted) {
abort_on_container_started_ = true; abort_on_container_started_ = true;
// Use termina/penguin names to allow fetch ssh keys. // Use termina/penguin names to allow fetch ssh keys.
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
#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 "base/timer/timer.h"
#include "chrome/browser/chromeos/crostini/crostini_manager.h" #include "chrome/browser/chromeos/crostini/crostini_manager.h"
#include "chrome/browser/component_updater/cros_component_installer_chromeos.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"
...@@ -68,6 +70,8 @@ class CrostiniInstallerView ...@@ -68,6 +70,8 @@ class CrostiniInstallerView
void OnConciergeStarted(crostini::ConciergeClientResult result) override; void OnConciergeStarted(crostini::ConciergeClientResult result) override;
void OnDiskImageCreated(crostini::ConciergeClientResult result) override; void OnDiskImageCreated(crostini::ConciergeClientResult result) override;
void OnVmStarted(crostini::ConciergeClientResult result) override; void OnVmStarted(crostini::ConciergeClientResult result) override;
void OnContainerDownloading(int32_t download_percent) override;
void OnContainerCreated(crostini::ConciergeClientResult result) override;
void OnContainerStarted(crostini::ConciergeClientResult result) override; void OnContainerStarted(crostini::ConciergeClientResult result) override;
void OnSshKeysFetched(crostini::ConciergeClientResult result) override; void OnSshKeysFetched(crostini::ConciergeClientResult result) override;
...@@ -83,6 +87,7 @@ class CrostiniInstallerView ...@@ -83,6 +87,7 @@ class CrostiniInstallerView
START_CONCIERGE, // Starting the Concierge D-Bus client. START_CONCIERGE, // Starting the Concierge D-Bus client.
CREATE_DISK_IMAGE, // Creating the image for the Termina VM. CREATE_DISK_IMAGE, // Creating the image for the Termina VM.
START_TERMINA_VM, // Starting 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. START_CONTAINER, // Starting the container inside the Termina VM.
FETCH_SSH_KEYS, // Fetch ssh keys from concierge. FETCH_SSH_KEYS, // Fetch ssh keys from concierge.
MOUNT_CONTAINER, // Do sshfs mount of container. MOUNT_CONTAINER, // Do sshfs mount of container.
...@@ -97,6 +102,7 @@ class CrostiniInstallerView ...@@ -97,6 +102,7 @@ class CrostiniInstallerView
void MountContainerFinished(crostini::ConciergeClientResult result); void MountContainerFinished(crostini::ConciergeClientResult result);
void ShowLoginShell(); void ShowLoginShell();
void StepProgress(); void StepProgress();
void UpdateState(State new_state);
void SetMessageLabel(); void SetMessageLabel();
void SetBigMessageLabel(); void SetBigMessageLabel();
...@@ -112,6 +118,9 @@ class CrostiniInstallerView ...@@ -112,6 +118,9 @@ class CrostiniInstallerView
Profile* profile_; Profile* profile_;
crostini::CrostiniManager::RestartId restart_id_ = crostini::CrostiniManager::RestartId restart_id_ =
crostini::CrostiniManager::kUninitializedRestartId; crostini::CrostiniManager::kUninitializedRestartId;
int32_t container_download_percent_ = 0;
base::Time state_start_time_;
std::unique_ptr<base::RepeatingTimer> state_progress_timer_;
// Whether the result has been logged or not is stored to prevent multiple // 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 // results being logged for a given setup flow. This can happen due to
......
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