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

Side by Side Diff: chrome/browser/chromeos/policy/device_status_collector.cc

Issue 2111103002: Make callers of FromUTC(Local)Exploded in chrome/ use new time API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Lei Zhang's comments Created 4 years, 5 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 unified diff | Download patch
OLDNEW
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
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 bool conversion_success = Time::FromUTCExploded(exploded, &out_time);
108 DCHECK(conversion_success);
109 return (out_time - Time::UnixEpoch()).InMilliseconds();
107 } 110 }
108 111
109 // Helper function (invoked via blocking pool) to fetch information about 112 // Helper function (invoked via blocking pool) to fetch information about
110 // mounted disks. 113 // mounted disks.
111 std::vector<em::VolumeInfo> GetVolumeInfo( 114 std::vector<em::VolumeInfo> GetVolumeInfo(
112 const std::vector<std::string>& mount_points) { 115 const std::vector<std::string>& mount_points) {
113 std::vector<em::VolumeInfo> result; 116 std::vector<em::VolumeInfo> result;
114 for (const std::string& mount_point : mount_points) { 117 for (const std::string& mount_point : mount_points) {
115 base::FilePath mount_path(mount_point); 118 base::FilePath mount_path(mount_point);
116 int64_t free_size = base::SysInfo::AmountOfFreeDiskSpace(mount_path); 119 int64_t free_size = base::SysInfo::AmountOfFreeDiskSpace(mount_path);
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 ScheduleGeolocationUpdateRequest(); 1054 ScheduleGeolocationUpdateRequest();
1052 } 1055 }
1053 1056
1054 void DeviceStatusCollector::ReceiveVolumeInfo( 1057 void DeviceStatusCollector::ReceiveVolumeInfo(
1055 const std::vector<em::VolumeInfo>& info) { 1058 const std::vector<em::VolumeInfo>& info) {
1056 if (report_hardware_status_) 1059 if (report_hardware_status_)
1057 volume_info_ = info; 1060 volume_info_ = info;
1058 } 1061 }
1059 1062
1060 } // namespace policy 1063 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698