Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/policy/device_status_collector.h" | 5 #include "chrome/browser/chromeos/policy/device_status_collector.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 101 return (out_time - Time::UnixEpoch()).InMilliseconds(); | 101 return (out_time - Time::UnixEpoch()).InMilliseconds(); |
| 102 } | 102 } |
| 103 | 103 |
| 104 // Helper function (invoked via blocking pool) to fetch information about | 104 // Helper function (invoked via blocking pool) to fetch information about |
| 105 // mounted disks. | 105 // mounted disks. |
| 106 std::vector<em::VolumeInfo> GetVolumeInfo( | 106 std::vector<em::VolumeInfo> GetVolumeInfo( |
| 107 const std::vector<std::string>& mount_points) { | 107 const std::vector<std::string>& mount_points) { |
| 108 std::vector<em::VolumeInfo> result; | 108 std::vector<em::VolumeInfo> result; |
| 109 for (const std::string& mount_point : mount_points) { | 109 for (const std::string& mount_point : mount_points) { |
| 110 base::FilePath mount_path(mount_point); | 110 base::FilePath mount_path(mount_point); |
| 111 | |
| 112 // Non-native file systems do not have a mount point in the local file | |
| 113 // system. However, it's worth checking here, as it's easier than checking | |
| 114 // earlier which mount point is local, and which one is not. | |
| 115 if (mount_point.empty() || !base::PathExists(mount_path)) | |
|
Wez
2016/12/15 19:27:57
nit: It'd be more readable to check mount_path.emp
| |
| 116 continue; | |
| 117 | |
| 111 int64_t free_size = base::SysInfo::AmountOfFreeDiskSpace(mount_path); | 118 int64_t free_size = base::SysInfo::AmountOfFreeDiskSpace(mount_path); |
| 112 int64_t total_size = base::SysInfo::AmountOfTotalDiskSpace(mount_path); | 119 int64_t total_size = base::SysInfo::AmountOfTotalDiskSpace(mount_path); |
| 113 if (free_size < 0 || total_size < 0) { | 120 if (free_size < 0 || total_size < 0) { |
| 114 LOG_IF(ERROR, !mount_point.empty()) << "Unable to get volume status for " | 121 LOG(ERROR) << "Unable to get volume status for " << mount_point; |
| 115 << mount_point; | |
| 116 continue; | 122 continue; |
| 117 } | 123 } |
| 118 em::VolumeInfo info; | 124 em::VolumeInfo info; |
| 119 info.set_volume_id(mount_point); | 125 info.set_volume_id(mount_point); |
| 120 info.set_storage_total(total_size); | 126 info.set_storage_total(total_size); |
| 121 info.set_storage_free(free_size); | 127 info.set_storage_free(free_size); |
| 122 result.push_back(info); | 128 result.push_back(info); |
| 123 } | 129 } |
| 124 return result; | 130 return result; |
| 125 } | 131 } |
| (...skipping 1063 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1189 | 1195 |
| 1190 void DeviceStatusCollector::OnOSVersion(const std::string& version) { | 1196 void DeviceStatusCollector::OnOSVersion(const std::string& version) { |
| 1191 os_version_ = version; | 1197 os_version_ = version; |
| 1192 } | 1198 } |
| 1193 | 1199 |
| 1194 void DeviceStatusCollector::OnOSFirmware(const std::string& version) { | 1200 void DeviceStatusCollector::OnOSFirmware(const std::string& version) { |
| 1195 firmware_version_ = version; | 1201 firmware_version_ = version; |
| 1196 } | 1202 } |
| 1197 | 1203 |
| 1198 } // namespace policy | 1204 } // namespace policy |
| OLD | NEW |