Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(880)

Unified Diff: chrome/browser/chromeos/policy/device_status_collector.cc

Issue 2115723003: Report all system temperatures, not just CPU (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 fdf71837622a40c30c5dd91fe7ad5fa26240213d..d24213879909f6c6a410e964ba5fa938fc0c7468 100644
--- a/chrome/browser/chromeos/policy/device_status_collector.cc
+++ b/chrome/browser/chromeos/policy/device_status_collector.cc
@@ -168,11 +168,12 @@ std::vector<em::CPUTempInfo> ReadCPUTempInfo() {
for (base::FilePath hwmon_path = hwmon_enumerator.Next(); !hwmon_path.empty();
hwmon_path = hwmon_enumerator.Next()) {
Polina Bondarenko 2016/07/01 15:22:26 s/devices/device
- // 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*/devices/
+ 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.
@@ -182,11 +183,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);
+ } else if (base::PathExists(base::FilePath(name_path))) {
+ base::ReadFileToString(name_path, &label);
+ } else {
label = std::string();
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698