update_engine: Update libchrome APIs to r369476
The new libchrome has been ported from Chromium and some APIs have
changed. Make necessary changes at call sites.
Change-Id: I42e65bda7f1dbdf6f6e0ebf356d2cfea6b729193
diff --git a/common/action_pipe.h b/common/action_pipe.h
index 362817d..376c2f1 100644
--- a/common/action_pipe.h
+++ b/common/action_pipe.h
@@ -89,10 +89,10 @@
// Utility function
template<typename FromAction, typename ToAction>
void BondActions(FromAction* from, ToAction* to) {
- // TODO(adlr): find something like this that the compiler accepts:
- // COMPILE_ASSERT(typeof(typename FromAction::OutputObjectType) ==
- // typeof(typename ToAction::InputObjectType),
- // FromAction_OutputObjectType_doesnt_match_ToAction_InputObjectType);
+ static_assert(
+ std::is_same<typename FromAction::OutputObjectType,
+ typename ToAction::InputObjectType>::value,
+ "FromAction::OutputObjectType doesn't match ToAction::InputObjectType");
ActionPipe<typename FromAction::OutputObjectType>::Bond(from, to);
}
diff --git a/common/libcurl_http_fetcher.cc b/common/libcurl_http_fetcher.cc
index 13784fa..b735703 100644
--- a/common/libcurl_http_fetcher.cc
+++ b/common/libcurl_http_fetcher.cc
@@ -63,21 +63,21 @@
bool LibcurlHttpFetcher::GetProxyType(const string& proxy,
curl_proxytype* out_type) {
- if (base::StartsWithASCII(proxy, "socks5://", true) ||
- base::StartsWithASCII(proxy, "socks://", true)) {
+ if (base::StartsWith(proxy, "socks5://", base::CompareCase::SENSITIVE) ||
+ base::StartsWith(proxy, "socks://", base::CompareCase::SENSITIVE)) {
*out_type = CURLPROXY_SOCKS5_HOSTNAME;
return true;
}
- if (base::StartsWithASCII(proxy, "socks4://", true)) {
+ if (base::StartsWith(proxy, "socks4://", base::CompareCase::SENSITIVE)) {
*out_type = CURLPROXY_SOCKS4A;
return true;
}
- if (base::StartsWithASCII(proxy, "http://", true) ||
- base::StartsWithASCII(proxy, "https://", true)) {
+ if (base::StartsWith(proxy, "http://", base::CompareCase::SENSITIVE) ||
+ base::StartsWith(proxy, "https://", base::CompareCase::SENSITIVE)) {
*out_type = CURLPROXY_HTTP;
return true;
}
- if (base::StartsWithASCII(proxy, kNoProxy, true)) {
+ if (base::StartsWith(proxy, kNoProxy, base::CompareCase::SENSITIVE)) {
// known failure case. don't log.
return false;
}
@@ -193,7 +193,7 @@
// Lock down the appropriate curl options for HTTP or HTTPS depending on
// the url.
if (hardware_->IsOfficialBuild()) {
- if (base::StartsWithASCII(url_, "http://", false))
+ if (base::StartsWith(url_, "http://", base::CompareCase::INSENSITIVE_ASCII))
SetCurlOptionsForHttp();
else
SetCurlOptionsForHttps();
diff --git a/common/prefs.cc b/common/prefs.cc
index 9d3a30f..a4b97d0 100644
--- a/common/prefs.cc
+++ b/common/prefs.cc
@@ -133,7 +133,7 @@
TEST_AND_RETURN_FALSE(!key.empty());
for (size_t i = 0; i < key.size(); ++i) {
char c = key.at(i);
- TEST_AND_RETURN_FALSE(IsAsciiAlpha(c) || IsAsciiDigit(c) ||
+ TEST_AND_RETURN_FALSE(base::IsAsciiAlpha(c) || base::IsAsciiDigit(c) ||
c == '_' || c == '-');
}
*filename = prefs_dir_.Append(key);
diff --git a/common/prefs_unittest.cc b/common/prefs_unittest.cc
index 354b05b..967c411 100644
--- a/common/prefs_unittest.cc
+++ b/common/prefs_unittest.cc
@@ -143,17 +143,19 @@
}
TEST_F(PrefsTest, GetInt64Max) {
- ASSERT_TRUE(SetValue(kKey, base::StringPrintf("%" PRIi64, kint64max)));
+ ASSERT_TRUE(SetValue(kKey, base::StringPrintf(
+ "%" PRIi64, std::numeric_limits<uint64_t>::max())));
int64_t value;
EXPECT_TRUE(prefs_.GetInt64(kKey, &value));
- EXPECT_EQ(kint64max, value);
+ EXPECT_EQ(std::numeric_limits<uint64_t>::max(), value);
}
TEST_F(PrefsTest, GetInt64Min) {
- ASSERT_TRUE(SetValue(kKey, base::StringPrintf("%" PRIi64, kint64min)));
+ ASSERT_TRUE(SetValue(kKey, base::StringPrintf(
+ "%" PRIi64, std::numeric_limits<uint64_t>::min())));
int64_t value;
EXPECT_TRUE(prefs_.GetInt64(kKey, &value));
- EXPECT_EQ(kint64min, value);
+ EXPECT_EQ(std::numeric_limits<uint64_t>::min(), value);
}
TEST_F(PrefsTest, GetInt64Negative) {
@@ -182,17 +184,19 @@
}
TEST_F(PrefsTest, SetInt64Max) {
- EXPECT_TRUE(prefs_.SetInt64(kKey, kint64max));
+ EXPECT_TRUE(prefs_.SetInt64(kKey, std::numeric_limits<int64_t>::max()));
string value;
EXPECT_TRUE(base::ReadFileToString(prefs_dir_.Append(kKey), &value));
- EXPECT_EQ(base::StringPrintf("%" PRIi64, kint64max), value);
+ EXPECT_EQ(base::StringPrintf("%" PRIi64, std::numeric_limits<int64_t>::max()),
+ value);
}
TEST_F(PrefsTest, SetInt64Min) {
- EXPECT_TRUE(prefs_.SetInt64(kKey, kint64min));
+ EXPECT_TRUE(prefs_.SetInt64(kKey, std::numeric_limits<int64_t>::min()));
string value;
EXPECT_TRUE(base::ReadFileToString(prefs_dir_.Append(kKey), &value));
- EXPECT_EQ(base::StringPrintf("%" PRIi64, kint64min), value);
+ EXPECT_EQ(base::StringPrintf("%" PRIi64, std::numeric_limits<int64_t>::min()),
+ value);
}
TEST_F(PrefsTest, GetBooleanFalse) {
diff --git a/common/test_utils.cc b/common/test_utils.cc
index f89c448..4d1e20d 100644
--- a/common/test_utils.cc
+++ b/common/test_utils.cc
@@ -142,7 +142,8 @@
// Bind to an unused loopback device, sanity check the device name.
lo_dev_name_p->clear();
if (!(utils::ReadPipe("losetup --show -f " + filename, lo_dev_name_p) &&
- base::StartsWithASCII(*lo_dev_name_p, "/dev/loop", true))) {
+ base::StartsWith(*lo_dev_name_p, "/dev/loop",
+ base::CompareCase::SENSITIVE))) {
ADD_FAILURE();
return false;
}
diff --git a/common/utils.cc b/common/utils.cc
index f1a357b..d3b5baa 100644
--- a/common/utils.cc
+++ b/common/utils.cc
@@ -89,8 +89,9 @@
// Return true if |disk_name| is an MTD or a UBI device. Note that this test is
// simply based on the name of the device.
bool IsMtdDeviceName(const string& disk_name) {
- return base::StartsWithASCII(disk_name, "/dev/ubi", true) ||
- base::StartsWithASCII(disk_name, "/dev/mtd", true);
+ return base::StartsWith(disk_name, "/dev/ubi",
+ base::CompareCase::SENSITIVE) ||
+ base::StartsWith(disk_name, "/dev/mtd", base::CompareCase::SENSITIVE);
}
// Return the device name for the corresponding partition on a NAND device.
@@ -133,8 +134,9 @@
// base::GetTempDir() and prepends it to |path|. On success stores the full
// temporary path in |template_path| and returns true.
bool GetTempName(const string& path, base::FilePath* template_path) {
- if (path[0] == '/' || base::StartsWithASCII(path, "./", true) ||
- base::StartsWithASCII(path, "../", true)) {
+ if (path[0] == '/' ||
+ base::StartsWith(path, "./", base::CompareCase::SENSITIVE) ||
+ base::StartsWith(path, "../", base::CompareCase::SENSITIVE)) {
*template_path = base::FilePath(path);
return true;
}
@@ -432,7 +434,8 @@
bool SplitPartitionName(const string& partition_name,
string* out_disk_name,
int* out_partition_num) {
- if (!base::StartsWithASCII(partition_name, "/dev/", true)) {
+ if (!base::StartsWith(partition_name, "/dev/",
+ base::CompareCase::SENSITIVE)) {
LOG(ERROR) << "Invalid partition device name: " << partition_name;
return false;
}
@@ -486,7 +489,7 @@
return string();
}
- if (!base::StartsWithASCII(disk_name, "/dev/", true)) {
+ if (!base::StartsWith(disk_name, "/dev/", base::CompareCase::SENSITIVE)) {
LOG(ERROR) << "Invalid disk name: " << disk_name;
return string();
}