xref: /aosp_15_r20/external/cronet/components/metrics/cpu_metrics_provider.cc (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1 // Copyright 2018 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "components/metrics/cpu_metrics_provider.h"
6 
7 #include "base/cpu.h"
8 #include "base/system/sys_info.h"
9 #include "third_party/metrics_proto/system_profile.pb.h"
10 
11 namespace metrics {
12 
CPUMetricsProvider()13 CPUMetricsProvider::CPUMetricsProvider() {}
14 
~CPUMetricsProvider()15 CPUMetricsProvider::~CPUMetricsProvider() {}
16 
ProvideSystemProfileMetrics(SystemProfileProto * system_profile)17 void CPUMetricsProvider::ProvideSystemProfileMetrics(
18     SystemProfileProto* system_profile) {
19   SystemProfileProto::Hardware::CPU* cpu =
20       system_profile->mutable_hardware()->mutable_cpu();
21   // All the CPU information is generated in the constructor.
22   base::CPU cpu_info;
23   cpu->set_vendor_name(cpu_info.vendor_name());
24   cpu->set_signature(cpu_info.signature());
25   cpu->set_num_cores(base::SysInfo::NumberOfProcessors());
26   cpu->set_is_hypervisor(cpu_info.is_running_in_vm());
27 }
28 
29 }  // namespace metrics
30