Index: chrome/browser/chromeos/policy/device_status_collector.cc |
diff --git a/chrome/browser/chromeos/policy/device_status_collector.cc b/chrome/browser/chromeos/policy/device_status_collector.cc |
index d731df43bf15008572b7ec328779f816b498680e..b530f56f032a48b2e7d156e69c89652adc734a6a 100644 |
--- a/chrome/browser/chromeos/policy/device_status_collector.cc |
+++ b/chrome/browser/chromeos/policy/device_status_collector.cc |
@@ -171,11 +171,12 @@ std::vector<em::CPUTempInfo> ReadCPUTempInfo() { |
for (base::FilePath hwmon_path = hwmon_enumerator.Next(); !hwmon_path.empty(); |
hwmon_path = hwmon_enumerator.Next()) { |
- // Get files /sys/class/hwmon/hwmon*/device/temp*_input |
- const base::FilePath hwmon_device_dir = hwmon_path.Append(kDeviceDir); |
- base::FileEnumerator enumerator(hwmon_device_dir, false, |
- base::FileEnumerator::FILES, |
- kCPUTempFilePattern); |
+ // Get temp*_input files in hwmon*/ and hwmon*/device/ |
+ if (base::PathExists(hwmon_path.Append(kDeviceDir))) { |
+ hwmon_path = hwmon_path.Append(kDeviceDir); |
+ } |
+ base::FileEnumerator enumerator( |
+ hwmon_path, false, base::FileEnumerator::FILES, kCPUTempFilePattern); |
for (base::FilePath temperature_path = enumerator.Next(); |
!temperature_path.empty(); temperature_path = enumerator.Next()) { |
// Get appropriate temp*_label file. |
@@ -185,11 +186,16 @@ std::vector<em::CPUTempInfo> ReadCPUTempInfo() { |
continue; |
} |
base::ReplaceSubstringsAfterOffset(&label_path, 0, "input", "label"); |
+ base::FilePath name_path = hwmon_path.Append("name"); |
- // Read label. |
+ // Get the label describing this temperature. Use temp*_label |
+ // if present, fall back on name file or blank. |
std::string label; |
- if (!base::PathExists(base::FilePath(label_path)) || |
- !base::ReadFileToString(base::FilePath(label_path), &label)) { |
+ if (base::PathExists(base::FilePath(label_path))) { |
+ base::ReadFileToString(base::FilePath(label_path), &label); |
Andrew T Wilson (Slow)
2016/09/06 18:10:45
I'm concerned that if ReadFileToString() returns a
Jay Lee
2016/09/14 15:24:54
As far as I can see at:
https://chromium.googleso
|
+ } else if (base::PathExists(base::FilePath(name_path))) { |
+ base::ReadFileToString(name_path, &label); |
+ } else { |
label = std::string(); |
} |