Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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_SYSTEM_CPU_TEMPERATURE_READER_H_ | |
| 6 #define CHROMEOS_SYSTEM_CPU_TEMPERATURE_READER_H_ | |
| 7 | |
| 8 #include <string> | |
| 9 #include <utility> | |
| 10 #include <vector> | |
| 11 | |
| 12 #include "base/macros.h" | |
| 13 | |
| 14 namespace chromeos { | |
| 15 namespace system { | |
| 16 | |
| 17 // Used to read CPU temperature info from sysfs hwmon. | |
| 18 class CPUTemperatureReader { | |
| 19 public: | |
| 20 // Contains info from a CPU temperature sensor. | |
| 21 struct CPUTemperatureInfo { | |
|
Daniel Erat
2017/04/21 21:01:20
i think you need to declare a c'tor and d'tor here
Simon Que
2017/04/24 13:59:17
Done.
| |
| 22 // The temperature read by a CPU temperature sensor in degrees Celsius. | |
| 23 double temp_celsius; | |
| 24 | |
| 25 // The name of the CPU temperature zone monitored by this sensor. Used to | |
| 26 // identify the source of each temperature reading. Taken from sysfs "name" | |
| 27 // or "label" field, if it exists. | |
| 28 std::string label; | |
| 29 | |
| 30 bool operator<(const CPUTemperatureInfo& other) const { | |
|
Daniel Erat
2017/04/21 21:01:20
move this method above the members; also move the
Simon Que
2017/04/24 13:59:17
Done.
| |
| 31 return std::make_pair(temp_celsius, label) < | |
|
Daniel Erat
2017/04/21 21:01:20
sorting by temperature is a bit surprising. consid
Simon Que
2017/04/24 13:59:17
Done.
| |
| 32 std::make_pair(other.temp_celsius, label); | |
| 33 } | |
| 34 }; | |
| 35 | |
| 36 CPUTemperatureReader(); | |
| 37 | |
|
Daniel Erat
2017/04/21 21:01:20
nit: delete blank line here
Simon Que
2017/04/24 13:59:17
Done.
| |
| 38 ~CPUTemperatureReader(); | |
| 39 | |
| 40 void set_hwmon_dir_for_test(const std::string& dir) { hwmon_dir_ = dir; } | |
| 41 | |
| 42 // Read temperature from each thermal sensor of the CPU. Returns a vector | |
| 43 // containing a reading from each sensor to |callback|. This is a blocking | |
|
Daniel Erat
2017/04/21 21:01:20
fix comment; there's no callback now. also s/Read/
Simon Que
2017/04/24 13:59:17
Done.
| |
| 44 // function that should be run on a thread that allows blocking operations. | |
| 45 std::vector<CPUTemperatureInfo> GetCPUTemperatures(); | |
| 46 | |
| 47 private: | |
| 48 // Sysfs hwmon directory path. | |
| 49 std::string hwmon_dir_; | |
| 50 | |
| 51 DISALLOW_COPY_AND_ASSIGN(CPUTemperatureReader); | |
| 52 }; | |
| 53 | |
| 54 } // namespace system | |
| 55 } // namespace chromeos | |
| 56 | |
| 57 #endif // CHROMEOS_SYSTEM_CPU_TEMPERATURE_READER_H_ | |
| OLD | NEW |