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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 96 const char kHwmonDir[] = "/sys/class/hwmon/"; | 96 const char kHwmonDir[] = "/sys/class/hwmon/"; |
| 97 const char kDeviceDir[] = "device"; | 97 const char kDeviceDir[] = "device"; |
| 98 const char kHwmonDirectoryPattern[] = "hwmon*"; | 98 const char kHwmonDirectoryPattern[] = "hwmon*"; |
| 99 const char kCPUTempFilePattern[] = "temp*_input"; | 99 const char kCPUTempFilePattern[] = "temp*_input"; |
| 100 | 100 |
| 101 // Determine the day key (milliseconds since epoch for corresponding day in UTC) | 101 // Determine the day key (milliseconds since epoch for corresponding day in UTC) |
| 102 // for a given |timestamp|. | 102 // for a given |timestamp|. |
| 103 int64_t TimestampToDayKey(Time timestamp) { | 103 int64_t TimestampToDayKey(Time timestamp) { |
| 104 Time::Exploded exploded; | 104 Time::Exploded exploded; |
| 105 timestamp.LocalMidnight().LocalExplode(&exploded); | 105 timestamp.LocalMidnight().LocalExplode(&exploded); |
| 106 return (Time::FromUTCExploded(exploded) - Time::UnixEpoch()).InMilliseconds(); | 106 Time out_time; |
| 107 // Returns Time(0) on failure. | |
| 108 if (!Time::FromUTCExploded(exploded, &out_time)) { | |
|
Lei Zhang
2016/07/06 17:44:29
Can values that come from another Time instance ev
maksims (do not use this acc)
2016/07/07 05:48:14
No, they shouldn't
| |
| 109 // TODO(maksims): implement failure handling. | |
| 110 NOTIMPLEMENTED(); | |
| 111 } | |
| 112 return (out_time - Time::UnixEpoch()).InMilliseconds(); | |
| 107 } | 113 } |
| 108 | 114 |
| 109 // Helper function (invoked via blocking pool) to fetch information about | 115 // Helper function (invoked via blocking pool) to fetch information about |
| 110 // mounted disks. | 116 // mounted disks. |
| 111 std::vector<em::VolumeInfo> GetVolumeInfo( | 117 std::vector<em::VolumeInfo> GetVolumeInfo( |
| 112 const std::vector<std::string>& mount_points) { | 118 const std::vector<std::string>& mount_points) { |
| 113 std::vector<em::VolumeInfo> result; | 119 std::vector<em::VolumeInfo> result; |
| 114 for (const std::string& mount_point : mount_points) { | 120 for (const std::string& mount_point : mount_points) { |
| 115 base::FilePath mount_path(mount_point); | 121 base::FilePath mount_path(mount_point); |
| 116 int64_t free_size = base::SysInfo::AmountOfFreeDiskSpace(mount_path); | 122 int64_t free_size = base::SysInfo::AmountOfFreeDiskSpace(mount_path); |
| (...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1051 ScheduleGeolocationUpdateRequest(); | 1057 ScheduleGeolocationUpdateRequest(); |
| 1052 } | 1058 } |
| 1053 | 1059 |
| 1054 void DeviceStatusCollector::ReceiveVolumeInfo( | 1060 void DeviceStatusCollector::ReceiveVolumeInfo( |
| 1055 const std::vector<em::VolumeInfo>& info) { | 1061 const std::vector<em::VolumeInfo>& info) { |
| 1056 if (report_hardware_status_) | 1062 if (report_hardware_status_) |
| 1057 volume_info_ = info; | 1063 volume_info_ = info; |
| 1058 } | 1064 } |
| 1059 | 1065 |
| 1060 } // namespace policy | 1066 } // namespace policy |
| OLD | NEW |