Index: chrome/browser/component_updater/recovery_component_installer.cc |
diff --git a/chrome/browser/component_updater/recovery_component_installer.cc b/chrome/browser/component_updater/recovery_component_installer.cc |
index 240bce1008c05415aca55ed2f1919e664eaab7a7..8562146318f9fbdbfa4b948d6fae17139bb26baa 100644 |
--- a/chrome/browser/component_updater/recovery_component_installer.cc |
+++ b/chrome/browser/component_updater/recovery_component_installer.cc |
@@ -16,6 +16,7 @@ |
#include "base/json/json_file_value_serializer.h" |
#include "base/logging.h" |
#include "base/memory/scoped_ptr.h" |
+#include "base/metrics/histogram.h" |
#include "base/path_service.h" |
#include "base/prefs/pref_registry_simple.h" |
#include "base/prefs/pref_service.h" |
@@ -59,6 +60,20 @@ enum ChromeRecoveryExitCode { |
EXIT_CODE_ELEVATION_NEEDED = 2, |
}; |
+enum RecoveryComponentEvent { |
+ RCE_RUNNING_NON_ELEVATED = 0, |
+ RCE_ELEVATION_NEEDED = 1, |
+ RCE_FAILED = 2, |
+ RCE_SUCCEEDED = 3, |
+ RCE_SKIPPED = 4, |
+ RCE_RUNNING_ELEVATED = 5, |
+ RCE_ELEVATED_FAILED = 6, |
+ RCE_ELEVATED_SUCCEEDED = 7, |
+ RCE_ELEVATED_SKIPPED = 8, |
+ RCE_COMPONENT_DOWNLOAD_ERROR = 9, |
+ RCE_COUNT |
+}; |
+ |
#if !defined(OS_CHROMEOS) |
// Checks if elevated recovery simulation switch was present on the command |
// line. This is for testing purpose. |
@@ -66,7 +81,7 @@ bool SimulatingElevatedRecovery() { |
return base::CommandLine::ForCurrentProcess()->HasSwitch( |
switches::kSimulateElevatedRecovery); |
} |
-#endif |
+#endif // !defined(OS_CHROMEOS) |
#if defined(OS_WIN) |
scoped_ptr<base::DictionaryValue> ReadManifest(const base::FilePath& manifest) { |
@@ -80,6 +95,23 @@ scoped_ptr<base::DictionaryValue> ReadManifest(const base::FilePath& manifest) { |
return scoped_ptr<base::DictionaryValue>(); |
} |
+void WaitForElevatedInstallToComplete(base::Process process) { |
+ int installer_exit_code = 0; |
+ const base::TimeDelta kMaxWaitTime = base::TimeDelta::FromSeconds(600); |
+ if (process.WaitForExitWithTimeout(kMaxWaitTime, &installer_exit_code)) { |
+ if (installer_exit_code == EXIT_CODE_RECOVERY_SUCCEEDED) { |
+ UMA_HISTOGRAM_ENUMERATION("RecoveryComponent.Event", |
Alexei Svitkine (slow)
2015/01/12 23:18:08
Nit: Please make a helper function for this histog
robertshield
2015/01/14 04:04:31
Thanks, done.
|
+ RCE_ELEVATED_SUCCEEDED, RCE_COUNT); |
+ } else { |
+ UMA_HISTOGRAM_ENUMERATION("RecoveryComponent.Event", |
+ RCE_ELEVATED_SKIPPED, RCE_COUNT); |
+ } |
+ } else { |
+ UMA_HISTOGRAM_ENUMERATION("RecoveryComponent.Event", RCE_ELEVATED_FAILED, |
+ RCE_COUNT); |
+ } |
+} |
+ |
void DoElevatedInstallRecoveryComponent(const base::FilePath& path) { |
const base::FilePath main_file = path.Append(kRecoveryFileName); |
const base::FilePath manifest_file = |
@@ -108,9 +140,17 @@ void DoElevatedInstallRecoveryComponent(const base::FilePath& path) { |
cmdline.AppendSwitchASCII("version", version.GetString()); |
} |
+ UMA_HISTOGRAM_ENUMERATION("RecoveryComponent.Event", RCE_RUNNING_ELEVATED, |
+ RCE_COUNT); |
+ |
base::LaunchOptions options; |
options.start_hidden = true; |
- base::LaunchElevatedProcess(cmdline, options); |
+ base::Process process = base::LaunchElevatedProcess(cmdline, options); |
+ |
+ base::WorkerPool::PostTask( |
+ FROM_HERE, |
+ base::Bind(&WaitForElevatedInstallToComplete, base::Passed(&process)), |
+ true); |
} |
void ElevatedInstallRecoveryComponent(const base::FilePath& installer_path) { |
@@ -119,7 +159,7 @@ void ElevatedInstallRecoveryComponent(const base::FilePath& installer_path) { |
base::Bind(&DoElevatedInstallRecoveryComponent, installer_path), |
true); |
} |
-#endif |
+#endif // defined(OS_WIN) |
} // namespace |
@@ -194,6 +234,8 @@ RecoveryComponentInstaller::RecoveryComponentInstaller(const Version& version, |
} |
void RecoveryComponentInstaller::OnUpdateError(int error) { |
+ UMA_HISTOGRAM_ENUMERATION("RecoveryComponent.Event", |
+ RCE_COMPONENT_DOWNLOAD_ERROR, RCE_COUNT); |
NOTREACHED() << "Recovery component update error: " << error; |
} |
@@ -203,20 +245,35 @@ void WaitForInstallToComplete(base::Process process, |
PrefService* prefs) { |
int installer_exit_code = 0; |
const base::TimeDelta kMaxWaitTime = base::TimeDelta::FromSeconds(600); |
- if (process.WaitForExitWithTimeout(kMaxWaitTime, &installer_exit_code) && |
- installer_exit_code == EXIT_CODE_ELEVATION_NEEDED) { |
- BrowserThread::PostTask( |
- BrowserThread::UI, |
- FROM_HERE, |
- base::Bind(&SetPrefsForElevatedRecoveryInstall, |
- installer_folder, |
- prefs)); |
+ if (process.WaitForExitWithTimeout(kMaxWaitTime, &installer_exit_code)) { |
+ if (installer_exit_code == EXIT_CODE_ELEVATION_NEEDED) { |
+ UMA_HISTOGRAM_ENUMERATION("RecoveryComponent.Event", RCE_ELEVATION_NEEDED, |
+ RCE_COUNT); |
+ |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(&SetPrefsForElevatedRecoveryInstall, |
+ installer_folder, |
+ prefs)); |
+ } else if (installer_exit_code == EXIT_CODE_RECOVERY_SUCCEEDED) { |
+ UMA_HISTOGRAM_ENUMERATION("RecoveryComponent.Event", RCE_SUCCEEDED, |
+ RCE_COUNT); |
+ } else if (installer_exit_code == EXIT_CODE_RECOVERY_SKIPPED) { |
+ UMA_HISTOGRAM_ENUMERATION("RecoveryComponent.Event", RCE_SKIPPED, |
+ RCE_COUNT); |
+ } |
+ } else { |
+ UMA_HISTOGRAM_ENUMERATION("RecoveryComponent.Event", RCE_FAILED, RCE_COUNT); |
} |
} |
bool RecoveryComponentInstaller::RunInstallCommand( |
const base::CommandLine& cmdline, |
const base::FilePath& installer_folder) const { |
+ UMA_HISTOGRAM_ENUMERATION("RecoveryComponent.Event", RCE_RUNNING_NON_ELEVATED, |
+ RCE_COUNT); |
+ |
base::LaunchOptions options; |
options.start_hidden = true; |
base::Process process = base::LaunchProcess(cmdline, options); |
@@ -241,7 +298,7 @@ bool RecoveryComponentInstaller::RunInstallCommand( |
const base::FilePath&) const { |
return base::LaunchProcess(cmdline, base::LaunchOptions()).IsValid(); |
} |
-#endif |
+#endif // defined(OS_WIN) |
bool RecoveryComponentInstaller::Install(const base::DictionaryValue& manifest, |
const base::FilePath& unpack_path) { |
@@ -322,7 +379,7 @@ void RegisterRecoveryComponent(ComponentUpdateService* cus, |
FROM_HERE, |
base::Bind(&RecoveryRegisterHelper, cus, prefs), |
base::TimeDelta::FromSeconds(6)); |
-#endif |
+#endif // !defined(OS_CHROMEOS) |
} |
void RegisterPrefsForRecoveryComponent(PrefRegistrySimple* registry) { |
@@ -338,7 +395,7 @@ void AcceptedElevatedRecoveryInstall(PrefService* prefs) { |
#if defined(OS_WIN) |
ElevatedInstallRecoveryComponent( |
prefs->GetFilePath(prefs::kRecoveryComponentUnpackPath)); |
-#endif |
+#endif // OS_WIN |
prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false); |
} |