shill: Update to build against libchrome-271506.
BUG=chromium:375032
TEST=`USE='cellular gdmwimax wimax vpn' FEATURES=test emerge-$BOARD platform2`
Change-Id: Ib7c8b2b290caa261cbb61d30cf8a361a1e3345e1
Reviewed-on: https://chromium-review.googlesource.com/201211
Tested-by: Ben Chan <benchan@chromium.org>
Commit-Queue: Ben Chan <benchan@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
diff --git a/certificate_file.cc b/certificate_file.cc
index d65bbe5..5b4e9c1 100644
--- a/certificate_file.cc
+++ b/certificate_file.cc
@@ -66,7 +66,7 @@
for (vector<string>::const_iterator it = input_lines.begin();
it != input_lines.end(); ++it) {
string line;
- TrimWhitespaceASCII(*it, TRIM_ALL, &line);
+ base::TrimWhitespaceASCII(*it, base::TRIM_ALL, &line);
if (StartsWithASCII(line, kPEMHeader, kCaseSensitive)) {
if (found_header) {
LOG(ERROR) << "Found two PEM headers in a row.";
@@ -123,8 +123,7 @@
}
size_t written =
- file_util::WriteFile(output_file, output_data.c_str(),
- output_data.length());
+ base::WriteFile(output_file, output_data.c_str(), output_data.length());
if (written != output_data.length()) {
LOG(ERROR) << "Unable to write to output file.";
return FilePath();
diff --git a/connection_info_reader_unittest.cc b/connection_info_reader_unittest.cc
index 8c19493..679cbbf 100644
--- a/connection_info_reader_unittest.cc
+++ b/connection_info_reader_unittest.cc
@@ -65,7 +65,7 @@
string line = lines[i];
line += '\n';
ASSERT_EQ(line.size(),
- file_util::AppendToFile(*file_path, line.data(), line.size()));
+ base::AppendToFile(*file_path, line.data(), line.size()));
}
}
diff --git a/crypto_des_cbc_unittest.cc b/crypto_des_cbc_unittest.cc
index 0ba8206..2998fd6 100644
--- a/crypto_des_cbc_unittest.cc
+++ b/crypto_des_cbc_unittest.cc
@@ -53,12 +53,12 @@
string matter = string(kTestIV) + kTestKey;
- file_util::WriteFile(key_matter, matter.data(), matter.size() - 1);
+ base::WriteFile(key_matter, matter.data(), matter.size() - 1);
EXPECT_FALSE(crypto_.LoadKeyMatter(key_matter));
EXPECT_TRUE(crypto_.key().empty());
EXPECT_TRUE(crypto_.iv().empty());
- file_util::WriteFile(key_matter, matter.data(), matter.size());
+ base::WriteFile(key_matter, matter.data(), matter.size());
EXPECT_TRUE(crypto_.LoadKeyMatter(key_matter));
EXPECT_EQ(kTestKey, string(crypto_.key().begin(), crypto_.key().end()));
EXPECT_EQ(kTestIV, string(crypto_.iv().begin(), crypto_.iv().end()));
@@ -67,12 +67,12 @@
const char kIV2[] = "87654321";
matter = string("X") + kIV2 + kKey2;
- file_util::WriteFile(key_matter, matter.data(), matter.size());
+ base::WriteFile(key_matter, matter.data(), matter.size());
EXPECT_TRUE(crypto_.LoadKeyMatter(key_matter));
EXPECT_EQ(kKey2, string(crypto_.key().begin(), crypto_.key().end()));
EXPECT_EQ(kIV2, string(crypto_.iv().begin(), crypto_.iv().end()));
- file_util::WriteFile(key_matter, " ", 1);
+ base::WriteFile(key_matter, " ", 1);
EXPECT_FALSE(crypto_.LoadKeyMatter(key_matter));
EXPECT_TRUE(crypto_.key().empty());
EXPECT_TRUE(crypto_.iv().empty());
diff --git a/crypto_provider_unittest.cc b/crypto_provider_unittest.cc
index e6aa897..624a77e 100644
--- a/crypto_provider_unittest.cc
+++ b/crypto_provider_unittest.cc
@@ -42,7 +42,7 @@
FilePath CryptoProviderTest::InitKeyMatterFile(const FilePath &dir) {
FilePath path = dir.Append(kKeyMatterFile);
string matter = string(kTestIV) + kTestKey;
- file_util::WriteFile(path, matter.data(), matter.size());
+ base::WriteFile(path, matter.data(), matter.size());
return path;
}
diff --git a/device.cc b/device.cc
index b8a3a46..b4a4a22 100644
--- a/device.cc
+++ b/device.cc
@@ -726,7 +726,7 @@
link_name_.c_str(), flag.c_str()));
SLOG(Device, 2) << "Writing " << value << " to flag file "
<< flag_file.value();
- if (file_util::WriteFile(flag_file, value.c_str(), value.length()) != 1) {
+ if (base::WriteFile(flag_file, value.c_str(), value.length()) != 1) {
LOG(ERROR) << StringPrintf("IP flag write failed: %s to %s",
value.c_str(), flag_file.value().c_str());
return false;
diff --git a/device_info.cc b/device_info.cc
index d9fafdb..bda42a1 100644
--- a/device_info.cc
+++ b/device_info.cc
@@ -23,6 +23,7 @@
#include <base/bind.h>
#include <base/file_util.h>
#include <base/files/file_enumerator.h>
+#include <base/files/scoped_file.h>
#include <base/memory/scoped_ptr.h>
#include <base/stl_util.h>
#include <base/strings/string_number_conversions.h>
@@ -820,7 +821,7 @@
PLOG(ERROR) << "failed to open " << kTunDeviceName;
return false;
}
- file_util::ScopedFD scoped_fd(&fd);
+ base::ScopedFD scoped_fd(fd);
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
diff --git a/device_info_unittest.cc b/device_info_unittest.cc
index d649d81..c19bbc6 100644
--- a/device_info_unittest.cc
+++ b/device_info_unittest.cc
@@ -1189,8 +1189,8 @@
FilePath info_path = GetInfoPath(name);
EXPECT_TRUE(base::CreateDirectory(info_path.DirName()));
string contents_newline(contents + "\n");
- EXPECT_TRUE(file_util::WriteFile(info_path, contents_newline.c_str(),
- contents_newline.size()));
+ EXPECT_TRUE(base::WriteFile(info_path, contents_newline.c_str(),
+ contents_newline.size()));
}
void DeviceInfoTechnologyTest::CreateInfoSymLink(const string &name,
diff --git a/dhcp_config_unittest.cc b/dhcp_config_unittest.cc
index f3aa275..8da3339 100644
--- a/dhcp_config_unittest.cc
+++ b/dhcp_config_unittest.cc
@@ -157,8 +157,8 @@
EXPECT_TRUE(base::CreateDirectory(varlib));
lease_file_ =
varlib.Append(base::StringPrintf("dhcpcd-%s.lease", kDeviceName));
- EXPECT_EQ(0, file_util::WriteFile(pid_file_, "", 0));
- EXPECT_EQ(0, file_util::WriteFile(lease_file_, "", 0));
+ EXPECT_EQ(0, base::WriteFile(pid_file_, "", 0));
+ EXPECT_EQ(0, base::WriteFile(lease_file_, "", 0));
EXPECT_TRUE(base::PathExists(pid_file_));
EXPECT_TRUE(base::PathExists(lease_file_));
diff --git a/dhcp_provider_unittest.cc b/dhcp_provider_unittest.cc
index efa5984..b63b40f 100644
--- a/dhcp_provider_unittest.cc
+++ b/dhcp_provider_unittest.cc
@@ -64,7 +64,7 @@
DHCPProvider::kDHCPCDPathFormatLease,
kDeviceName));
EXPECT_TRUE(base::CreateDirectory(lease_file.DirName()));
- EXPECT_EQ(0, file_util::WriteFile(lease_file, "", 0));
+ EXPECT_EQ(0, base::WriteFile(lease_file, "", 0));
EXPECT_TRUE(base::PathExists(lease_file));
provider_->DestroyLease(kDeviceName);
EXPECT_FALSE(base::PathExists(lease_file));
diff --git a/diagnostics_reporter_unittest.cc b/diagnostics_reporter_unittest.cc
index 841b0ae..e88be56 100644
--- a/diagnostics_reporter_unittest.cc
+++ b/diagnostics_reporter_unittest.cc
@@ -102,7 +102,7 @@
base::ScopedTempDir temp_dir_;
ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
FilePath stashed_net_log = temp_dir_.path().Append("stashed-net-log");
- EXPECT_EQ(0, file_util::WriteFile(stashed_net_log, "", 0));
+ EXPECT_EQ(0, base::WriteFile(stashed_net_log, "", 0));
EXPECT_TRUE(base::PathExists(stashed_net_log));
SetStashedNetLog(stashed_net_log);
EXPECT_CALL(time_, GetTimeMonotonic(_))
diff --git a/file_reader.cc b/file_reader.cc
index d0021a4..fb916d3 100644
--- a/file_reader.cc
+++ b/file_reader.cc
@@ -4,6 +4,8 @@
#include "shill/file_reader.h"
+#include <base/file_util.h>
+
using base::FilePath;
using std::string;
diff --git a/file_reader.h b/file_reader.h
index 3d7e452..80faa69 100644
--- a/file_reader.h
+++ b/file_reader.h
@@ -9,7 +9,7 @@
#include <base/basictypes.h>
#include <base/files/file_path.h>
-#include <base/file_util.h>
+#include <base/files/scoped_file.h>
namespace shill {
@@ -34,7 +34,7 @@
private:
// The file to read.
- file_util::ScopedFILE file_;
+ base::ScopedFILE file_;
DISALLOW_COPY_AND_ASSIGN(FileReader);
};
diff --git a/file_reader_unittest.cc b/file_reader_unittest.cc
index ca12ae6..cdc5d8f 100644
--- a/file_reader_unittest.cc
+++ b/file_reader_unittest.cc
@@ -68,13 +68,13 @@
// Test a file not ending with a new-line character
ASSERT_EQ(content.size(),
- file_util::WriteFile(path, content.c_str(), content.size()));
+ base::WriteFile(path, content.c_str(), content.size()));
VerifyReadLines(path, lines);
// Test a file ending with a new-line character
content.push_back('\n');
ASSERT_EQ(content.size(),
- file_util::WriteFile(path, content.c_str(), content.size()));
+ base::WriteFile(path, content.c_str(), content.size()));
VerifyReadLines(path, lines);
}
diff --git a/http_proxy.cc b/http_proxy.cc
index 7d040ea..e783460 100644
--- a/http_proxy.cc
+++ b/http_proxy.cc
@@ -272,7 +272,7 @@
client_data_.Append(ByteString(string("\r\n"), false));
}
- TrimWhitespaceASCII(host, TRIM_ALL, &host);
+ base::TrimWhitespaceASCII(host, base::TRIM_ALL, &host);
if (host.empty()) {
// Revert to using the hostname in the URL if no "Host:" header exists.
host = server_hostname_;
diff --git a/key_file_store_unittest.cc b/key_file_store_unittest.cc
index adbe603..4098c42 100644
--- a/key_file_store_unittest.cc
+++ b/key_file_store_unittest.cc
@@ -64,7 +64,7 @@
void KeyFileStoreTest::WriteKeyFile(string data) {
EXPECT_EQ(data.size(),
- file_util::WriteFile(store_.path(), data.data(), data.size()));
+ base::WriteFile(store_.path(), data.data(), data.size()));
}
TEST_F(KeyFileStoreTest, OpenClose) {
diff --git a/l2tp_ipsec_driver.cc b/l2tp_ipsec_driver.cc
index 7e6ead5..c203a9e 100644
--- a/l2tp_ipsec_driver.cc
+++ b/l2tp_ipsec_driver.cc
@@ -275,7 +275,7 @@
if (!psk.empty()) {
if (!base::CreateTemporaryFileInDir(manager()->run_path(), &psk_file_) ||
chmod(psk_file_.value().c_str(), S_IRUSR | S_IWUSR) ||
- file_util::WriteFile(psk_file_, psk.data(), psk.size()) !=
+ base::WriteFile(psk_file_, psk.data(), psk.size()) !=
static_cast<int>(psk.size())) {
Error::PopulateAndLog(
error, Error::kInternalError, "Unable to setup psk file.");
@@ -338,8 +338,8 @@
if (!base::CreateTemporaryFileInDir(manager()->run_path(),
&xauth_credentials_file_) ||
chmod(xauth_credentials_file_.value().c_str(), S_IRUSR | S_IWUSR) ||
- file_util::WriteFile(xauth_credentials_file_, xauth_credentials.data(),
- xauth_credentials.size()) !=
+ base::WriteFile(xauth_credentials_file_, xauth_credentials.data(),
+ xauth_credentials.size()) !=
static_cast<int>(xauth_credentials.size())) {
Error::PopulateAndLog(
error, Error::kInternalError,
diff --git a/memory_log.cc b/memory_log.cc
index 745fd08..c7f74bf 100644
--- a/memory_log.cc
+++ b/memory_log.cc
@@ -15,8 +15,9 @@
#include <iomanip>
#include <string>
-#include <base/files/file_path.h>
#include <base/file_util.h>
+#include <base/files/file_path.h>
+#include <base/files/scoped_file.h>
#include "shill/logging.h"
#include "shill/shill_time.h"
@@ -118,7 +119,7 @@
LOG(ERROR) << "Failed to open file for dumping memory log to disk.";
return -1;
}
- file_util::ScopedFILE file_closer(f);
+ base::ScopedFILE file_closer(f);
long maximum_pw_string_size = sysconf(_SC_GETPW_R_SIZE_MAX);
if (maximum_pw_string_size < 0) {
LOG(ERROR) << "Setup for changing ownership of memory log file failed";
diff --git a/openvpn_driver.cc b/openvpn_driver.cc
index 2eff5cd..a25d43d 100644
--- a/openvpn_driver.cc
+++ b/openvpn_driver.cc
@@ -277,7 +277,7 @@
string contents = JoinOptions(options, '\n');
contents.push_back('\n');
if (!base::CreateTemporaryFileInDir(openvpn_config_directory_, config_file) ||
- file_util::WriteFile(*config_file, contents.data(), contents.size()) !=
+ base::WriteFile(*config_file, contents.data(), contents.size()) !=
static_cast<int>(contents.size())) {
LOG(ERROR) << "Unable to setup OpenVPN config file.";
return false;
@@ -633,9 +633,8 @@
args()->LookupString(kOpenVPNTLSAuthContentsProperty, "");
if (!contents.empty()) {
if (!base::CreateTemporaryFile(&tls_auth_file_) ||
- file_util::WriteFile(
- tls_auth_file_, contents.data(), contents.size()) !=
- static_cast<int>(contents.size())) {
+ base::WriteFile(tls_auth_file_, contents.data(), contents.size()) !=
+ static_cast<int>(contents.size())) {
Error::PopulateAndLog(
error, Error::kInternalError, "Unable to setup tls-auth file.");
return;
diff --git a/openvpn_driver_unittest.cc b/openvpn_driver_unittest.cc
index 20df258..71ae784 100644
--- a/openvpn_driver_unittest.cc
+++ b/openvpn_driver_unittest.cc
@@ -323,9 +323,9 @@
"CHROMEOS_RELEASE_VERSION=2202.0\n";
EXPECT_TRUE(base::CreateTemporaryFile(&lsb_release_file_));
EXPECT_EQ(arraysize(kLSBReleaseContents),
- file_util::WriteFile(lsb_release_file_,
- kLSBReleaseContents,
- arraysize(kLSBReleaseContents)));
+ base::WriteFile(lsb_release_file_,
+ kLSBReleaseContents,
+ arraysize(kLSBReleaseContents)));
EXPECT_EQ(OpenVPNDriver::kLSBReleaseFile, driver_->lsb_release_file_.value());
driver_->lsb_release_file_ = lsb_release_file_;
}
@@ -1396,7 +1396,7 @@
EXPECT_EQ("IV_PLAT=Chromium OS", env[0]);
EXPECT_EQ("IV_PLAT_REL=2202.0", env[1]);
env.clear();
- EXPECT_EQ(0, file_util::WriteFile(lsb_release_file_, "", 0));
+ EXPECT_EQ(0, base::WriteFile(lsb_release_file_, "", 0));
driver_->InitEnvironment(&env);
EXPECT_EQ(0, env.size());
}
diff --git a/profile.cc b/profile.cc
index 475ac31..ab9b97b 100644
--- a/profile.cc
+++ b/profile.cc
@@ -322,7 +322,7 @@
id.user_hash.c_str()));
}
string content = JoinString(lines, "");
- size_t ret = file_util::WriteFile(path, content.c_str(), content.length());
+ size_t ret = base::WriteFile(path, content.c_str(), content.length());
return ret == content.length();
}
diff --git a/profile_unittest.cc b/profile_unittest.cc
index 247ea07..8fde516 100644
--- a/profile_unittest.cc
+++ b/profile_unittest.cc
@@ -344,8 +344,7 @@
"~%s/%s \n\n",
kUser0, kIdentifier0, kHash0,
kUser1, kIdentifier1));
- EXPECT_EQ(data.size(),
- file_util::WriteFile(list_path, data.data(), data.size()));
+ EXPECT_EQ(data.size(), base::WriteFile(list_path, data.data(), data.size()));
identifiers = Profile::LoadUserProfileList(list_path);
EXPECT_EQ(2, identifiers.size());
EXPECT_EQ(kUser0, identifiers[0].user);
@@ -449,8 +448,7 @@
base::StringPrintf("%s/%s/%s.profile", storage_path().c_str(),
id.user.c_str(), id.identifier.c_str()));
string data = "]corrupt_data[";
- EXPECT_EQ(data.size(),
- file_util::WriteFile(final_path, data.data(), data.size()));
+ EXPECT_EQ(data.size(), base::WriteFile(final_path, data.data(), data.size()));
// Then test that we fail to open this file.
EXPECT_CALL(*mock_metrics_, NotifyCorruptedProfile());
diff --git a/protobuf_lite_streams.cc b/protobuf_lite_streams.cc
index 2ccc33e..f8863fe 100644
--- a/protobuf_lite_streams.cc
+++ b/protobuf_lite_streams.cc
@@ -36,7 +36,7 @@
ProtobufLiteCopyingFileInputStream::ProtobufLiteCopyingFileInputStream(int fd)
: fd_(fd),
- scoped_fd_closer_(&fd_),
+ scoped_fd_closer_(fd_),
previous_seek_failed_(false) {}
ProtobufLiteCopyingFileInputStream::~ProtobufLiteCopyingFileInputStream() {}
diff --git a/protobuf_lite_streams.h b/protobuf_lite_streams.h
index 78950bb..920234c 100644
--- a/protobuf_lite_streams.h
+++ b/protobuf_lite_streams.h
@@ -7,7 +7,7 @@
#include <string>
-#include <base/file_util.h>
+#include <base/files/scoped_file.h>
#include <google/protobuf/io/zero_copy_stream_impl_lite.h>
// Some basic input/output streams are not implemented for protobuf-lite.
@@ -32,7 +32,7 @@
virtual int Skip(int count);
private:
int fd_;
- file_util::ScopedFD scoped_fd_closer_;
+ base::ScopedFD scoped_fd_closer_;
bool previous_seek_failed_;
DISALLOW_COPY_AND_ASSIGN(ProtobufLiteCopyingFileInputStream);
diff --git a/resolver.cc b/resolver.cc
index 5868266..12e5a27 100644
--- a/resolver.cc
+++ b/resolver.cc
@@ -84,7 +84,7 @@
string contents = JoinString(lines, '\n');
SLOG(Resolver, 2) << "Writing DNS out to " << path_.value();
- int count = file_util::WriteFile(path_, contents.c_str(), contents.size());
+ int count = base::WriteFile(path_, contents.c_str(), contents.size());
return count == static_cast<int>(contents.size());
}
diff --git a/routing_table.cc b/routing_table.cc
index 180be41..a08c3a8 100644
--- a/routing_table.cc
+++ b/routing_table.cc
@@ -471,7 +471,7 @@
SLOG(Route, 2) << __func__;
for (size_t i = 0; i < arraysize(kPaths); ++i) {
- if (file_util::WriteFile(FilePath(kPaths[i]), "-1", 2) != 2) {
+ if (base::WriteFile(FilePath(kPaths[i]), "-1", 2) != 2) {
LOG(ERROR) << base::StringPrintf("Cannot write to route flush file %s",
kPaths[i]);
ret = false;
diff --git a/shims/certificates.cc b/shims/certificates.cc
index 705580d..af63768 100644
--- a/shims/certificates.cc
+++ b/shims/certificates.cc
@@ -40,10 +40,9 @@
// static
bool Certificates::Write(const ByteString &cert,
const base::FilePath &certfile) {
- if (file_util::WriteFile(certfile,
- reinterpret_cast<const char *>(cert.GetConstData()),
- cert.GetLength()) !=
- static_cast<int>(cert.GetLength())) {
+ if (base::WriteFile(certfile,
+ reinterpret_cast<const char *>(cert.GetConstData()),
+ cert.GetLength()) != static_cast<int>(cert.GetLength())) {
base::DeleteFile(certfile, false);
LOG(ERROR) << "Unable to save certificate to a file: " << certfile.value();
return false;
diff --git a/shims/netfilter_queue_processor.cc b/shims/netfilter_queue_processor.cc
index 78702c4..e43d5f2 100644
--- a/shims/netfilter_queue_processor.cc
+++ b/shims/netfilter_queue_processor.cc
@@ -19,7 +19,7 @@
#include <deque>
-#include <base/file_util.h>
+#include <base/files/scoped_file.h>
#include <base/logging.h>
#include <base/strings/stringprintf.h>
@@ -284,7 +284,7 @@
return INADDR_NONE;
}
- file_util::ScopedFD scoped_fd(&socket_fd);
+ base::ScopedFD scoped_fd(socket_fd);
struct ifreq ifr;
memset(&ifr, 0, sizeof(ifr));
diff --git a/socket_info_reader_unittest.cc b/socket_info_reader_unittest.cc
index ba59f66..fc4cc5e 100644
--- a/socket_info_reader_unittest.cc
+++ b/socket_info_reader_unittest.cc
@@ -80,7 +80,7 @@
string line = lines[i];
line += '\n';
ASSERT_EQ(line.size(),
- file_util::AppendToFile(*file_path, line.data(), line.size()));
+ base::AppendToFile(*file_path, line.data(), line.size()));
}
}
diff --git a/wifi_endpoint.cc b/wifi_endpoint.cc
index 6349c26..677321d 100644
--- a/wifi_endpoint.cc
+++ b/wifi_endpoint.cc
@@ -580,7 +580,7 @@
break;
}
string s(ie, ie + element_length);
- if (IsStringASCII(s)) {
+ if (base::IsStringASCII(s)) {
switch (element_type) {
case IEEE_80211::kWPSElementManufacturer:
vendor_information->wps_manufacturer = s;
diff --git a/wimax_provider_unittest.cc b/wimax_provider_unittest.cc
index d9534c0..2b4b643 100644
--- a/wimax_provider_unittest.cc
+++ b/wimax_provider_unittest.cc
@@ -470,7 +470,7 @@
"Type=wimax\n"
"NetworkId=76543210\n";
EXPECT_EQ(strlen(contents),
- file_util::WriteFile(test_profile, contents, strlen(contents)));
+ base::WriteFile(test_profile, contents, strlen(contents)));
ASSERT_TRUE(store.Open());
scoped_refptr<MockProfile> profile(
new MockProfile(&control_, &metrics_, &manager_));