crash-reporter: Update to build against libchrome-271506.

BUG=chromium:375032
TEST=`FEATURES=test emerge-$BOARD platform2`

Change-Id: I3984dee513690711e277e5fa8939ca5f7910d180
Reviewed-on: https://chromium-review.googlesource.com/201184
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
diff --git a/crash_reporter/chrome_collector.cc b/crash_reporter/chrome_collector.cc
index 9798ec5..7bf1f85 100644
--- a/crash_reporter/chrome_collector.cc
+++ b/crash_reporter/chrome_collector.cc
@@ -72,9 +72,9 @@
   guchar *decoded_error_state =
       g_base64_decode(error_state_str.c_str() + kBase64HeaderLength, &len);
 
-  int written;
-  written = file_util::WriteFile(error_state_path,
-      reinterpret_cast<const char*>(decoded_error_state), len);
+  int written =
+      base::WriteFile(error_state_path,
+                      reinterpret_cast<const char *>(decoded_error_state), len);
   g_free(decoded_error_state);
 
   if (written < 0 || (gsize)written != len) {
diff --git a/crash_reporter/chrome_collector_test.cc b/crash_reporter/chrome_collector_test.cc
index 37a180b..9b97399 100644
--- a/crash_reporter/chrome_collector_test.cc
+++ b/crash_reporter/chrome_collector_test.cc
@@ -123,13 +123,13 @@
   const FilePath& dir = scoped_temp_dir.path();
   FilePath dump_file = dir.Append("test.dmp");
   ASSERT_EQ(strlen(kCrashFormatWithFile),
-            file_util::WriteFile(dump_file, kCrashFormatWithFile,
-                                 strlen(kCrashFormatWithFile)));
+            base::WriteFile(dump_file, kCrashFormatWithFile,
+                            strlen(kCrashFormatWithFile)));
   collector_.ForceCrashDirectory(dir);
 
   FilePath log_file;
   {
-    file_util::ScopedFILE output(
+    base::ScopedFILE output(
         base::CreateAndOpenTemporaryFileInDir(dir, &log_file));
     ASSERT_TRUE(output.get());
     base::AutoReset<FILE*> auto_reset_file_ptr(&collector_.output_file_ptr_,
diff --git a/crash_reporter/crash_collector.cc b/crash_reporter/crash_collector.cc
index 5ddff08..8e463da 100644
--- a/crash_reporter/crash_collector.cc
+++ b/crash_reporter/crash_collector.cc
@@ -102,7 +102,7 @@
     return -1;
   }
 
-  int rv = file_util::WriteFileDescriptor(fd, data, size);
+  int rv = base::WriteFileDescriptor(fd, data, size);
   IGNORE_EINTR(close(fd));
   return rv;
 }
@@ -520,7 +520,7 @@
                                        version.c_str(),
                                        payload_path.c_str(),
                                        payload_size);
-  // We must use WriteNewFile instead of file_util::WriteFile as we
+  // We must use WriteNewFile instead of base::WriteFile as we
   // do not want to write with root access to a symlink that an attacker
   // might have created.
   if (WriteNewFile(meta_path, meta_data.c_str(), meta_data.size()) < 0) {
diff --git a/crash_reporter/crash_collector_test.cc b/crash_reporter/crash_collector_test.cc
index 863fed3..81a4a7c 100644
--- a/crash_reporter/crash_collector_test.cc
+++ b/crash_reporter/crash_collector_test.cc
@@ -175,22 +175,19 @@
 TEST_F(CrashCollectorTest, CheckHasCapacityUsual) {
   // Test kMaxCrashDirectorySize - 1 non-meta files can be added.
   for (int i = 0; i < CrashCollector::kMaxCrashDirectorySize - 1; ++i) {
-    file_util::WriteFile(test_dir_.Append(StringPrintf("file%d.core", i)),
-                         "", 0);
+    base::WriteFile(test_dir_.Append(StringPrintf("file%d.core", i)), "", 0);
     EXPECT_TRUE(CheckHasCapacity());
   }
 
   // Test an additional kMaxCrashDirectorySize - 1 meta files fit.
   for (int i = 0; i < CrashCollector::kMaxCrashDirectorySize - 1; ++i) {
-    file_util::WriteFile(test_dir_.Append(StringPrintf("file%d.meta", i)),
-                         "", 0);
+    base::WriteFile(test_dir_.Append(StringPrintf("file%d.meta", i)), "", 0);
     EXPECT_TRUE(CheckHasCapacity());
   }
 
   // Test an additional kMaxCrashDirectorySize meta files don't fit.
   for (int i = 0; i < CrashCollector::kMaxCrashDirectorySize; ++i) {
-    file_util::WriteFile(test_dir_.Append(StringPrintf("overage%d.meta", i)),
-                         "", 0);
+    base::WriteFile(test_dir_.Append(StringPrintf("overage%d.meta", i)), "", 0);
     EXPECT_FALSE(CheckHasCapacity());
   }
 }
@@ -198,26 +195,25 @@
 TEST_F(CrashCollectorTest, CheckHasCapacityCorrectBasename) {
   // Test kMaxCrashDirectorySize - 1 files can be added.
   for (int i = 0; i < CrashCollector::kMaxCrashDirectorySize - 1; ++i) {
-    file_util::WriteFile(test_dir_.Append(StringPrintf("file.%d.core", i)),
-                         "", 0);
+    base::WriteFile(test_dir_.Append(StringPrintf("file.%d.core", i)), "", 0);
     EXPECT_TRUE(CheckHasCapacity());
   }
-  file_util::WriteFile(test_dir_.Append("file.last.core"), "", 0);
+  base::WriteFile(test_dir_.Append("file.last.core"), "", 0);
   EXPECT_FALSE(CheckHasCapacity());
 }
 
 TEST_F(CrashCollectorTest, CheckHasCapacityStrangeNames) {
   // Test many files with different extensions and same base fit.
   for (int i = 0; i < 5 * CrashCollector::kMaxCrashDirectorySize; ++i) {
-    file_util::WriteFile(test_dir_.Append(StringPrintf("a.%d", i)), "", 0);
+    base::WriteFile(test_dir_.Append(StringPrintf("a.%d", i)), "", 0);
     EXPECT_TRUE(CheckHasCapacity());
   }
   // Test dot files are treated as individual files.
   for (int i = 0; i < CrashCollector::kMaxCrashDirectorySize - 2; ++i) {
-    file_util::WriteFile(test_dir_.Append(StringPrintf(".file%d", i)), "", 0);
+    base::WriteFile(test_dir_.Append(StringPrintf(".file%d", i)), "", 0);
     EXPECT_TRUE(CheckHasCapacity());
   }
-  file_util::WriteFile(test_dir_.Append("normal.meta"), "", 0);
+  base::WriteFile(test_dir_.Append("normal.meta"), "", 0);
   EXPECT_FALSE(CheckHasCapacity());
 }
 
@@ -238,7 +234,7 @@
   std::map<std::string, std::string> dictionary;
   std::map<std::string, std::string>::iterator i;
 
-  file_util::WriteFile(path, contents, strlen(contents));
+  base::WriteFile(path, contents, strlen(contents));
 
   EXPECT_TRUE(collector_.ReadKeyValueFile(path, '=', &dictionary));
   i = dictionary.find("a");
@@ -255,7 +251,7 @@
               "=k\n"
               "#comment=0\n"
               "l=\n");
-  file_util::WriteFile(path, contents, strlen(contents));
+  base::WriteFile(path, contents, strlen(contents));
 
   EXPECT_FALSE(collector_.ReadKeyValueFile(path, '=', &dictionary));
   EXPECT_EQ(5, dictionary.size());
@@ -282,13 +278,9 @@
   std::string contents;
   collector_.lsb_release_ = lsb_release.value();
   const char kLsbContents[] = "CHROMEOS_RELEASE_VERSION=version\n";
-  ASSERT_TRUE(
-      file_util::WriteFile(lsb_release,
-                           kLsbContents, strlen(kLsbContents)));
+  ASSERT_TRUE(base::WriteFile(lsb_release, kLsbContents, strlen(kLsbContents)));
   const char kPayload[] = "foo";
-  ASSERT_TRUE(
-      file_util::WriteFile(payload_file,
-                           kPayload, strlen(kPayload)));
+  ASSERT_TRUE(base::WriteFile(payload_file, kPayload, strlen(kPayload)));
   collector_.AddCrashMetaData("foo", "bar");
   collector_.WriteCrashMetaData(meta_file, "kernel", payload_file.value());
   EXPECT_TRUE(base::ReadFileToString(meta_file, &contents));
@@ -303,9 +295,7 @@
 
   // Test target of symlink is not overwritten.
   payload_file = test_dir_.Append("payload2-file");
-  ASSERT_TRUE(
-      file_util::WriteFile(payload_file,
-                           kPayload, strlen(kPayload)));
+  ASSERT_TRUE(base::WriteFile(payload_file, kPayload, strlen(kPayload)));
   FilePath meta_symlink_path = test_dir_.Append("symlink.meta");
   ASSERT_EQ(0,
             symlink(kMetaFileBasename,
@@ -337,8 +327,7 @@
   const char kConfigContents[] =
       "foobar:echo hello there | sed -e \"s/there/world/\"";
   ASSERT_TRUE(
-      file_util::WriteFile(config_file,
-                           kConfigContents, strlen(kConfigContents)));
+      base::WriteFile(config_file, kConfigContents, strlen(kConfigContents)));
   base::DeleteFile(FilePath(output_file), false);
   EXPECT_FALSE(collector_.GetLogContents(config_file,
                                          "barfoo",
diff --git a/crash_reporter/crash_reporter.cc b/crash_reporter/crash_reporter.cc
index 828ec91..be70ebc 100644
--- a/crash_reporter/crash_reporter.cc
+++ b/crash_reporter/crash_reporter.cc
@@ -68,7 +68,7 @@
 }
 
 static bool TouchFile(const FilePath &file_path) {
-  return file_util::WriteFile(file_path, "", 0) == 0;
+  return base::WriteFile(file_path, "", 0) == 0;
 }
 
 static void SendCrashMetrics(CrashKinds type, const char* name) {
diff --git a/crash_reporter/kernel_collector.cc b/crash_reporter/kernel_collector.cc
index 7f7c7fb..a57e587 100644
--- a/crash_reporter/kernel_collector.cc
+++ b/crash_reporter/kernel_collector.cc
@@ -523,7 +523,7 @@
     FilePath kernel_crash_path = root_crash_directory.Append(
         StringPrintf("%s.kcrash", dump_basename.c_str()));
 
-    // We must use WriteNewFile instead of file_util::WriteFile as we
+    // We must use WriteNewFile instead of base::WriteFile as we
     // do not want to write with root access to a symlink that an attacker
     // might have created.
     if (WriteNewFile(kernel_crash_path,
diff --git a/crash_reporter/kernel_collector_test.cc b/crash_reporter/kernel_collector_test.cc
index 14b8357..5e9bc15 100644
--- a/crash_reporter/kernel_collector_test.cc
+++ b/crash_reporter/kernel_collector_test.cc
@@ -33,8 +33,7 @@
  protected:
   void WriteStringToFile(const FilePath &file_path,
                          const char *data) {
-    ASSERT_EQ(strlen(data),
-              file_util::WriteFile(file_path, data, strlen(data)));
+    ASSERT_EQ(strlen(data), base::WriteFile(file_path, data, strlen(data)));
   }
 
   void SetUpSuccessfulCollect();
diff --git a/crash_reporter/kernel_warning_collector.cc b/crash_reporter/kernel_warning_collector.cc
index 34d29a5..a186e9f 100644
--- a/crash_reporter/kernel_warning_collector.cc
+++ b/crash_reporter/kernel_warning_collector.cc
@@ -77,7 +77,7 @@
   FilePath kernel_crash_path = root_crash_directory.Append(
       StringPrintf("%s.kcrash", dump_basename.c_str()));
 
-  // We must use WriteNewFile instead of file_util::WriteFile as we
+  // We must use WriteNewFile instead of base::WriteFile as we
   // do not want to write with root access to a symlink that an attacker
   // might have created.
   if (WriteNewFile(kernel_crash_path,
diff --git a/crash_reporter/list_proxies.cc b/crash_reporter/list_proxies.cc
index 1f9db76..41dd390 100644
--- a/crash_reporter/list_proxies.cc
+++ b/crash_reporter/list_proxies.cc
@@ -66,7 +66,7 @@
   base::StringTokenizer entry_tok(input, ";");
   while (entry_tok.GetNext()) {
     std::string token = entry_tok.token();
-    TrimWhitespaceASCII(token, TRIM_ALL, &token);
+    base::TrimWhitespaceASCII(token, base::TRIM_ALL, &token);
 
     // Start by finding the first space (if any).
     std::string::iterator space;
@@ -90,7 +90,7 @@
       continue;  // Invalid proxy scheme
 
     std::string host_and_port = std::string(space, token.end());
-    TrimWhitespaceASCII(host_and_port, TRIM_ALL, &host_and_port);
+    base::TrimWhitespaceASCII(host_and_port, base::TRIM_ALL, &host_and_port);
     if (scheme != "direct" && host_and_port.empty())
       continue;  // Must supply host/port when non-direct proxy used.
     ret.push_back(scheme + "://" + host_and_port);
diff --git a/crash_reporter/udev_collector_test.cc b/crash_reporter/udev_collector_test.cc
index db1550f..d5d6f29 100644
--- a/crash_reporter/udev_collector_test.cc
+++ b/crash_reporter/udev_collector_test.cc
@@ -68,9 +68,9 @@
 
     // Write to a dummy log config file.
     ASSERT_EQ(strlen(kLogConfigFileContents),
-              file_util::WriteFile(log_config_path,
-                                   kLogConfigFileContents,
-                                   strlen(kLogConfigFileContents)));
+              base::WriteFile(log_config_path,
+                              kLogConfigFileContents,
+                              strlen(kLogConfigFileContents)));
 
     chromeos::ClearLog();
   }
diff --git a/crash_reporter/unclean_shutdown_collector.cc b/crash_reporter/unclean_shutdown_collector.cc
index ae0775c..8ee83c8 100644
--- a/crash_reporter/unclean_shutdown_collector.cc
+++ b/crash_reporter/unclean_shutdown_collector.cc
@@ -29,7 +29,7 @@
 bool UncleanShutdownCollector::Enable() {
   FilePath file_path(unclean_shutdown_file_);
   base::CreateDirectory(file_path.DirName());
-  if (file_util::WriteFile(file_path, "", 0) != 0) {
+  if (base::WriteFile(file_path, "", 0) != 0) {
     LOG(ERROR) << "Unable to create shutdown check file";
     return false;
   }
diff --git a/crash_reporter/unclean_shutdown_collector_test.cc b/crash_reporter/unclean_shutdown_collector_test.cc
index f9ad054..a0eec1c 100644
--- a/crash_reporter/unclean_shutdown_collector_test.cc
+++ b/crash_reporter/unclean_shutdown_collector_test.cc
@@ -45,8 +45,7 @@
  protected:
   void WriteStringToFile(const FilePath &file_path,
                          const char *data) {
-    ASSERT_EQ(strlen(data),
-              file_util::WriteFile(file_path, data, strlen(data)));
+    ASSERT_EQ(strlen(data), base::WriteFile(file_path, data, strlen(data)));
   }
 
   UncleanShutdownCollector collector_;
@@ -87,7 +86,7 @@
 TEST_F(UncleanShutdownCollectorTest, CollectDeadBatterySuspended) {
   ASSERT_TRUE(collector_.Enable());
   ASSERT_TRUE(base::PathExists(test_unclean_));
-  file_util::WriteFile(collector_.powerd_suspended_file_, "", 0);
+  base::WriteFile(collector_.powerd_suspended_file_, "", 0);
   ASSERT_FALSE(collector_.Collect());
   ASSERT_FALSE(base::PathExists(test_unclean_));
   ASSERT_FALSE(base::PathExists(collector_.powerd_suspended_file_));
@@ -114,7 +113,7 @@
         << "Error while creating directory '" << kTestUnclean
         << "': " << strerror(errno);
   }
-  ASSERT_EQ(0, file_util::WriteFile(test_unclean_.Append("foo"), "", 0))
+  ASSERT_EQ(0, base::WriteFile(test_unclean_.Append("foo"), "", 0))
       << "Error while creating empty file '"
       << test_unclean_.Append("foo").value() << "': " << strerror(errno);
   ASSERT_FALSE(collector_.Disable());
diff --git a/crash_reporter/user_collector.cc b/crash_reporter/user_collector.cc
index 5b0bdb3..3355b0e 100644
--- a/crash_reporter/user_collector.cc
+++ b/crash_reporter/user_collector.cc
@@ -117,18 +117,15 @@
   CHECK(initialized_);
   LOG(INFO) << (enabled ? "Enabling" : "Disabling") << " user crash handling";
 
-  if (file_util::WriteFile(FilePath(core_pipe_limit_file_),
-                           kCorePipeLimit,
-                           strlen(kCorePipeLimit)) !=
+  if (base::WriteFile(FilePath(core_pipe_limit_file_), kCorePipeLimit,
+                      strlen(kCorePipeLimit)) !=
       static_cast<int>(strlen(kCorePipeLimit))) {
     PLOG(ERROR) << "Unable to write " << core_pipe_limit_file_;
     return false;
   }
   std::string pattern = GetPattern(enabled);
-  if (file_util::WriteFile(FilePath(core_pattern_file_),
-                           pattern.c_str(),
-                           pattern.length()) !=
-      static_cast<int>(pattern.length())) {
+  if (base::WriteFile(FilePath(core_pattern_file_), pattern.c_str(),
+                      pattern.length()) != static_cast<int>(pattern.length())) {
     PLOG(ERROR) << "Unable to write " << core_pattern_file_;
     return false;
   }
@@ -209,7 +206,7 @@
   }
   FilePath log_path = GetCrashPath(crash_path, dump_basename, "log");
   FilePath meta_path = GetCrashPath(crash_path, dump_basename, "meta");
-  // We must use WriteNewFile instead of file_util::WriteFile as we do
+  // We must use WriteNewFile instead of base::WriteFile as we do
   // not want to write with root access to a symlink that an attacker
   // might have created.
   if (WriteNewFile(log_path, error_log.data(), error_log.length()) < 0) {
diff --git a/crash_reporter/user_collector_test.cc b/crash_reporter/user_collector_test.cc
index 0dd35e0..eeaf070 100644
--- a/crash_reporter/user_collector_test.cc
+++ b/crash_reporter/user_collector_test.cc
@@ -478,13 +478,13 @@
 
   // maps file is empty
   FilePath maps_file = container_dir.Append("maps");
-  ASSERT_EQ(0, file_util::WriteFile(maps_file, NULL, 0));
+  ASSERT_EQ(0, base::WriteFile(maps_file, NULL, 0));
   ASSERT_TRUE(base::PathExists(maps_file));
   EXPECT_FALSE(collector_.ValidateProcFiles(container_dir));
 
   // maps file is not empty
   const char data[] = "test data";
-  ASSERT_EQ(sizeof(data), file_util::WriteFile(maps_file, data, sizeof(data)));
+  ASSERT_EQ(sizeof(data), base::WriteFile(maps_file, data, sizeof(data)));
   ASSERT_TRUE(base::PathExists(maps_file));
   EXPECT_TRUE(collector_.ValidateProcFiles(container_dir));
 }
@@ -512,26 +512,26 @@
 #endif
 
   // Core file has the expected header
-  ASSERT_TRUE(file_util::WriteFile(core_file, e_ident, sizeof(e_ident)));
+  ASSERT_TRUE(base::WriteFile(core_file, e_ident, sizeof(e_ident)));
   EXPECT_EQ(UserCollector::kErrorNone,
             collector_.ValidateCoreFile(core_file));
 
 #if __WORDSIZE == 64
   // 32-bit core file on 64-bit platform
   e_ident[EI_CLASS] = ELFCLASS32;
-  ASSERT_TRUE(file_util::WriteFile(core_file, e_ident, sizeof(e_ident)));
+  ASSERT_TRUE(base::WriteFile(core_file, e_ident, sizeof(e_ident)));
   EXPECT_EQ(UserCollector::kErrorUnsupported32BitCoreFile,
             collector_.ValidateCoreFile(core_file));
   e_ident[EI_CLASS] = ELFCLASS64;
 #endif
 
   // Invalid core files
-  ASSERT_TRUE(file_util::WriteFile(core_file, e_ident, sizeof(e_ident) - 1));
+  ASSERT_TRUE(base::WriteFile(core_file, e_ident, sizeof(e_ident) - 1));
   EXPECT_EQ(UserCollector::kErrorInvalidCoreFile,
             collector_.ValidateCoreFile(core_file));
 
   e_ident[EI_MAG0] = 0;
-  ASSERT_TRUE(file_util::WriteFile(core_file, e_ident, sizeof(e_ident)));
+  ASSERT_TRUE(base::WriteFile(core_file, e_ident, sizeof(e_ident)));
   EXPECT_EQ(UserCollector::kErrorInvalidCoreFile,
             collector_.ValidateCoreFile(core_file));
 }