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()13CPUMetricsProvider::CPUMetricsProvider() {} 14 ~CPUMetricsProvider()15CPUMetricsProvider::~CPUMetricsProvider() {} 16 ProvideSystemProfileMetrics(SystemProfileProto * system_profile)17void 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