Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(815)

Unified Diff: chrome/browser/component_updater/recovery_component_installer.cc

Issue 846663003: Add UMA metrics to recovery component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Expand to include result codes. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c8a06d0ac16cc8cccd98a4f1c8a4c80771ae48c7 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)) {
xiaoling 2015/01/09 23:06:06 Does this block handle both of the following cases
+ UMA_HISTOGRAM_ENUMERATION("RecoveryComponent.Event", RCE_ELEVATED_FAILED,
+ RCE_COUNT);
+ } else {
+ if (installer_exit_code == EXIT_CODE_RECOVERY_SUCCEEDED) {
+ UMA_HISTOGRAM_ENUMERATION("RecoveryComponent.Event",
+ RCE_ELEVATED_SUCCEEDED, RCE_COUNT);
+ } else {
+ UMA_HISTOGRAM_ENUMERATION("RecoveryComponent.Event",
+ RCE_ELEVATED_SKIPPED, 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,33 @@ 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_ELEVATION_NEEDED,
gab 2015/01/09 22:41:22 Wrong event here and below?
robertshield 2015/01/09 22:45:32 Done.
+ RCE_COUNT);
+ } else if (installer_exit_code == EXIT_CODE_RECOVERY_SKIPPED) {
+ UMA_HISTOGRAM_ENUMERATION("RecoveryComponent.Event", RCE_ELEVATION_NEEDED,
+ 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 +296,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 +377,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 +393,7 @@ void AcceptedElevatedRecoveryInstall(PrefService* prefs) {
#if defined(OS_WIN)
ElevatedInstallRecoveryComponent(
prefs->GetFilePath(prefs::kRecoveryComponentUnpackPath));
-#endif
+#endif // OS_WIN
prefs->SetBoolean(prefs::kRecoveryComponentNeedsElevation, false);
}
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698