Commit ad250eb7 authored by David Munro's avatar David Munro Committed by Commit Bot

crostini: Record success/failure metrics for app launches.

Test: Manual
Bug: None
Change-Id: I14fbb5586dd2cef623f37c76f392a1719a775968
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2053668Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarBrian White <bcwhite@chromium.org>
Commit-Queue: David Munro <davidmunro@google.com>
Cr-Commit-Position: refs/heads/master@{#741211}
parent 620608e4
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
namespace { namespace {
constexpr char kCrostiniAppLaunchHistogram[] = "Crostini.AppLaunch"; constexpr char kCrostiniAppLaunchHistogram[] = "Crostini.AppLaunch";
constexpr char kCrostiniAppLaunchResultHistogram[] = "Crostini.AppLaunchResult";
constexpr char kCrostiniAppNamePrefix[] = "_crostini_"; constexpr char kCrostiniAppNamePrefix[] = "_crostini_";
constexpr int64_t kDelayBeforeSpinnerMs = 400; constexpr int64_t kDelayBeforeSpinnerMs = 400;
...@@ -76,13 +77,19 @@ void RecordAppLaunchHistogram(CrostiniAppLaunchAppType app_type) { ...@@ -76,13 +77,19 @@ void RecordAppLaunchHistogram(CrostiniAppLaunchAppType app_type) {
CrostiniAppLaunchAppType::kCount); CrostiniAppLaunchAppType::kCount);
} }
void OnLaunchFailed(const std::string& app_id) { void RecordAppLaunchResultHistogram(crostini::CrostiniResult reason) {
base::UmaHistogramEnumeration(kCrostiniAppLaunchResultHistogram, reason);
}
void OnLaunchFailed(const std::string& app_id,
crostini::CrostiniResult reason) {
// Remove the spinner so it doesn't stay around forever. // Remove the spinner so it doesn't stay around forever.
// TODO(timloh): Consider also displaying a notification of some sort. // TODO(timloh): Consider also displaying a notification of some sort.
ChromeLauncherController* chrome_controller = ChromeLauncherController* chrome_controller =
ChromeLauncherController::instance(); ChromeLauncherController::instance();
DCHECK(chrome_controller); DCHECK(chrome_controller);
chrome_controller->GetShelfSpinnerController()->CloseSpinner(app_id); chrome_controller->GetShelfSpinnerController()->CloseSpinner(app_id);
RecordAppLaunchResultHistogram(reason);
} }
void OnCrostiniRestarted(Profile* profile, void OnCrostiniRestarted(Profile* profile,
...@@ -97,7 +104,7 @@ void OnCrostiniRestarted(Profile* profile, ...@@ -97,7 +104,7 @@ void OnCrostiniRestarted(Profile* profile,
return; return;
} }
if (result != crostini::CrostiniResult::SUCCESS) { if (result != crostini::CrostiniResult::SUCCESS) {
OnLaunchFailed(app_id); OnLaunchFailed(app_id, result);
if (browser && browser->window()) if (browser && browser->window())
browser->window()->Close(); browser->window()->Close();
if (result == crostini::CrostiniResult::OFFLINE_WHEN_UPGRADE_REQUIRED || if (result == crostini::CrostiniResult::OFFLINE_WHEN_UPGRADE_REQUIRED ||
...@@ -113,8 +120,11 @@ void OnCrostiniRestarted(Profile* profile, ...@@ -113,8 +120,11 @@ void OnCrostiniRestarted(Profile* profile,
void OnApplicationLaunched(crostini::LaunchCrostiniAppCallback callback, void OnApplicationLaunched(crostini::LaunchCrostiniAppCallback callback,
const std::string& app_id, const std::string& app_id,
bool success) { bool success) {
if (!success) if (!success) {
OnLaunchFailed(app_id); OnLaunchFailed(app_id, crostini::CrostiniResult::UNKNOWN_ERROR);
} else {
RecordAppLaunchResultHistogram(crostini::CrostiniResult::SUCCESS);
}
std::move(callback).Run(success, success ? "" : "Failed to launch " + app_id); std::move(callback).Run(success, success ? "" : "Failed to launch " + app_id);
} }
...@@ -128,7 +138,7 @@ void OnSharePathForLaunchApplication( ...@@ -128,7 +138,7 @@ void OnSharePathForLaunchApplication(
bool success, bool success,
const std::string& failure_reason) { const std::string& failure_reason) {
if (!success) { if (!success) {
OnLaunchFailed(app_id); OnLaunchFailed(app_id, crostini::CrostiniResult::UNKNOWN_ERROR);
return std::move(callback).Run( return std::move(callback).Run(
success, success ? "" success, success ? ""
: "Failed to share paths to launch " + app_id + ":" + : "Failed to share paths to launch " + app_id + ":" +
...@@ -147,6 +157,7 @@ void LaunchTerminal(Profile* profile, ...@@ -147,6 +157,7 @@ void LaunchTerminal(Profile* profile,
crostini::LaunchCrostiniAppCallback callback) { crostini::LaunchCrostiniAppCallback callback) {
crostini::ShowContainerTerminal(profile, launch_params, vsh_in_crosh_url, crostini::ShowContainerTerminal(profile, launch_params, vsh_in_crosh_url,
browser); browser);
RecordAppLaunchResultHistogram(crostini::CrostiniResult::SUCCESS);
std::move(callback).Run(true, ""); std::move(callback).Run(true, "");
} }
...@@ -411,8 +422,13 @@ void LaunchCrostiniApp(Profile* profile, ...@@ -411,8 +422,13 @@ void LaunchCrostiniApp(Profile* profile,
profile, vm_name, container_name, std::vector<std::string>()); profile, vm_name, container_name, std::vector<std::string>());
if (base::FeatureList::IsEnabled(features::kTerminalSystemApp)) { if (base::FeatureList::IsEnabled(features::kTerminalSystemApp)) {
web_app::LaunchSystemWebApp(profile, web_app::SystemAppType::TERMINAL, auto* browser = web_app::LaunchSystemWebApp(
vsh_in_crosh_url); profile, web_app::SystemAppType::TERMINAL, vsh_in_crosh_url);
if (browser == nullptr) {
RecordAppLaunchResultHistogram(crostini::CrostiniResult::UNKNOWN_ERROR);
} else {
RecordAppLaunchResultHistogram(crostini::CrostiniResult::SUCCESS);
}
return; return;
} }
......
...@@ -29605,6 +29605,15 @@ uploading your change for review. ...@@ -29605,6 +29605,15 @@ uploading your change for review.
</summary> </summary>
</histogram> </histogram>
<histogram name="Crostini.AppLaunchResult" enum="CrostiniResult"
expires_after="2021-01-31">
<owner>clumptini@google.com</owner>
<owner>tbuckley@chromium.org</owner>
<summary>
The result of attempting to launch a Crostini app (including Terminal).
</summary>
</histogram>
<histogram name="Crostini.AppsInstalledAtLogin" units="apps" <histogram name="Crostini.AppsInstalledAtLogin" units="apps"
expires_after="2021-01-31"> expires_after="2021-01-31">
<owner>clumptini@google.com</owner> <owner>clumptini@google.com</owner>
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