From 6f03549d97555810c8e190af3439b4e7c7bad10f Mon Sep 17 00:00:00 2001 From: Simon Que Date: Wed, 27 Jun 2012 17:28:14 -0700 Subject: [PATCH] Put send metrics code into common function SendEnumToUMA() and SendCrashToUMA() are being called from three functions in crash_reporter.cc. This patch puts the three calls plus a repeated TODO into one helper function that's called by the three existing functions. BUG=chromium-os:11163,chromium-os:30268 TEST=emerge crash-reporter Change-Id: I703d93e3a072faa0264a220a69df2203af100c57 Signed-off-by: Simon Que Reviewed-on: https://gerrit.chromium.org/gerrit/26291 Reviewed-by: Ben Chan --- crash_reporter/crash_reporter.cc | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/crash_reporter/crash_reporter.cc b/crash_reporter/crash_reporter.cc index 4fab0b7aa..e563b45ea 100644 --- a/crash_reporter/crash_reporter.cc +++ b/crash_reporter/crash_reporter.cc @@ -59,31 +59,23 @@ static bool TouchFile(const FilePath &file_path) { return file_util::WriteFile(file_path, "", 0) == 0; } -static void CountKernelCrash() { +static void SendCrashMetrics(CrashKinds type, const char* name) { // TODO(kmixter): We can remove this histogram as part of // crosbug.com/11163. - s_metrics_lib.SendEnumToUMA(std::string(kCrashCounterHistogram), - kCrashKindKernel, - kCrashKindMax); - s_metrics_lib.SendCrashToUMA("kernel"); + s_metrics_lib.SendEnumToUMA(kCrashCounterHistogram, type, kCrashKindMax); + s_metrics_lib.SendCrashToUMA(name); +} + +static void CountKernelCrash() { + SendCrashMetrics(kCrashKindKernel, "kernel"); } static void CountUncleanShutdown() { - // TODO(kmixter): We can remove this histogram as part of - // crosbug.com/11163. - s_metrics_lib.SendEnumToUMA(std::string(kCrashCounterHistogram), - kCrashKindUncleanShutdown, - kCrashKindMax); - s_metrics_lib.SendCrashToUMA("uncleanshutdown"); + SendCrashMetrics(kCrashKindUncleanShutdown, "uncleanshutdown"); } static void CountUserCrash() { - // TODO(kmixter): We can remove this histogram as part of - // crosbug.com/11163. - s_metrics_lib.SendEnumToUMA(std::string(kCrashCounterHistogram), - kCrashKindUser, - kCrashKindMax); - s_metrics_lib.SendCrashToUMA("user"); + SendCrashMetrics(kCrashKindUser, "user"); std::string command = StringPrintf( "/usr/bin/dbus-send --type=signal --system / \"%s\" &", kUserCrashSignal);