1 // Copyright 2020 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 #ifndef CHROMEOS_COMPONENTS_DIAGNOSTICS_UI_BACKEND_CPU_USAGE_DATA_H_ 6 #define CHROMEOS_COMPONENTS_DIAGNOSTICS_UI_BACKEND_CPU_USAGE_DATA_H_ 7 8 #include <cstdint> 9 #include <limits> 10 11 namespace chromeos { 12 namespace diagnostics { 13 14 class CpuUsageData { 15 public: 16 CpuUsageData() = default; 17 CpuUsageData(uint64_t user_time, uint64_t system_time, uint64_t idle_time); 18 19 ~CpuUsageData() = default; 20 21 CpuUsageData(const CpuUsageData& other) = default; 22 CpuUsageData& operator=(const CpuUsageData& other) = default; 23 24 bool IsInitialized() const; 25 GetUserTime()26 uint64_t GetUserTime() const { return user_time_; } 27 GetSystemTime()28 uint64_t GetSystemTime() const { return system_time_; } 29 GetIdleTime()30 uint64_t GetIdleTime() const { return idle_time_; } 31 32 uint64_t GetTotalTime() const; 33 34 CpuUsageData operator+(const CpuUsageData& other) const; 35 CpuUsageData& operator+=(const CpuUsageData& other); 36 CpuUsageData operator-(const CpuUsageData& other) const; 37 CpuUsageData& operator-=(const CpuUsageData& other); 38 39 private: 40 uint64_t user_time_ = std::numeric_limits<uint64_t>::max(); 41 uint64_t system_time_ = std::numeric_limits<uint64_t>::max(); 42 uint64_t idle_time_ = std::numeric_limits<uint64_t>::max(); 43 }; 44 45 } // namespace diagnostics 46 } // namespace chromeos 47 48 #endif // CHROMEOS_COMPONENTS_DIAGNOSTICS_UI_BACKEND_CPU_USAGE_DATA_H_ 49