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_TEMP_READER_H_ | |
6 #define CHROMEOS_SYSTEM_CPU_TEMP_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 // Contains info from a CPU temperature sensor. | |
18 struct CPUTemperatureInfo { | |
stevenjb
2017/04/17 16:49:00
Make this a member of the class.
Simon Que
2017/04/17 17:07:48
Done.
| |
19 // The temperature read by a CPU temperature sensor in degrees Celsius. | |
20 double temp_celsius; | |
stevenjb
2017/04/17 16:49:00
blank line
Simon Que
2017/04/17 17:07:48
Done.
| |
21 // The name of the CPU temperature zone monitored by this sensor. Used to | |
22 // identify the source of each temperature reading. Taken from sysfs "name" | |
23 // or "label" field, if it exists. | |
24 std::string label; | |
25 | |
26 bool operator<(const CPUTemperatureInfo& other) const { | |
27 return std::make_pair(temp_celsius, label) < | |
28 std::make_pair(other.temp_celsius, label); | |
29 } | |
30 }; | |
31 | |
32 // Used to read CPU temperature info from sysfs hwmon. | |
33 class CPUTemperatureReader { | |
stevenjb
2017/04/17 16:49:00
File name should match the class name.
Simon Que
2017/04/17 17:07:48
Done.
| |
34 public: | |
35 CPUTemperatureReader(); | |
36 | |
37 // Read temperature from each thermal sensor of the CPU. Returns a vector | |
38 // containing a reading from each sensor. | |
39 // | |
40 // This is a blocking function that performs file operations. Users of this | |
41 // function can choose to call it from a task runner instead. | |
stevenjb
2017/04/17 16:49:00
Instead of what? Implemented this way, callers *mu
Simon Que
2017/04/17 17:07:48
Do you have an example of Chrome code that does no
stevenjb
2017/04/17 17:24:40
I'm not sure what you mean. There is no such thing
| |
42 std::vector<CPUTemperatureInfo> GetCPUTemperatures(); | |
43 | |
44 void set_hwmon_dir_for_test(const std::string& dir) { hwmon_dir_ = dir; } | |
45 | |
46 private: | |
47 // Sysfs hwmon directory path. Gets initialized to a default value but can be | |
48 // overriden by set_hwmon_dir_for_test(). | |
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_TEMP_READER_H_ | |
OLD | NEW |