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

Unified Diff: components/metrics/metrics_log.cc

Issue 2657083003: Populate a basic SystemProfileProto in UKM. (Closed)
Patch Set: remove stale TODO Created 3 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 | « components/metrics/metrics_log.h ('k') | components/metrics/metrics_log_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/metrics/metrics_log.cc
diff --git a/components/metrics/metrics_log.cc b/components/metrics/metrics_log.cc
index 56701d561ab65f1cdadd108a841a342c28f4b963..0856f31f3b86314788faeb600d7abfd761146962 100644
--- a/components/metrics/metrics_log.cc
+++ b/components/metrics/metrics_log.cc
@@ -103,13 +103,7 @@ MetricsLog::MetricsLog(const std::string& client_id,
if (product != uma_proto_.product())
uma_proto_.set_product(product);
- SystemProfileProto* system_profile = uma_proto_.mutable_system_profile();
- system_profile->set_build_timestamp(GetBuildTime());
- system_profile->set_app_version(client_->GetVersionString());
- system_profile->set_channel(client_->GetChannel());
-#if defined(SYZYASAN)
- system_profile->set_is_asan_build(true);
-#endif
+ RecordCoreSystemProfile(client_, uma_proto_.mutable_system_profile());
}
MetricsLog::~MetricsLog() {
@@ -170,6 +164,35 @@ void MetricsLog::RecordUserAction(const std::string& key) {
user_action->set_time(GetCurrentTime());
}
+void MetricsLog::RecordCoreSystemProfile(MetricsServiceClient* client,
+ SystemProfileProto* system_profile) {
+ system_profile->set_build_timestamp(metrics::MetricsLog::GetBuildTime());
+ system_profile->set_app_version(client->GetVersionString());
+ system_profile->set_channel(client->GetChannel());
+ system_profile->set_application_locale(client->GetApplicationLocale());
+
+#if defined(SYZYASAN)
+ system_profile->set_is_asan_build(true);
+#endif
+
+ metrics::SystemProfileProto::Hardware* hardware =
+ system_profile->mutable_hardware();
+ hardware->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture());
+ hardware->set_system_ram_mb(base::SysInfo::AmountOfPhysicalMemoryMB());
+ hardware->set_hardware_class(base::SysInfo::HardwareModelName());
+#if defined(OS_WIN)
+ hardware->set_dll_base(reinterpret_cast<uint64_t>(CURRENT_MODULE()));
+#endif
+
+ metrics::SystemProfileProto::OS* os = system_profile->mutable_os();
+ os->set_name(base::SysInfo::OperatingSystemName());
+ os->set_version(base::SysInfo::OperatingSystemVersion());
+#if defined(OS_ANDROID)
+ os->set_fingerprint(
+ base::android::BuildInfo::GetInstance()->android_build_fp());
+#endif
+}
+
void MetricsLog::RecordHistogramDelta(const std::string& histogram_name,
const base::HistogramSamples& snapshot) {
DCHECK(!closed_);
@@ -375,32 +398,9 @@ std::string MetricsLog::RecordEnvironment(
// Reduce granularity of the install_date field to nearest hour.
system_profile->set_install_date(RoundSecondsToHour(install_date));
- system_profile->set_application_locale(client_->GetApplicationLocale());
-
- SystemProfileProto::Hardware* hardware = system_profile->mutable_hardware();
-
- // HardwareModelName() will return an empty string on platforms where it's
- // not implemented or if an error occured.
- hardware->set_hardware_class(base::SysInfo::HardwareModelName());
-
- hardware->set_cpu_architecture(base::SysInfo::OperatingSystemArchitecture());
- hardware->set_system_ram_mb(base::SysInfo::AmountOfPhysicalMemoryMB());
-#if defined(OS_WIN)
- hardware->set_dll_base(reinterpret_cast<uint64_t>(CURRENT_MODULE()));
-#endif
-
- SystemProfileProto::OS* os = system_profile->mutable_os();
- std::string os_name = base::SysInfo::OperatingSystemName();
- os->set_name(os_name);
-
- os->set_version(base::SysInfo::OperatingSystemVersion());
-#if defined(OS_ANDROID)
- os->set_fingerprint(
- base::android::BuildInfo::GetInstance()->android_build_fp());
-#endif
-
+ SystemProfileProto::Hardware::CPU* cpu =
+ system_profile->mutable_hardware()->mutable_cpu();
base::CPU cpu_info;
- SystemProfileProto::Hardware::CPU* cpu = hardware->mutable_cpu();
cpu->set_vendor_name(cpu_info.vendor_name());
cpu->set_signature(cpu_info.signature());
cpu->set_num_cores(base::SysInfo::NumberOfProcessors());
« no previous file with comments | « components/metrics/metrics_log.h ('k') | components/metrics/metrics_log_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698