Nikunj Bhagat | 19b85930 | 2018-12-20 00:39:56 | [diff] [blame] | 1 | // Copyright 2018 The Chromium Authors. All rights reserved. |
| 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 | |
| 13 | CPUMetricsProvider::CPUMetricsProvider() {} |
| 14 | |
| 15 | CPUMetricsProvider::~CPUMetricsProvider() {} |
| 16 | |
| 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()); |
Nicolas Ouellet-payeur | 28420275 | 2019-06-27 14:49:06 | [diff] [blame] | 26 | cpu->set_is_hypervisor(cpu_info.is_running_in_vm()); |
Nikunj Bhagat | 19b85930 | 2018-12-20 00:39:56 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | } // namespace metrics |