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 <sque@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/26291
Reviewed-by: Ben Chan <benchan@chromium.org>
diff --git a/crash_reporter/crash_reporter.cc b/crash_reporter/crash_reporter.cc
index 4fab0b7..e563b45 100644
--- a/crash_reporter/crash_reporter.cc
+++ b/crash_reporter/crash_reporter.cc
@@ -59,31 +59,23 @@
   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);