metrics: Use integer types from stdint.h

This CL replaces the deprecated int* and uint* types from
'base/basictypes.h' with the int*_t and uint*_t types from 'stdint.h'.

BUG=chromium:401356
TEST=`FEATURES=test emerge-$BOARD metrics`

Change-Id: Ie5a69edba2c8a9d5185bbc548ed70a5b121c3e3b
Reviewed-on: https://chromium-review.googlesource.com/211381
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
diff --git a/metrics/metrics_daemon.cc b/metrics/metrics_daemon.cc
index b9212fb..9e0bf04 100644
--- a/metrics/metrics_daemon.cc
+++ b/metrics/metrics_daemon.cc
@@ -175,7 +175,7 @@
   }
 
   // On OS version change, clear version stats (which are reported daily).
-  int32 version = GetOsVersionHash();
+  int32_t version = GetOsVersionHash();
   if (version_cycle_->Get() != version) {
     version_cycle_->Set(version);
     kernel_crashes_version_count_->Set(0);
@@ -190,8 +190,8 @@
   upload_service_->UploadEvent();
 }
 
-uint32 MetricsDaemon::GetOsVersionHash() {
-  static uint32 cached_version_hash = 0;
+uint32_t MetricsDaemon::GetOsVersionHash() {
+  static uint32_t cached_version_hash = 0;
   static bool version_hash_is_cached = false;
   if (version_hash_is_cached)
     return cached_version_hash;
@@ -372,7 +372,7 @@
   std::vector<std::string> proc_stat_totals;
   base::SplitStringAlongWhitespace(proc_stat_lines[0], &proc_stat_totals);
 
-  uint64 user_ticks, user_nice_ticks, system_ticks;
+  uint64_t user_ticks, user_nice_ticks, system_ticks;
   if (proc_stat_totals.size() != kMetricsProcStatFirstLineItemsCount ||
       proc_stat_totals[0] != "cpu" ||
       !base::StringToUint64(proc_stat_totals[1], &user_ticks) ||
@@ -382,7 +382,7 @@
     return TimeDelta(base::TimeDelta::FromSeconds(0));
   }
 
-  uint64 total_cpu_use_ticks = user_ticks + user_nice_ticks + system_ticks;
+  uint64_t total_cpu_use_ticks = user_ticks + user_nice_ticks + system_ticks;
 
   // Sanity check.
   if (total_cpu_use_ticks < latest_cpu_use_ticks_) {
@@ -391,7 +391,7 @@
     return TimeDelta();
   }
 
-  uint64 diff = total_cpu_use_ticks - latest_cpu_use_ticks_;
+  uint64_t diff = total_cpu_use_ticks - latest_cpu_use_ticks_;
   latest_cpu_use_ticks_ = total_cpu_use_ticks;
   // Use microseconds to avoid significant truncations.
   return base::TimeDelta::FromMicroseconds(
@@ -470,8 +470,8 @@
   g_timeout_add_seconds(wait, StatsCallbackStatic, this);
 }
 
-bool MetricsDaemon::DiskStatsReadStats(uint64* read_sectors,
-                                       uint64* write_sectors) {
+bool MetricsDaemon::DiskStatsReadStats(uint64_t* read_sectors,
+                                       uint64_t* write_sectors) {
   int nchars;
   int nitems;
   bool success = false;
@@ -632,7 +632,7 @@
 // Collects disk and vm stats alternating over a short and a long interval.
 
 void MetricsDaemon::StatsCallback() {
-  uint64 read_sectors_now, write_sectors_now;
+  uint64_t read_sectors_now, write_sectors_now;
   struct VmstatRecord vmstats_now;
   double time_now = GetActiveTime();
   double delta_time = time_now - stats_initial_time_;
@@ -765,7 +765,7 @@
 
 // static
 bool MetricsDaemon::ReadFileToUint64(const base::FilePath& path,
-                                     uint64* value) {
+                                     uint64_t* value) {
   std::string content;
   if (!base::ReadFileToString(path, &content)) {
     PLOG(WARNING) << "cannot read " << path.MaybeAsASCII();
@@ -782,7 +782,7 @@
 
 bool MetricsDaemon::ReportZram(const base::FilePath& zram_dir) {
   // Data sizes are in bytes.  |zero_pages| is in number of pages.
-  uint64 compr_data_size, orig_data_size, zero_pages;
+  uint64_t compr_data_size, orig_data_size, zero_pages;
   const size_t page_size = 4096;
 
   if (!ReadFileToUint64(zram_dir.Append(kComprDataSizeName),
@@ -1014,7 +1014,7 @@
 void MetricsDaemon::SendKernelCrashesCumulativeCountStats() {
   // Report the number of crashes for this OS version, but don't clear the
   // counter.  It is cleared elsewhere on version change.
-  int64 crashes_count = kernel_crashes_version_count_->Get();
+  int64_t crashes_count = kernel_crashes_version_count_->Get();
   SendSample(kernel_crashes_version_count_->Name(),
              crashes_count,
              1,                         // value of first bucket
@@ -1022,7 +1022,7 @@
              100);                      // number of buckets
 
 
-  int64 cpu_use_ms = version_cumulative_cpu_use_->Get();
+  int64_t cpu_use_ms = version_cumulative_cpu_use_->Get();
   SendSample(version_cumulative_cpu_use_->Name(),
              cpu_use_ms / 1000,         // stat is in seconds
              1,                         // device may be used very little...
@@ -1040,7 +1040,7 @@
                100);
   }
 
-  int64 active_use_seconds = version_cumulative_active_use_->Get();
+  int64_t active_use_seconds = version_cumulative_active_use_->Get();
   if (active_use_seconds > 0) {
     SendSample(version_cumulative_active_use_->Name(),
                active_use_seconds / 1000,  // stat is in seconds
diff --git a/metrics/metrics_daemon.h b/metrics/metrics_daemon.h
index 2bd12b0..205ea69 100644
--- a/metrics/metrics_daemon.h
+++ b/metrics/metrics_daemon.h
@@ -5,6 +5,8 @@
 #ifndef METRICS_METRICS_DAEMON_H_
 #define METRICS_METRICS_DAEMON_H_
 
+#include <stdint.h>
+
 #include <dbus/dbus.h>
 #include <glib.h>
 #include <map>
@@ -213,7 +215,7 @@
   void ScheduleStatsCallback(int wait);
 
   // Reads cumulative disk statistics from sysfs.  Returns true for success.
-  bool DiskStatsReadStats(uint64* read_sectors, uint64* write_sectors);
+  bool DiskStatsReadStats(uint64_t* read_sectors, uint64_t* write_sectors);
 
   // Reads cumulative vm statistics from procfs.  Returns true for success.
   bool VmStatsReadStats(struct VmstatRecord* stats);
@@ -275,7 +277,7 @@
 
   // Reads the current OS version from /etc/lsb-release and hashes it
   // to a unsigned 32-bit int.
-  uint32 GetOsVersionHash();
+  uint32_t GetOsVersionHash();
 
   // Updates stats, additionally sending them to UMA if enough time has elapsed
   // since the last report.
@@ -287,8 +289,8 @@
   // Reports zram statistics.
   bool ReportZram(const base::FilePath& zram_dir);
 
-  // Reads a string from a file and converts it to uint64.
-  static bool ReadFileToUint64(const base::FilePath& path, uint64* value);
+  // Reads a string from a file and converts it to uint64_t.
+  static bool ReadFileToUint64(const base::FilePath& path, uint64_t* value);
 
   // VARIABLES
 
@@ -323,8 +325,8 @@
   unsigned int memuse_interval_index_;
 
   // Contain the most recent disk and vm cumulative stats.
-  uint64 read_sectors_;
-  uint64 write_sectors_;
+  uint64_t read_sectors_;
+  uint64_t write_sectors_;
   struct VmstatRecord vmstats_;
 
   StatsState stats_state_;
@@ -332,10 +334,10 @@
 
   // The system "HZ", or frequency of ticks.  Some system data uses ticks as a
   // unit, and this is used to convert to standard time units.
-  uint32 ticks_per_second_;
+  uint32_t ticks_per_second_;
   // Used internally by GetIncrementalCpuUse() to return the CPU utilization
   // between calls.
-  uint64 latest_cpu_use_ticks_;
+  uint64_t latest_cpu_use_ticks_;
 
   // Persistent values and accumulators for crash statistics.
   scoped_ptr<PersistentInteger> daily_cycle_;
diff --git a/metrics/metrics_daemon_test.cc b/metrics/metrics_daemon_test.cc
index d6abc42..1e9cb3f 100644
--- a/metrics/metrics_daemon_test.cc
+++ b/metrics/metrics_daemon_test.cc
@@ -39,8 +39,8 @@
     "    1793     1788    %" PRIu64 "d   105580    "
     "    196      175     %" PRIu64 "d    30290    "
     "    0    44060   135850\n";
-static const uint64 kFakeReadSectors[] = {80000, 100000};
-static const uint64 kFakeWriteSectors[] = {3000, 4000};
+static const uint64_t kFakeReadSectors[] = {80000, 100000};
+static const uint64_t kFakeWriteSectors[] = {3000, 4000};
 
 static const char kFakeVmStatsName[] = "fake-vm-stats";
 static const char kFakeScalingMaxFreqPath[] = "fake-scaling-max-freq";
@@ -173,7 +173,7 @@
 
   // Creates or overwrites the file in |path| so that it contains the printable
   // representation of |value|.
-  void CreateUint64ValueFile(const base::FilePath& path, uint64 value) {
+  void CreateUint64ValueFile(const base::FilePath& path, uint64_t value) {
     base::DeleteFile(path, false);
     std::string value_string = base::Uint64ToString(value);
     ASSERT_EQ(value_string.length(),
@@ -258,7 +258,7 @@
 }
 
 TEST_F(MetricsDaemonTest, ReportDiskStats) {
-  uint64 read_sectors_now, write_sectors_now;
+  uint64_t read_sectors_now, write_sectors_now;
 
   CreateFakeDiskStatsFile(kFakeDiskStats1.c_str());
   daemon_.DiskStatsReadStats(&read_sectors_now, &write_sectors_now);
@@ -361,12 +361,12 @@
   EXPECT_TRUE(daemon_.testing_);
 
   // |compr_data_size| is the size in bytes of compressed data.
-  const uint64 compr_data_size = 50 * 1000 * 1000;
+  const uint64_t compr_data_size = 50 * 1000 * 1000;
   // The constant '3' is a realistic but random choice.
   // |orig_data_size| does not include zero pages.
-  const uint64 orig_data_size = compr_data_size * 3;
-  const uint64 page_size = 4096;
-  const uint64 zero_pages = 10 * 1000 * 1000 / page_size;
+  const uint64_t orig_data_size = compr_data_size * 3;
+  const uint64_t page_size = 4096;
+  const uint64_t zero_pages = 10 * 1000 * 1000 / page_size;
 
   CreateUint64ValueFile(base::FilePath(MetricsDaemon::kComprDataSizeName),
                         compr_data_size);
@@ -375,11 +375,11 @@
   CreateUint64ValueFile(base::FilePath(MetricsDaemon::kZeroPagesName),
                         zero_pages);
 
-  const uint64 real_orig_size = orig_data_size + zero_pages * page_size;
-  const uint64 zero_ratio_percent =
+  const uint64_t real_orig_size = orig_data_size + zero_pages * page_size;
+  const uint64_t zero_ratio_percent =
       zero_pages * page_size * 100 / real_orig_size;
   // Ratio samples are in percents.
-  const uint64 actual_ratio_sample = real_orig_size * 100 / compr_data_size;
+  const uint64_t actual_ratio_sample = real_orig_size * 100 / compr_data_size;
 
   EXPECT_CALL(metrics_lib_, SendToUMA(_, compr_data_size >> 20, _, _, _));
   EXPECT_CALL(metrics_lib_,
diff --git a/metrics/persistent_integer.cc b/metrics/persistent_integer.cc
index 3020f7b..dd38f1e 100644
--- a/metrics/persistent_integer.cc
+++ b/metrics/persistent_integer.cc
@@ -37,25 +37,25 @@
 
 PersistentInteger::~PersistentInteger() {}
 
-void PersistentInteger::Set(int64 value) {
+void PersistentInteger::Set(int64_t value) {
   value_ = value;
   Write();
 }
 
-int64 PersistentInteger::Get() {
+int64_t PersistentInteger::Get() {
   // If not synced, then read.  If the read fails, it's a good idea to write.
   if (!synced_ && !Read())
     Write();
   return value_;
 }
 
-int64 PersistentInteger::GetAndClear() {
-  int64 v = Get();
+int64_t PersistentInteger::GetAndClear() {
+  int64_t v = Get();
   Set(0);
   return v;
 }
 
-void PersistentInteger::Add(int64 x) {
+void PersistentInteger::Add(int64_t x) {
   Set(Get() + x);
 }
 
@@ -79,8 +79,8 @@
     PLOG(WARNING) << "cannot open " << backing_file_name_ << " for reading";
     return false;
   }
-  int32 version;
-  int64 value;
+  int32_t version;
+  int64_t value;
   bool read_succeeded = false;
   if (HANDLE_EINTR(read(fd, &version, sizeof(version))) == sizeof(version) &&
       version == version_ &&
diff --git a/metrics/persistent_integer.h b/metrics/persistent_integer.h
index 4a5670c..b1cfcf4 100644
--- a/metrics/persistent_integer.h
+++ b/metrics/persistent_integer.h
@@ -5,7 +5,8 @@
 #ifndef METRICS_PERSISTENT_INTEGER_H_
 #define METRICS_PERSISTENT_INTEGER_H_
 
-#include <base/basictypes.h>
+#include <stdint.h>
+
 #include <string>
 
 namespace chromeos_metrics {
@@ -22,20 +23,20 @@
   virtual ~PersistentInteger();
 
   // Sets the value.  This writes through to the backing file.
-  void Set(int64 v);
+  void Set(int64_t v);
 
   // Gets the value.  May sync from backing file first.
-  int64 Get();
+  int64_t Get();
 
   // Returns the name of the object.
   std::string Name() { return name_; }
 
   // Convenience function for Get() followed by Set(0).
-  int64 GetAndClear();
+  int64_t GetAndClear();
 
   // Convenience function for v = Get, Set(v + x).
   // Virtual only because of mock.
-  virtual void Add(int64 x);
+  virtual void Add(int64_t x);
 
   // After calling with |testing| = true, changes some behavior for the purpose
   // of testing.  For instance: instances created while testing use the current
@@ -53,8 +54,8 @@
   // a valid backing file as a side effect.
   bool Read();
 
-  int64 value_;
-  int32 version_;
+  int64_t value_;
+  int32_t version_;
   std::string name_;
   std::string backing_file_name_;
   bool synced_;
diff --git a/metrics/persistent_integer_mock.h b/metrics/persistent_integer_mock.h
index bb42023..2061e55 100644
--- a/metrics/persistent_integer_mock.h
+++ b/metrics/persistent_integer_mock.h
@@ -17,7 +17,7 @@
  public:
   explicit PersistentIntegerMock(const std::string& name)
       : PersistentInteger(name) {}
-    MOCK_METHOD1(Add, void(int64 count));
+    MOCK_METHOD1(Add, void(int64_t count));
 };
 
 }  // namespace chromeos_metrics
diff --git a/metrics/timer_test.cc b/metrics/timer_test.cc
index b678a27..a712605 100644
--- a/metrics/timer_test.cc
+++ b/metrics/timer_test.cc
@@ -2,6 +2,8 @@
 // Use of this source code is governed by a BSD-style license that can be
 // found in the LICENSE file.
 
+#include <stdint.h>
+
 #include <base/memory/scoped_ptr.h>
 #include <gmock/gmock.h>
 #include <gtest/gtest.h>
@@ -16,17 +18,17 @@
 namespace chromeos_metrics {
 
 namespace {
-const int64 kStime1MSec = 1400;
-const int64 kEtime1MSec = 3000;
-const int64 kDelta1MSec = 1600;
+const int64_t kStime1MSec = 1400;
+const int64_t kEtime1MSec = 3000;
+const int64_t kDelta1MSec = 1600;
 
-const int64 kStime2MSec = 4200;
-const int64 kEtime2MSec = 5000;
-const int64 kDelta2MSec = 800;
+const int64_t kStime2MSec = 4200;
+const int64_t kEtime2MSec = 5000;
+const int64_t kDelta2MSec = 800;
 
-const int64 kStime3MSec = 6600;
-const int64 kEtime3MSec = 6800;
-const int64 kDelta3MSec = 200;
+const int64_t kStime3MSec = 6600;
+const int64_t kEtime3MSec = 6800;
+const int64_t kDelta3MSec = 200;
 }  // namespace
 
 class TimerTest : public testing::Test {
diff --git a/metrics/uploader/system_profile_cache.cc b/metrics/uploader/system_profile_cache.cc
index 4b79c73..fd79961 100644
--- a/metrics/uploader/system_profile_cache.cc
+++ b/metrics/uploader/system_profile_cache.cc
@@ -57,7 +57,7 @@
   // TODO(bsimonnet): Change this to map to the number of time system-services
   // is started.
   session_id_->Add(1);
-  profile_.session_id = static_cast<int32>(session_id_->Get());
+  profile_.session_id = static_cast<int32_t>(session_id_->Get());
 
   initialized_ = true;
   return initialized_;
diff --git a/metrics/uploader/system_profile_cache.h b/metrics/uploader/system_profile_cache.h
index 74a3766..2839179 100644
--- a/metrics/uploader/system_profile_cache.h
+++ b/metrics/uploader/system_profile_cache.h
@@ -5,9 +5,10 @@
 #ifndef METRICS_UPLOADER_SYSTEM_PROFILE_CACHE_H_
 #define METRICS_UPLOADER_SYSTEM_PROFILE_CACHE_H_
 
+#include <stdint.h>
+
 #include <string>
 
-#include "base/basictypes.h"
 #include "base/compiler_specific.h"
 #include "base/gtest_prod_util.h"
 #include "base/memory/scoped_ptr.h"
@@ -26,7 +27,7 @@
   std::string app_version;
   std::string hardware_class;
   std::string client_id;
-  int32 session_id;
+  int32_t session_id;
 };
 
 // Retrieves general system informations needed by the protobuf for context and