| 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 7a2afc892c41a5941d839b57ac8e16ee1ef977a6..bc0d2e3412073193a3c7288154da724b92dad429 100644
|
| --- a/chrome/browser/chromeos/policy/device_status_collector.cc
|
| +++ b/chrome/browser/chromeos/policy/device_status_collector.cc
|
| @@ -4,11 +4,12 @@
|
|
|
| #include "chrome/browser/chromeos/policy/device_status_collector.h"
|
|
|
| +#include <stddef.h>
|
| #include <stdint.h>
|
| +#include <sys/statvfs.h>
|
| #include <cstdio>
|
| #include <limits>
|
| #include <sstream>
|
| -#include <sys/statvfs.h>
|
|
|
| #include "base/bind.h"
|
| #include "base/bind_helpers.h"
|
| @@ -17,6 +18,7 @@
|
| #include "base/format_macros.h"
|
| #include "base/location.h"
|
| #include "base/logging.h"
|
| +#include "base/macros.h"
|
| #include "base/memory/scoped_ptr.h"
|
| #include "base/posix/eintr_wrapper.h"
|
| #include "base/prefs/pref_registry_simple.h"
|
| @@ -96,7 +98,7 @@ const char kCPUTempFilePattern[] = "temp*_input";
|
|
|
| // Determine the day key (milliseconds since epoch for corresponding day in UTC)
|
| // for a given |timestamp|.
|
| -int64 TimestampToDayKey(Time timestamp) {
|
| +int64_t TimestampToDayKey(Time timestamp) {
|
| Time::Exploded exploded;
|
| timestamp.LocalMidnight().LocalExplode(&exploded);
|
| return (Time::FromUTCExploded(exploded) - Time::UnixEpoch()).InMilliseconds();
|
| @@ -188,7 +190,7 @@ std::vector<em::CPUTempInfo> ReadCPUTempInfo() {
|
|
|
| // Read temperature in millidegree Celsius.
|
| std::string temperature_string;
|
| - int32 temperature = 0;
|
| + int32_t temperature = 0;
|
| if (base::ReadFileToString(temperature_path, &temperature_string) &&
|
| sscanf(temperature_string.c_str(), "%d", &temperature) == 1) {
|
| // CPU temp in millidegree Celsius to Celsius
|
| @@ -312,7 +314,7 @@ DeviceStatusCollector::DeviceStatusCollector(
|
| // reacquire the location on every user session change or browser crash.
|
| content::Geoposition position;
|
| std::string timestamp_str;
|
| - int64 timestamp;
|
| + int64_t timestamp;
|
| const base::DictionaryValue* location =
|
| local_state_->GetDictionary(prefs::kDeviceLocation);
|
| if (location->GetDouble(kLatitude, &position.latitude) &&
|
| @@ -447,16 +449,16 @@ void DeviceStatusCollector::PruneStoredActivityPeriods(Time base_time) {
|
| TimestampToDayKey(max_time));
|
| }
|
|
|
| -void DeviceStatusCollector::TrimStoredActivityPeriods(int64 min_day_key,
|
| +void DeviceStatusCollector::TrimStoredActivityPeriods(int64_t min_day_key,
|
| int min_day_trim_duration,
|
| - int64 max_day_key) {
|
| + int64_t max_day_key) {
|
| const base::DictionaryValue* activity_times =
|
| local_state_->GetDictionary(prefs::kDeviceActivityTimes);
|
|
|
| scoped_ptr<base::DictionaryValue> copy(activity_times->DeepCopy());
|
| for (base::DictionaryValue::Iterator it(*activity_times); !it.IsAtEnd();
|
| it.Advance()) {
|
| - int64 timestamp;
|
| + int64_t timestamp;
|
| if (base::StringToInt64(it.key(), ×tamp)) {
|
| // Remove data that is too old, or too far in the future.
|
| if (timestamp >= min_day_key && timestamp < max_day_key) {
|
| @@ -488,7 +490,7 @@ void DeviceStatusCollector::AddActivePeriod(Time start, Time end) {
|
| Time midnight = start.LocalMidnight();
|
| while (midnight < end) {
|
| midnight += TimeDelta::FromDays(1);
|
| - int64 activity = (std::min(end, midnight) - start).InMilliseconds();
|
| + int64_t activity = (std::min(end, midnight) - start).InMilliseconds();
|
| std::string day_key = base::Int64ToString(TimestampToDayKey(start));
|
| int previous_activity = 0;
|
| activity_times->GetInteger(day_key, &previous_activity);
|
| @@ -603,7 +605,7 @@ void DeviceStatusCollector::ReceiveCPUStatistics(const std::string& stats) {
|
| //
|
| // We only care about the first four numbers: user_time, nice_time,
|
| // sys_time, and idle_time.
|
| - uint64 user = 0, nice = 0, system = 0, idle = 0;
|
| + uint64_t user = 0, nice = 0, system = 0, idle = 0;
|
| int vals = sscanf(stats.c_str(),
|
| "cpu %" PRIu64 " %" PRIu64 " %" PRIu64 " %" PRIu64, &user,
|
| &nice, &system, &idle);
|
| @@ -611,9 +613,9 @@ void DeviceStatusCollector::ReceiveCPUStatistics(const std::string& stats) {
|
|
|
| // The values returned from /proc/stat are cumulative totals, so calculate
|
| // the difference between the last sample and this one.
|
| - uint64 active = user + nice + system;
|
| - uint64 total = active + idle;
|
| - uint64 last_total = last_cpu_active_ + last_cpu_idle_;
|
| + uint64_t active = user + nice + system;
|
| + uint64_t total = active + idle;
|
| + uint64_t last_total = last_cpu_active_ + last_cpu_idle_;
|
| DCHECK_GE(active, last_cpu_active_);
|
| DCHECK_GE(idle, last_cpu_idle_);
|
| DCHECK_GE(total, last_total);
|
| @@ -655,13 +657,13 @@ void DeviceStatusCollector::GetActivityTimes(
|
|
|
| for (base::DictionaryValue::Iterator it(*activity_times); !it.IsAtEnd();
|
| it.Advance()) {
|
| - int64 start_timestamp;
|
| + int64_t start_timestamp;
|
| int activity_milliseconds;
|
| if (base::StringToInt64(it.key(), &start_timestamp) &&
|
| it.value().GetAsInteger(&activity_milliseconds)) {
|
| // This is correct even when there are leap seconds, because when a leap
|
| // second occurs, two consecutive seconds have the same timestamp.
|
| - int64 end_timestamp = start_timestamp + Time::kMillisecondsPerDay;
|
| + int64_t end_timestamp = start_timestamp + Time::kMillisecondsPerDay;
|
|
|
| em::ActiveTimePeriod* active_period = request->add_active_period();
|
| em::TimePeriod* period = active_period->mutable_time_period();
|
| @@ -978,7 +980,7 @@ std::string DeviceStatusCollector::GetAppVersion(
|
|
|
| void DeviceStatusCollector::OnSubmittedSuccessfully() {
|
| TrimStoredActivityPeriods(last_reported_day_, duration_for_last_reported_day_,
|
| - std::numeric_limits<int64>::max());
|
| + std::numeric_limits<int64_t>::max());
|
| }
|
|
|
| void DeviceStatusCollector::OnOSVersion(const std::string& version) {
|
|
|