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

Unified Diff: components/ukm/ukm_service.cc

Issue 2657083003: Populate a basic SystemProfileProto in UKM. (Closed)
Patch Set: small fixes 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/ukm/ukm_service.h ('k') | components/ukm/ukm_service_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/ukm/ukm_service.cc
diff --git a/components/ukm/ukm_service.cc b/components/ukm/ukm_service.cc
index 823bff5fb368bbe1278aecd598f42adfab331284..08ae31ced0d3df64ce1ec6a4f29f6fb4a5cb1b6b 100644
--- a/components/ukm/ukm_service.cc
+++ b/components/ukm/ukm_service.cc
@@ -14,7 +14,9 @@
#include "base/metrics/histogram_macros.h"
#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
+#include "base/sys_info.h"
#include "base/time/time.h"
+#include "components/metrics/metrics_log.h"
#include "components/metrics/metrics_log_uploader.h"
#include "components/metrics/metrics_service_client.h"
#include "components/metrics/proto/ukm/report.pb.h"
@@ -94,6 +96,7 @@ UkmService::UkmService(PrefService* pref_service,
self_ptr_factory_(this) {
DCHECK(pref_service_);
DCHECK(client_);
+ DVLOG(1) << "UkmService::Constructor";
persisted_logs_.DeserializeLogs();
@@ -189,7 +192,8 @@ void UkmService::BuildAndStoreLog() {
DVLOG(1) << "UkmService::BuildAndStoreLog";
Report report;
report.set_client_id(client_id_);
- // TODO(holte): Populate system_profile.
+ PopulateSystemProfile(&report);
+ // TODO(rkaplow): Populate network information.
// TODO(oystein): Populate sources.
std::string serialized_log;
report.SerializeToString(&serialized_log);
@@ -247,4 +251,25 @@ void UkmService::OnLogUploadComplete(int response_code) {
scheduler_->UploadFinished(server_is_healthy, !persisted_logs_.empty());
}
+void UkmService::PopulateSystemProfile(Report* report) {
+ // Currently just store the most important system information.
+ metrics::SystemProfileProto* system_profile =
+ report->mutable_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());
+
+ metrics::SystemProfileProto::OS* os = system_profile->mutable_os();
+ os->set_name(base::SysInfo::OperatingSystemName());
+ os->set_version(base::SysInfo::OperatingSystemVersion());
+
+ 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());
+}
Alexei Svitkine (slow) 2017/01/27 17:32:25 Can we share code with UMA? I suggest we refactor
+
} // namespace ukm
« no previous file with comments | « components/ukm/ukm_service.h ('k') | components/ukm/ukm_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698