Add install_date from prefs into UMA logs with 1 hour granularity.
Reduce granularity of uma_enabled_date to 1 hour.

BUG=254551

Review URL: https://chromiumcodereview.appspot.com/18503011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@211190 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/chrome/browser/metrics/metrics_log.cc b/chrome/browser/metrics/metrics_log.cc
index 7d19e6d..585eb93 100644
--- a/chrome/browser/metrics/metrics_log.cc
+++ b/chrome/browser/metrics/metrics_log.cc
@@ -347,6 +347,13 @@
 }
 #endif  // defined(OS_CHROMEOS)
 
+// Round a timestamp measured in seconds since epoch to one with a granularity
+// of an hour. This can be used before uploaded potentially sensitive
+// timestamps.
+int64 RoundSecondsToHour(int64 time_in_seconds) {
+  return 3600 * (time_in_seconds / 3600);
+}
+
 }  // namespace
 
 GoogleUpdateMetrics::GoogleUpdateMetrics() : is_system_install(false) {}
@@ -799,7 +806,14 @@
   bool success = base::StringToInt(GetMetricsEnabledDate(GetPrefService()),
                                    &enabled_date);
   DCHECK(success);
-  system_profile->set_uma_enabled_date(enabled_date);
+
+  // Reduce granularity of the enabled_date field to nearest hour.
+  system_profile->set_uma_enabled_date(RoundSecondsToHour(enabled_date));
+
+  int64 install_date = GetPrefService()->GetInt64(prefs::kInstallDate);
+
+  // Reduce granularity of the install_date field to nearest hour.
+  system_profile->set_install_date(RoundSecondsToHour(install_date));
 
   system_profile->set_application_locale(
       g_browser_process->GetApplicationLocale());