update_engine: Fix all the "using" declaration usage.
This patch removes unused "using" declarations, that is, declarations
included in a .cc file at a global scope such that "using foo::bar"
that later don't use the identifier "bar" at all.
This also unifies the usage of these identifiers in the .cc files
in favor of using the short name defined by the using declaration.
For example, in several cases the .h refer to a type like
"std::string" because using declarations are forbidden in header
files while the .cc includes "using std::string;" with the purpose
of just writting "string" in the .cc file. Very rarely, the full
identifier is used when a local name ocludes it, for example,
StringVectorToGStrv() and StringVectorToString() in utils.cc named
its argument just "vector" need to refer to std::vector with the
full name. This patch renames those arguments instead.
Finally, it also sorts a few lists of using declarations that weren't
in order.
BUG=None
TEST=FEATURES=test emerge-link update_engine
Change-Id: I30f6b9510ecb7e03640f1951c48d5bb106309840
Reviewed-on: https://chromium-review.googlesource.com/226423
Reviewed-by: Alex Vakulenko <[email protected]>
Commit-Queue: Alex Deymo <[email protected]>
Tested-by: Alex Deymo <[email protected]>
diff --git a/bzip.cc b/bzip.cc
index 744ea67..808ae89 100644
--- a/bzip.cc
+++ b/bzip.cc
@@ -8,7 +8,6 @@
#include <bzlib.h>
#include "update_engine/utils.h"
-using std::max;
using std::string;
using std::vector;
@@ -78,13 +77,13 @@
} // namespace
-bool BzipDecompress(const std::vector<char>& in, std::vector<char>* out) {
+bool BzipDecompress(const vector<char>& in, vector<char>* out) {
return BzipData<BzipBuffToBuffDecompress>(&in[0],
static_cast<int32_t>(in.size()),
out);
}
-bool BzipCompress(const std::vector<char>& in, std::vector<char>* out) {
+bool BzipCompress(const vector<char>& in, vector<char>* out) {
return BzipData<BzipBuffToBuffCompress>(&in[0], in.size(), out);
}
@@ -92,8 +91,8 @@
template<bool F(const char* const in,
const int32_t in_size,
vector<char>* const out)>
-bool BzipString(const std::string& str,
- std::vector<char>* out) {
+bool BzipString(const string& str,
+ vector<char>* out) {
TEST_AND_RETURN_FALSE(out);
vector<char> temp;
TEST_AND_RETURN_FALSE(F(str.data(),
@@ -105,13 +104,13 @@
}
} // namespace
-bool BzipCompressString(const std::string& str,
- std::vector<char>* out) {
+bool BzipCompressString(const string& str,
+ vector<char>* out) {
return BzipString<BzipData<BzipBuffToBuffCompress>>(str, out);
}
-bool BzipDecompressString(const std::string& str,
- std::vector<char>* out) {
+bool BzipDecompressString(const string& str,
+ vector<char>* out) {
return BzipString<BzipData<BzipBuffToBuffDecompress>>(str, out);
}
diff --git a/certificate_checker_unittest.cc b/certificate_checker_unittest.cc
index ef9bbd2..7ac2830 100644
--- a/certificate_checker_unittest.cc
+++ b/certificate_checker_unittest.cc
@@ -16,11 +16,11 @@
#include "update_engine/fake_system_state.h"
#include "update_engine/prefs_mock.h"
-using ::testing::_;
using ::testing::DoAll;
using ::testing::Return;
using ::testing::SetArgumentPointee;
using ::testing::SetArrayArgument;
+using ::testing::_;
using std::string;
namespace chromeos_update_engine {
diff --git a/chrome_browser_proxy_resolver.cc b/chrome_browser_proxy_resolver.cc
index e8e1a69..cd0e2a7 100644
--- a/chrome_browser_proxy_resolver.cc
+++ b/chrome_browser_proxy_resolver.cc
@@ -24,7 +24,6 @@
using base::StringTokenizer;
using std::deque;
using std::make_pair;
-using std::multimap;
using std::pair;
using std::string;
@@ -232,7 +231,7 @@
base::TrimWhitespaceASCII(token, base::TRIM_ALL, &token);
// Start by finding the first space (if any).
- std::string::iterator space;
+ string::iterator space;
for (space = token.begin(); space != token.end(); ++space) {
if (IsAsciiWhitespace(*space)) {
break;
diff --git a/chrome_browser_proxy_resolver_unittest.cc b/chrome_browser_proxy_resolver_unittest.cc
index 557fc2e..3974f3b 100644
--- a/chrome_browser_proxy_resolver_unittest.cc
+++ b/chrome_browser_proxy_resolver_unittest.cc
@@ -10,12 +10,12 @@
#include "update_engine/chrome_browser_proxy_resolver.h"
#include "update_engine/mock_dbus_wrapper.h"
-using std::deque;
-using std::string;
-using ::testing::_;
using ::testing::Return;
using ::testing::SetArgPointee;
using ::testing::StrEq;
+using ::testing::_;
+using std::deque;
+using std::string;
namespace chromeos_update_engine {
@@ -77,14 +77,14 @@
}
namespace {
-void DBusWrapperTestResolved(const std::deque<std::string>& proxies,
+void DBusWrapperTestResolved(const deque<string>& proxies,
void* data) {
EXPECT_EQ(2, proxies.size());
EXPECT_EQ("socks5://192.168.52.83:5555", proxies[0]);
EXPECT_EQ(kNoProxy, proxies[1]);
g_main_loop_quit(reinterpret_cast<GMainLoop*>(data));
}
-void DBusWrapperTestResolvedNoReply(const std::deque<std::string>& proxies,
+void DBusWrapperTestResolvedNoReply(const deque<string>& proxies,
void* data) {
EXPECT_EQ(1, proxies.size());
EXPECT_EQ(kNoProxy, proxies[0]);
diff --git a/connection_manager_unittest.cc b/connection_manager_unittest.cc
index 47adf11..748c725 100644
--- a/connection_manager_unittest.cc
+++ b/connection_manager_unittest.cc
@@ -17,11 +17,11 @@
using std::set;
using std::string;
-using testing::_;
using testing::AnyNumber;
using testing::Return;
using testing::SetArgumentPointee;
using testing::StrEq;
+using testing::_;
namespace chromeos_update_engine {
diff --git a/dbus_service.cc b/dbus_service.cc
index ccd175f..0c39340 100644
--- a/dbus_service.cc
+++ b/dbus_service.cc
@@ -24,10 +24,10 @@
using base::StringPrintf;
using chromeos::string_utils::ToString;
-using std::set;
-using std::string;
using chromeos_update_engine::AttemptUpdateFlags;
using chromeos_update_engine::kAttemptUpdateFlagNonInteractive;
+using std::set;
+using std::string;
#define UPDATE_ENGINE_SERVICE_ERROR update_engine_service_error_quark ()
#define UPDATE_ENGINE_SERVICE_TYPE_ERROR \
@@ -218,7 +218,7 @@
gchar** out_kernel_devices,
GError **error) {
auto devices = self->system_state_->update_attempter()->GetKernelDevices();
- std::string info;
+ string info;
for (const auto& device : devices) {
base::StringAppendF(&info, "%d:%s\n",
device.second ? 1 : 0, device.first.c_str());
@@ -501,7 +501,7 @@
UpdateEngineService* self,
gchar** prev_version,
GError **error) {
- std::string ver = self->system_state_->update_attempter()->GetPrevVersion();
+ string ver = self->system_state_->update_attempter()->GetPrevVersion();
*prev_version = g_strdup(ver.c_str());
return TRUE;
}
diff --git a/delta_performer.cc b/delta_performer.cc
index f2ed85f..2cd83fd 100644
--- a/delta_performer.cc
+++ b/delta_performer.cc
@@ -178,7 +178,7 @@
const size_t count = *count_p;
if (!count)
return 0; // Special case shortcut.
- size_t read_len = std::min(count, max - buffer_.size());
+ size_t read_len = min(count, max - buffer_.size());
const char* bytes_start = *bytes_p;
const char* bytes_end = bytes_start + read_len;
buffer_.insert(buffer_.end(), bytes_start, bytes_end);
@@ -309,7 +309,7 @@
DeltaPerformer::MetadataParseResult DeltaPerformer::ParsePayloadMetadata(
- const std::vector<char>& payload,
+ const vector<char>& payload,
ErrorCode* error) {
*error = ErrorCode::kSuccess;
const uint64_t manifest_offset = GetManifestOffset();
@@ -1043,7 +1043,7 @@
} while (0);
ErrorCode DeltaPerformer::VerifyPayload(
- const std::string& update_check_response_hash,
+ const string& update_check_response_hash,
const uint64_t update_check_response_size) {
// See if we should use the public RSA key in the Omaha response.
diff --git a/delta_performer_unittest.cc b/delta_performer_unittest.cc
index dd0994e..785d8b9 100644
--- a/delta_performer_unittest.cc
+++ b/delta_performer_unittest.cc
@@ -31,7 +31,6 @@
namespace chromeos_update_engine {
-using std::min;
using std::string;
using std::vector;
using testing::Return;
@@ -695,7 +694,7 @@
// Write at some number of bytes per operation. Arbitrarily chose 5.
const size_t kBytesPerWrite = 5;
for (size_t i = 0; i < state->delta.size(); i += kBytesPerWrite) {
- size_t count = min(state->delta.size() - i, kBytesPerWrite);
+ size_t count = std::min(state->delta.size() - i, kBytesPerWrite);
bool write_succeeded = ((*performer)->Write(&state->delta[i],
count,
&actual_error));
diff --git a/download_action.cc b/download_action.cc
index 6871f60..e51549e 100644
--- a/download_action.cc
+++ b/download_action.cc
@@ -18,11 +18,9 @@
#include "update_engine/subprocess.h"
#include "update_engine/utils.h"
-using std::min;
+using base::FilePath;
using std::string;
using std::vector;
-using base::FilePath;
-using base::StringPrintf;
namespace chromeos_update_engine {
@@ -50,7 +48,7 @@
}
if (delete_p2p_file) {
- base::FilePath path =
+ FilePath path =
system_state_->p2p_manager()->FileGetPath(p2p_file_id_);
if (unlink(path.value().c_str()) != 0) {
PLOG(ERROR) << "Error deleting p2p file " << path.value();
@@ -74,7 +72,7 @@
// File has already been created (and allocated, xattrs been
// populated etc.) by FileShare() so just open it for writing.
- base::FilePath path = p2p_manager->FileGetPath(p2p_file_id_);
+ FilePath path = p2p_manager->FileGetPath(p2p_file_id_);
p2p_sharing_fd_ = open(path.value().c_str(), O_WRONLY);
if (p2p_sharing_fd_ == -1) {
PLOG(ERROR) << "Error opening file " << path.value();
@@ -202,7 +200,7 @@
// hash. If this is the case, we NEED to clean it up otherwise
// we're essentially timing out other peers downloading from us
// (since we're never going to complete the file).
- base::FilePath path = system_state_->p2p_manager()->FileGetPath(file_id);
+ FilePath path = system_state_->p2p_manager()->FileGetPath(file_id);
if (!path.empty()) {
if (unlink(path.value().c_str()) != 0) {
PLOG(ERROR) << "Error deleting p2p file " << path.value();
diff --git a/download_action_unittest.cc b/download_action_unittest.cc
index 0bdeacf..705d759 100644
--- a/download_action_unittest.cc
+++ b/download_action_unittest.cc
@@ -27,16 +27,15 @@
namespace chromeos_update_engine {
+using base::FilePath;
+using base::ReadFileToString;
+using base::WriteFile;
using std::string;
using std::unique_ptr;
using std::vector;
-using testing::_;
using testing::AtLeast;
using testing::InSequence;
-using base::FilePath;
-using base::ReadFileToString;
-using base::StringPrintf;
-using base::WriteFile;
+using testing::_;
class DownloadActionTest : public ::testing::Test { };
diff --git a/extent_ranges.cc b/extent_ranges.cc
index 7cdce41..326dbbd 100644
--- a/extent_ranges.cc
+++ b/extent_ranges.cc
@@ -13,8 +13,6 @@
#include "update_engine/payload_constants.h"
-using std::max;
-using std::min;
using std::set;
using std::vector;
@@ -57,9 +55,9 @@
Extent UnionOverlappingExtents(const Extent& first, const Extent& second) {
CHECK_NE(kSparseHole, first.start_block());
CHECK_NE(kSparseHole, second.start_block());
- uint64_t start = min(first.start_block(), second.start_block());
- uint64_t end = max(first.start_block() + first.num_blocks(),
- second.start_block() + second.num_blocks());
+ uint64_t start = std::min(first.start_block(), second.start_block());
+ uint64_t end = std::max(first.start_block() + first.num_blocks(),
+ second.start_block() + second.num_blocks());
return ExtentForRange(start, end - start);
}
@@ -198,7 +196,7 @@
return ret;
}
-std::vector<Extent> ExtentRanges::GetExtentsForBlockCount(
+vector<Extent> ExtentRanges::GetExtentsForBlockCount(
uint64_t count) const {
vector<Extent> out;
if (count == 0)
diff --git a/fake_prefs.cc b/fake_prefs.cc
index 653104e..64ff18a 100644
--- a/fake_prefs.cc
+++ b/fake_prefs.cc
@@ -6,7 +6,6 @@
#include <gtest/gtest.h>
-using std::map;
using std::string;
using chromeos_update_engine::FakePrefs;
@@ -49,7 +48,7 @@
return GetValue(key, value);
}
-bool FakePrefs::SetString(const std::string& key, const std::string& value) {
+bool FakePrefs::SetString(const string& key, const string& value) {
SetValue(key, value);
return true;
}
@@ -63,7 +62,7 @@
return true;
}
-bool FakePrefs::GetBoolean(const std::string& key, bool* value) {
+bool FakePrefs::GetBoolean(const string& key, bool* value) {
return GetValue(key, value);
}
diff --git a/fake_system_state.cc b/fake_system_state.cc
index 8dec9f5..8747a59 100644
--- a/fake_system_state.cc
+++ b/fake_system_state.cc
@@ -4,10 +4,6 @@
#include "update_engine/fake_system_state.h"
-#include "update_engine/update_manager/fake_state.h"
-
-using chromeos_update_manager::FakeState;
-
namespace chromeos_update_engine {
// Mock the SystemStateInterface so that we could lie that
diff --git a/filesystem_copier_action.cc b/filesystem_copier_action.cc
index a8f56e9..7346a99 100644
--- a/filesystem_copier_action.cc
+++ b/filesystem_copier_action.cc
@@ -27,7 +27,6 @@
#include "update_engine/utils.h"
using std::map;
-using std::min;
using std::string;
using std::vector;
diff --git a/hardware.cc b/hardware.cc
index fd774ca..a9f0b25 100644
--- a/hardware.cc
+++ b/hardware.cc
@@ -65,12 +65,12 @@
return utils::IsRemovableDevice(utils::GetDiskName(BootDevice()));
}
-bool Hardware::IsKernelBootable(const std::string& kernel_device,
+bool Hardware::IsKernelBootable(const string& kernel_device,
bool* bootable) const {
CgptAddParams params;
memset(¶ms, '\0', sizeof(params));
- std::string disk_name;
+ string disk_name;
int partition_num = 0;
if (!utils::SplitPartitionName(kernel_device, &disk_name, &partition_num))
@@ -87,18 +87,18 @@
return true;
}
-std::vector<std::string> Hardware::GetKernelDevices() const {
+vector<string> Hardware::GetKernelDevices() const {
LOG(INFO) << "GetAllKernelDevices";
- std::string disk_name = utils::GetDiskName(Hardware::BootKernelDevice());
+ string disk_name = utils::GetDiskName(Hardware::BootKernelDevice());
if (disk_name.empty()) {
LOG(ERROR) << "Failed to get the current kernel boot disk name";
- return std::vector<std::string>();
+ return vector<string>();
}
- std::vector<std::string> devices;
+ vector<string> devices;
for (int partition_num : {2, 4}) { // for now, only #2, #4 for slot A & B
- std::string device = utils::MakePartitionName(disk_name, partition_num);
+ string device = utils::MakePartitionName(disk_name, partition_num);
if (!device.empty()) {
devices.push_back(std::move(device));
} else {
@@ -111,7 +111,7 @@
}
-bool Hardware::MarkKernelUnbootable(const std::string& kernel_device) {
+bool Hardware::MarkKernelUnbootable(const string& kernel_device) {
LOG(INFO) << "MarkPartitionUnbootable: " << kernel_device;
if (kernel_device == BootKernelDevice()) {
@@ -119,7 +119,7 @@
return false;
}
- std::string disk_name;
+ string disk_name;
int partition_num = 0;
if (!utils::SplitPartitionName(kernel_device, &disk_name, &partition_num))
diff --git a/http_fetcher.cc b/http_fetcher.cc
index 91aa177..3caadf0 100644
--- a/http_fetcher.cc
+++ b/http_fetcher.cc
@@ -48,7 +48,7 @@
this);
}
-void HttpFetcher::ProxiesResolved(const std::deque<std::string>& proxies) {
+void HttpFetcher::ProxiesResolved(const deque<string>& proxies) {
no_resolver_idle_id_ = 0;
if (!proxies.empty())
SetProxies(proxies);
diff --git a/http_fetcher_unittest.cc b/http_fetcher_unittest.cc
index 0e67ce9..ff52dfb 100644
--- a/http_fetcher_unittest.cc
+++ b/http_fetcher_unittest.cc
@@ -34,11 +34,6 @@
using std::unique_ptr;
using std::vector;
-using base::TimeDelta;
-using testing::DoAll;
-using testing::Return;
-using testing::SetArgumentPointee;
-using testing::_;
namespace {
@@ -941,7 +936,7 @@
multi_fetcher->ClearRanges();
for (vector<pair<off_t, off_t>>::const_iterator it = ranges.begin(),
e = ranges.end(); it != e; ++it) {
- std::string tmp_str = base::StringPrintf("%jd+", it->first);
+ string tmp_str = base::StringPrintf("%jd+", it->first);
if (it->second > 0) {
base::StringAppendF(&tmp_str, "%jd", it->second);
multi_fetcher->AddRange(it->first, it->second);
diff --git a/hwid_override.cc b/hwid_override.cc
index 0ec949f..258a997 100644
--- a/hwid_override.cc
+++ b/hwid_override.cc
@@ -22,7 +22,7 @@
HwidOverride::~HwidOverride() {}
-std::string HwidOverride::Read(const base::FilePath& root) {
+string HwidOverride::Read(const base::FilePath& root) {
chromeos::KeyValueStore lsb_release;
lsb_release.Load(base::FilePath(root.value() + "/etc/lsb-release"));
string result;
diff --git a/install_plan.cc b/install_plan.cc
index 4ae0de2..11fe4c3 100644
--- a/install_plan.cc
+++ b/install_plan.cc
@@ -21,7 +21,7 @@
const string& metadata_signature,
const string& install_path,
const string& kernel_install_path,
- const std::string& public_key_rsa)
+ const string& public_key_rsa)
: is_resume(is_resume),
is_full_update(is_full_update),
download_url(url),
diff --git a/libcurl_http_fetcher.cc b/libcurl_http_fetcher.cc
index 64680c1..42e9e42 100644
--- a/libcurl_http_fetcher.cc
+++ b/libcurl_http_fetcher.cc
@@ -36,7 +36,7 @@
CleanUp();
}
-bool LibcurlHttpFetcher::GetProxyType(const std::string& proxy,
+bool LibcurlHttpFetcher::GetProxyType(const string& proxy,
curl_proxytype* out_type) {
if (utils::StringHasPrefix(proxy, "socks5://") ||
utils::StringHasPrefix(proxy, "socks://")) {
@@ -60,7 +60,7 @@
return false;
}
-void LibcurlHttpFetcher::ResumeTransfer(const std::string& url) {
+void LibcurlHttpFetcher::ResumeTransfer(const string& url) {
LOG(INFO) << "Starting/Resuming transfer";
CHECK(!transfer_in_progress_);
url_ = url;
@@ -131,10 +131,10 @@
}
// Create a string representation of the desired range.
- std::string range_str = (end_offset ?
- base::StringPrintf("%jd-%zu", resume_offset_,
- end_offset) :
- base::StringPrintf("%jd-", resume_offset_));
+ string range_str = (end_offset ?
+ base::StringPrintf("%jd-%zu", resume_offset_,
+ end_offset) :
+ base::StringPrintf("%jd-", resume_offset_));
CHECK_EQ(curl_easy_setopt(curl_handle_, CURLOPT_RANGE, range_str.c_str()),
CURLE_OK);
}
@@ -219,7 +219,7 @@
// Begins the transfer, which must not have already been started.
-void LibcurlHttpFetcher::BeginTransfer(const std::string& url) {
+void LibcurlHttpFetcher::BeginTransfer(const string& url) {
CHECK(!transfer_in_progress_);
url_ = url;
auto closure = base::Bind(&LibcurlHttpFetcher::ProxiesResolved,
diff --git a/omaha_hash_calculator.cc b/omaha_hash_calculator.cc
index af39611..9899d59 100644
--- a/omaha_hash_calculator.cc
+++ b/omaha_hash_calculator.cc
@@ -230,7 +230,7 @@
return string(reinterpret_cast<const char*>(&ctx_), sizeof(ctx_));
}
-bool OmahaHashCalculator::SetContext(const std::string& context) {
+bool OmahaHashCalculator::SetContext(const string& context) {
TEST_AND_RETURN_FALSE(context.size() == sizeof(ctx_));
memcpy(&ctx_, context.data(), sizeof(ctx_));
return true;
diff --git a/omaha_request_action_unittest.cc b/omaha_request_action_unittest.cc
index 872b83b..775f074 100644
--- a/omaha_request_action_unittest.cc
+++ b/omaha_request_action_unittest.cc
@@ -30,15 +30,15 @@
using base::TimeDelta;
using std::string;
using std::vector;
-using testing::_;
using testing::AllOf;
+using testing::AnyNumber;
using testing::DoAll;
using testing::Ge;
using testing::Le;
using testing::NiceMock;
using testing::Return;
using testing::SetArgumentPointee;
-using testing::AnyNumber;
+using testing::_;
namespace chromeos_update_engine {
@@ -80,7 +80,7 @@
void PingTest(bool ping_only);
// InstallDate test helper function.
- bool InstallDateParseHelper(const std::string &elapsed_days,
+ bool InstallDateParseHelper(const string &elapsed_days,
OmahaResponse *response);
// P2P test helper function.
@@ -273,10 +273,10 @@
CHECK(false);
}
// Debugging/logging
- static std::string StaticType() {
+ static string StaticType() {
return "OutputObjectCollectorAction";
}
- std::string Type() const { return StaticType(); }
+ string Type() const { return StaticType(); }
bool has_input_object_;
OmahaResponse omaha_response_;
};
@@ -2057,9 +2057,8 @@
""); // expected_p2p_url
}
-bool OmahaRequestActionTest::InstallDateParseHelper(
- const std::string &elapsed_days,
- OmahaResponse *response) {
+bool OmahaRequestActionTest::InstallDateParseHelper(const string &elapsed_days,
+ OmahaResponse *response) {
return
TestUpdateCheck(nullptr, // request_params
GetUpdateResponse2(OmahaRequestParams::kAppId,
diff --git a/omaha_request_params.cc b/omaha_request_params.cc
index 2a4a0ea..7cef85a 100644
--- a/omaha_request_params.cc
+++ b/omaha_request_params.cc
@@ -50,8 +50,8 @@
"stable-channel",
};
-bool OmahaRequestParams::Init(const std::string& in_app_version,
- const std::string& in_update_url,
+bool OmahaRequestParams::Init(const string& in_app_version,
+ const string& in_update_url,
bool in_interactive) {
LOG(INFO) << "Initializing parameters for this update attempt";
InitFromLsbValue();
@@ -124,7 +124,7 @@
};
}
-bool OmahaRequestParams::SetTargetChannel(const std::string& new_target_channel,
+bool OmahaRequestParams::SetTargetChannel(const string& new_target_channel,
bool is_powerwash_allowed) {
LOG(INFO) << "SetTargetChannel called with " << new_target_channel
<< ", Is Powerwash Allowed = "
@@ -249,11 +249,11 @@
system_state_->hardware()->IsNormalBootMode();
}
-bool OmahaRequestParams::IsValidChannel(const std::string& channel) const {
+bool OmahaRequestParams::IsValidChannel(const string& channel) const {
return GetChannelIndex(channel) >= 0;
}
-void OmahaRequestParams::set_root(const std::string& root) {
+void OmahaRequestParams::set_root(const string& root) {
root_ = root;
InitFromLsbValue();
}
@@ -263,7 +263,7 @@
forced_lock_down_ = lock;
}
-int OmahaRequestParams::GetChannelIndex(const std::string& channel) const {
+int OmahaRequestParams::GetChannelIndex(const string& channel) const {
for (size_t t = 0; t < arraysize(kChannelsByStability); ++t)
if (channel == kChannelsByStability[t])
return t;
diff --git a/omaha_response_handler_action_unittest.cc b/omaha_response_handler_action_unittest.cc
index 46ff653..242cf61 100644
--- a/omaha_response_handler_action_unittest.cc
+++ b/omaha_response_handler_action_unittest.cc
@@ -13,7 +13,6 @@
#include "update_engine/utils.h"
using std::string;
-using testing::NiceMock;
using testing::Return;
namespace chromeos_update_engine {
diff --git a/p2p_manager.cc b/p2p_manager.cc
index 9f0db53..240b44a 100644
--- a/p2p_manager.cc
+++ b/p2p_manager.cc
@@ -66,8 +66,8 @@
virtual ~ConfigurationImpl() {}
- virtual base::FilePath GetP2PDir() {
- return base::FilePath(kDefaultP2PDir);
+ virtual FilePath GetP2PDir() {
+ return FilePath(kDefaultP2PDir);
}
virtual vector<string> GetInitctlArgs(bool is_start) {
@@ -83,7 +83,7 @@
vector<string> args;
args.push_back("p2p-client");
args.push_back(string("--get-url=") + file_id);
- args.push_back(base::StringPrintf("--minimum-size=%zu", minimum_size));
+ args.push_back(StringPrintf("--minimum-size=%zu", minimum_size));
return args;
}
@@ -111,7 +111,7 @@
LookupCallback callback);
virtual bool FileShare(const string& file_id,
size_t expected_size);
- virtual base::FilePath FileGetPath(const string& file_id);
+ virtual FilePath FileGetPath(const string& file_id);
virtual ssize_t FileGetSize(const string& file_id);
virtual ssize_t FileGetExpectedSize(const string& file_id);
virtual bool FileGetVisible(const string& file_id,
@@ -133,7 +133,7 @@
// Gets the on-disk path for |file_id| depending on if the file
// is visible or not.
- base::FilePath GetPath(const string& file_id, Visibility visibility);
+ FilePath GetPath(const string& file_id, Visibility visibility);
// Utility function used by EnsureP2PRunning() and EnsureP2PNotRunning().
bool EnsureP2P(bool should_be_running);
@@ -326,7 +326,7 @@
// Go through all files in the p2p dir and pick the ones that match
// and get their ctime.
- base::FilePath p2p_dir = configuration_->GetP2PDir();
+ FilePath p2p_dir = configuration_->GetP2PDir();
dir = g_dir_open(p2p_dir.value().c_str(), 0, &error);
if (dir == nullptr) {
LOG(ERROR) << "Error opening directory " << p2p_dir.value() << ": "
@@ -345,7 +345,7 @@
continue;
struct stat statbuf;
- base::FilePath file = p2p_dir.Append(name);
+ FilePath file = p2p_dir.Append(name);
if (stat(file.value().c_str(), &statbuf) != 0) {
PLOG(ERROR) << "Error getting file status for " << file.value();
continue;
@@ -362,7 +362,7 @@
// Delete starting at element num_files_to_keep_.
vector<pair<FilePath, Time>>::const_iterator i;
for (i = matches.begin() + num_files_to_keep_; i < matches.end(); ++i) {
- const base::FilePath& file = i->first;
+ const FilePath& file = i->first;
LOG(INFO) << "Deleting p2p file " << file.value();
if (unlink(file.value().c_str()) != 0) {
PLOG(ERROR) << "Error deleting p2p file " << file.value();
@@ -568,7 +568,7 @@
bool P2PManagerImpl::FileShare(const string& file_id,
size_t expected_size) {
// Check if file already exist.
- base::FilePath path = FileGetPath(file_id);
+ FilePath path = FileGetPath(file_id);
if (!path.empty()) {
// File exists - double check its expected size though.
ssize_t file_expected_size = FileGetExpectedSize(file_id);
@@ -586,7 +586,7 @@
// Before creating the file, bail if statvfs(3) indicates that at
// least twice the size is not available in P2P_DIR.
struct statvfs statvfsbuf;
- base::FilePath p2p_dir = configuration_->GetP2PDir();
+ FilePath p2p_dir = configuration_->GetP2PDir();
if (statvfs(p2p_dir.value().c_str(), &statvfsbuf) != 0) {
PLOG(ERROR) << "Error calling statvfs() for dir " << p2p_dir.value();
return false;
@@ -636,7 +636,7 @@
}
}
- string decimal_size = base::StringPrintf("%zu", expected_size);
+ string decimal_size = StringPrintf("%zu", expected_size);
if (fsetxattr(fd, kCrosP2PFileSizeXAttrName,
decimal_size.c_str(), decimal_size.size(), 0) != 0) {
PLOG(ERROR) << "Error setting xattr " << path.value();
@@ -649,7 +649,7 @@
FilePath P2PManagerImpl::FileGetPath(const string& file_id) {
struct stat statbuf;
- base::FilePath path;
+ FilePath path;
path = GetPath(file_id, kVisible);
if (stat(path.value().c_str(), &statbuf) == 0) {
@@ -667,7 +667,7 @@
bool P2PManagerImpl::FileGetVisible(const string& file_id,
bool *out_result) {
- base::FilePath path = FileGetPath(file_id);
+ FilePath path = FileGetPath(file_id);
if (path.empty()) {
LOG(ERROR) << "No file for id " << file_id;
return false;
@@ -678,7 +678,7 @@
}
bool P2PManagerImpl::FileMakeVisible(const string& file_id) {
- base::FilePath path = FileGetPath(file_id);
+ FilePath path = FileGetPath(file_id);
if (path.empty()) {
LOG(ERROR) << "No file for id " << file_id;
return false;
@@ -689,7 +689,7 @@
return true;
LOG_ASSERT(path.MatchesExtension(kTmpExtension));
- base::FilePath new_path = path.RemoveExtension();
+ FilePath new_path = path.RemoveExtension();
LOG_ASSERT(new_path.MatchesExtension(kP2PExtension));
if (rename(path.value().c_str(), new_path.value().c_str()) != 0) {
PLOG(ERROR) << "Error renaming " << path.value()
@@ -701,7 +701,7 @@
}
ssize_t P2PManagerImpl::FileGetSize(const string& file_id) {
- base::FilePath path = FileGetPath(file_id);
+ FilePath path = FileGetPath(file_id);
if (path.empty())
return -1;
@@ -709,7 +709,7 @@
}
ssize_t P2PManagerImpl::FileGetExpectedSize(const string& file_id) {
- base::FilePath path = FileGetPath(file_id);
+ FilePath path = FileGetPath(file_id);
if (path.empty())
return -1;
@@ -740,7 +740,7 @@
const char* name;
int num_files = 0;
- base::FilePath p2p_dir = configuration_->GetP2PDir();
+ FilePath p2p_dir = configuration_->GetP2PDir();
dir = g_dir_open(p2p_dir.value().c_str(), 0, &error);
if (dir == nullptr) {
LOG(ERROR) << "Error opening directory " << p2p_dir.value() << ": "
diff --git a/p2p_manager_unittest.cc b/p2p_manager_unittest.cc
index fb582f9..9af5458 100644
--- a/p2p_manager_unittest.cc
+++ b/p2p_manager_unittest.cc
@@ -27,10 +27,9 @@
#include "update_engine/test_utils.h"
#include "update_engine/utils.h"
+using base::TimeDelta;
using std::string;
using std::unique_ptr;
-using std::vector;
-using base::TimeDelta;
namespace chromeos_update_engine {
@@ -159,7 +158,7 @@
new policy::MockDevicePolicy());
// We return an empty owner as this is an enterprise.
EXPECT_CALL(*device_policy, GetOwner(testing::_)).WillRepeatedly(
- DoAll(testing::SetArgumentPointee<0>(std::string("")),
+ DoAll(testing::SetArgumentPointee<0>(string("")),
testing::Return(true)));
manager->SetDevicePolicy(device_policy.get());
EXPECT_TRUE(manager->IsP2PEnabled());
@@ -184,7 +183,7 @@
new policy::MockDevicePolicy());
// We return an empty owner as this is an enterprise.
EXPECT_CALL(*device_policy, GetOwner(testing::_)).WillRepeatedly(
- DoAll(testing::SetArgumentPointee<0>(std::string("")),
+ DoAll(testing::SetArgumentPointee<0>(string("")),
testing::Return(true)));
// Make Enterprise Policy indicate p2p is not enabled.
EXPECT_CALL(*device_policy, GetAuP2PEnabled(testing::_)).WillRepeatedly(
diff --git a/payload_generator/cycle_breaker.cc b/payload_generator/cycle_breaker.cc
index b4c14a9..906502d 100644
--- a/payload_generator/cycle_breaker.cc
+++ b/payload_generator/cycle_breaker.cc
@@ -94,7 +94,7 @@
void CycleBreaker::HandleCircuit() {
stack_.push_back(current_vertex_);
CHECK_GE(stack_.size(),
- static_cast<std::vector<Vertex::Index>::size_type>(2));
+ static_cast<vector<Vertex::Index>::size_type>(2));
Edge min_edge = make_pair(stack_[0], stack_[1]);
uint64_t min_edge_weight = kuint64max;
size_t edges_considered = 0;
@@ -131,7 +131,7 @@
}
bool CycleBreaker::StackContainsCutEdge() const {
- for (std::vector<Vertex::Index>::const_iterator it = ++stack_.begin(),
+ for (vector<Vertex::Index>::const_iterator it = ++stack_.begin(),
e = stack_.end(); it != e; ++it) {
Edge edge = make_pair(*(it - 1), *it);
if (utils::SetContainsKey(cut_edges_, edge)) {
diff --git a/payload_generator/delta_diff_generator.cc b/payload_generator/delta_diff_generator.cc
index 60755db..337b1aa 100644
--- a/payload_generator/delta_diff_generator.cc
+++ b/payload_generator/delta_diff_generator.cc
@@ -92,8 +92,8 @@
// Needed for testing purposes, in case we can't use actual filesystem objects.
// TODO(garnold) (chromium:331965) Replace this hack with a properly injected
// parameter in form of a mockable abstract class.
-bool (*get_extents_with_chunk_func)(const std::string&, off_t, off_t,
- std::vector<Extent>*) =
+bool (*get_extents_with_chunk_func)(const string&, off_t, off_t,
+ vector<Extent>*) =
extent_mapper::ExtentsForFileChunkFibmap;
namespace {
@@ -1379,8 +1379,8 @@
bool DeltaDiffGenerator::ReorderDataBlobs(
DeltaArchiveManifest* manifest,
- const std::string& data_blobs_path,
- const std::string& new_data_blobs_path) {
+ const string& data_blobs_path,
+ const string& new_data_blobs_path) {
int in_fd = open(data_blobs_path.c_str(), O_RDONLY, 0);
TEST_AND_RETURN_FALSE_ERRNO(in_fd >= 0);
ScopedFdCloser in_fd_closer(&in_fd);
diff --git a/payload_generator/delta_diff_generator_unittest.cc b/payload_generator/delta_diff_generator_unittest.cc
index 85d041c..c1bee61 100644
--- a/payload_generator/delta_diff_generator_unittest.cc
+++ b/payload_generator/delta_diff_generator_unittest.cc
@@ -32,7 +32,6 @@
#include "update_engine/test_utils.h"
#include "update_engine/utils.h"
-using std::make_pair;
using std::set;
using std::string;
using std::stringstream;
@@ -42,8 +41,8 @@
typedef DeltaDiffGenerator::Block Block;
-typedef bool (*GetExtentsWithChunk)(const std::string&, off_t, off_t,
- std::vector<Extent>*);
+typedef bool (*GetExtentsWithChunk)(const string&, off_t, off_t,
+ vector<Extent>*);
extern GetExtentsWithChunk get_extents_with_chunk_func;
namespace {
@@ -653,7 +652,7 @@
template<typename T>
void DumpVect(const vector<T>& vect) {
- std::stringstream ss(stringstream::out);
+ stringstream ss(stringstream::out);
for (typename vector<T>::const_iterator it = vect.begin(), e = vect.end();
it != e; ++it) {
ss << *it << ", ";
diff --git a/payload_generator/extent_mapper.cc b/payload_generator/extent_mapper.cc
index 5e363c7..ce490d2 100644
--- a/payload_generator/extent_mapper.cc
+++ b/payload_generator/extent_mapper.cc
@@ -32,10 +32,10 @@
const int kBlockSize = 4096;
}
-bool ExtentsForFileChunkFibmap(const std::string& path,
+bool ExtentsForFileChunkFibmap(const string& path,
off_t chunk_offset,
off_t chunk_size,
- std::vector<Extent>* out) {
+ vector<Extent>* out) {
CHECK(out);
CHECK_EQ(0, chunk_offset % kBlockSize);
CHECK(chunk_size == -1 || chunk_size >= 0);
@@ -76,11 +76,11 @@
return true;
}
-bool ExtentsForFileFibmap(const std::string& path, std::vector<Extent>* out) {
+bool ExtentsForFileFibmap(const string& path, vector<Extent>* out) {
return ExtentsForFileChunkFibmap(path, 0, -1, out);
}
-bool GetFilesystemBlockSize(const std::string& path, uint32_t* out_blocksize) {
+bool GetFilesystemBlockSize(const string& path, uint32_t* out_blocksize) {
int fd = open(path.c_str(), O_RDONLY, 0);
TEST_AND_RETURN_FALSE_ERRNO(fd >= 0);
ScopedFdCloser fd_closer(&fd);
diff --git a/payload_generator/filesystem_iterator.cc b/payload_generator/filesystem_iterator.cc
index edede08..9646092 100644
--- a/payload_generator/filesystem_iterator.cc
+++ b/payload_generator/filesystem_iterator.cc
@@ -40,8 +40,8 @@
} while (0)
FilesystemIterator::FilesystemIterator(
- const std::string& path,
- const std::set<std::string>& excl_prefixes)
+ const string& path,
+ const set<string>& excl_prefixes)
: excl_prefixes_(excl_prefixes),
is_end_(false),
is_err_(false) {
@@ -62,12 +62,12 @@
}
// Returns full path for current file
-std::string FilesystemIterator::GetFullPath() const {
+string FilesystemIterator::GetFullPath() const {
return root_path_ + GetPartialPath();
}
-std::string FilesystemIterator::GetPartialPath() const {
- std::string ret;
+string FilesystemIterator::GetPartialPath() const {
+ string ret;
for (vector<string>::const_iterator it = names_.begin();
it != names_.end(); ++it) {
ret += "/";
diff --git a/payload_generator/full_update_generator.cc b/payload_generator/full_update_generator.cc
index b4594a5..2b114f7 100644
--- a/payload_generator/full_update_generator.cc
+++ b/payload_generator/full_update_generator.cc
@@ -18,8 +18,6 @@
#include "update_engine/utils.h"
using std::deque;
-using std::max;
-using std::min;
using std::shared_ptr;
using std::string;
using std::vector;
@@ -111,19 +109,19 @@
bool FullUpdateGenerator::Run(
Graph* graph,
- const std::string& new_kernel_part,
- const std::string& new_image,
+ const string& new_kernel_part,
+ const string& new_image,
off_t image_size,
int fd,
off_t* data_file_size,
off_t chunk_size,
off_t block_size,
vector<DeltaArchiveManifest_InstallOperation>* kernel_ops,
- std::vector<Vertex::Index>* final_order) {
+ vector<Vertex::Index>* final_order) {
TEST_AND_RETURN_FALSE(chunk_size > 0);
TEST_AND_RETURN_FALSE((chunk_size % block_size) == 0);
- size_t max_threads = max(sysconf(_SC_NPROCESSORS_ONLN), 4L);
+ size_t max_threads = std::max(sysconf(_SC_NPROCESSORS_ONLN), 4L);
LOG(INFO) << "Max threads: " << max_threads;
// Get the sizes early in the function, so we can fail fast if the user
@@ -149,7 +147,8 @@
// Check and start new chunk processors if possible.
while (threads.size() < max_threads && bytes_left > 0) {
shared_ptr<ChunkProcessor> processor(
- new ChunkProcessor(in_fd, offset, min(bytes_left, chunk_size)));
+ new ChunkProcessor(in_fd, offset,
+ std::min(bytes_left, chunk_size)));
threads.push_back(processor);
TEST_AND_RETURN_FALSE(processor->Start());
bytes_left -= chunk_size;
diff --git a/payload_generator/graph_utils.cc b/payload_generator/graph_utils.cc
index a0ce802..dd0c873 100644
--- a/payload_generator/graph_utils.cc
+++ b/payload_generator/graph_utils.cc
@@ -105,7 +105,7 @@
}
}
-Extent GetElement(const std::vector<Extent>& collection, size_t index) {
+Extent GetElement(const vector<Extent>& collection, size_t index) {
return collection[index];
}
Extent GetElement(
diff --git a/payload_generator/tarjan_unittest.cc b/payload_generator/tarjan_unittest.cc
index 552c32e..76f5f2c 100644
--- a/payload_generator/tarjan_unittest.cc
+++ b/payload_generator/tarjan_unittest.cc
@@ -14,8 +14,6 @@
#include "update_engine/utils.h"
using std::make_pair;
-using std::pair;
-using std::set;
using std::string;
using std::vector;
diff --git a/payload_state.cc b/payload_state.cc
index fcd4dab..4ce3d67 100644
--- a/payload_state.cc
+++ b/payload_state.cc
@@ -577,8 +577,8 @@
int64_t payload_bytes_downloaded = attempt_num_bytes_downloaded_;
ClockInterface *clock = system_state_->clock();
- base::TimeDelta duration = clock->GetBootTime() - attempt_start_time_boot_;
- base::TimeDelta duration_uptime = clock->GetMonotonicTime() -
+ TimeDelta duration = clock->GetBootTime() - attempt_start_time_boot_;
+ TimeDelta duration_uptime = clock->GetMonotonicTime() -
attempt_start_time_monotonic_;
int64_t payload_download_speed_bps = 0;
@@ -789,7 +789,7 @@
metric = "Installer.DownloadSourcesUsed";
LOG(INFO) << "Uploading 0x" << std::hex << download_sources_used
<< " (bit flags) for metric " << metric;
- int num_buckets = std::min(1 << kNumDownloadSources, kNumDefaultUmaBuckets);
+ int num_buckets = min(1 << kNumDownloadSources, kNumDefaultUmaBuckets);
system_state_->metrics_lib()->SendToUMA(metric,
download_sources_used,
0, // min
@@ -906,7 +906,7 @@
ResetRollbackVersion();
SetP2PNumAttempts(0);
SetP2PFirstAttemptTimestamp(Time()); // Set to null time
- SetScatteringWaitPeriod(base::TimeDelta());
+ SetScatteringWaitPeriod(TimeDelta());
}
void PayloadState::ResetRollbackVersion() {
@@ -1031,7 +1031,7 @@
TimeDelta::FromSeconds(GetPersistedValue(kPrefsWallClockWaitPeriod)));
}
-void PayloadState::SetScatteringWaitPeriod(base::TimeDelta wait_period) {
+void PayloadState::SetScatteringWaitPeriod(TimeDelta wait_period) {
CHECK(prefs_);
scattering_wait_period_ = wait_period;
LOG(INFO) << "Scattering Wait Period (seconds) = "
diff --git a/payload_state_unittest.cc b/payload_state_unittest.cc
index 27ee22c..cec69f1 100644
--- a/payload_state_unittest.cc
+++ b/payload_state_unittest.cc
@@ -25,13 +25,13 @@
using base::Time;
using base::TimeDelta;
using std::string;
-using testing::_;
using testing::AnyNumber;
using testing::AtLeast;
using testing::Mock;
using testing::NiceMock;
using testing::Return;
using testing::SetArgumentPointee;
+using testing::_;
namespace chromeos_update_engine {
diff --git a/payload_verifier.cc b/payload_verifier.cc
index 91cb42a..2f821ea 100644
--- a/payload_verifier.cc
+++ b/payload_verifier.cc
@@ -98,18 +98,18 @@
return true;
}
-bool PayloadVerifier::VerifySignature(const std::vector<char>& signature_blob,
- const std::string& public_key_path,
- std::vector<char>* out_hash_data) {
+bool PayloadVerifier::VerifySignature(const vector<char>& signature_blob,
+ const string& public_key_path,
+ vector<char>* out_hash_data) {
return VerifySignatureBlob(signature_blob, public_key_path,
kSignatureMessageCurrentVersion, out_hash_data);
}
bool PayloadVerifier::VerifySignatureBlob(
- const std::vector<char>& signature_blob,
- const std::string& public_key_path,
+ const vector<char>& signature_blob,
+ const string& public_key_path,
uint32_t client_version,
- std::vector<char>* out_hash_data) {
+ vector<char>* out_hash_data) {
TEST_AND_RETURN_FALSE(!public_key_path.empty());
Signatures signatures;
@@ -136,9 +136,9 @@
bool PayloadVerifier::GetRawHashFromSignature(
- const std::vector<char>& sig_data,
- const std::string& public_key_path,
- std::vector<char>* out_hash_data) {
+ const vector<char>& sig_data,
+ const string& public_key_path,
+ vector<char>* out_hash_data) {
TEST_AND_RETURN_FALSE(!public_key_path.empty());
// The code below executes the equivalent of:
@@ -180,8 +180,8 @@
return true;
}
-bool PayloadVerifier::VerifySignedPayload(const std::string& payload_path,
- const std::string& public_key_path,
+bool PayloadVerifier::VerifySignedPayload(const string& payload_path,
+ const string& public_key_path,
uint32_t client_key_check_version) {
vector<char> payload;
DeltaArchiveManifest manifest;
@@ -208,7 +208,7 @@
return true;
}
-bool PayloadVerifier::PadRSA2048SHA256Hash(std::vector<char>* hash) {
+bool PayloadVerifier::PadRSA2048SHA256Hash(vector<char>* hash) {
TEST_AND_RETURN_FALSE(hash->size() == 32);
hash->insert(hash->begin(),
reinterpret_cast<const char*>(kRSA2048SHA256Padding),
diff --git a/prefs.cc b/prefs.cc
index ca8749b..5b91939 100644
--- a/prefs.cc
+++ b/prefs.cc
@@ -30,7 +30,7 @@
return true;
}
-bool Prefs::SetString(const std::string& key, const std::string& value) {
+bool Prefs::SetString(const string& key, const string& value) {
base::FilePath filename;
TEST_AND_RETURN_FALSE(GetFileNameForKey(key, &filename));
TEST_AND_RETURN_FALSE(base::CreateDirectory(filename.DirName()));
@@ -52,7 +52,7 @@
return SetString(key, base::Int64ToString(value));
}
-bool Prefs::GetBoolean(const std::string& key, bool* value) {
+bool Prefs::GetBoolean(const string& key, bool* value) {
string str_value;
if (!GetString(key, &str_value))
return false;
@@ -68,7 +68,7 @@
return false;
}
-bool Prefs::SetBoolean(const std::string& key, const bool value) {
+bool Prefs::SetBoolean(const string& key, const bool value) {
return SetString(key, value ? "true" : "false");
}
@@ -84,7 +84,7 @@
return base::DeleteFile(filename, false);
}
-bool Prefs::GetFileNameForKey(const std::string& key,
+bool Prefs::GetFileNameForKey(const string& key,
base::FilePath* filename) {
// Allows only non-empty keys containing [A-Za-z0-9_-].
TEST_AND_RETURN_FALSE(!key.empty());
diff --git a/proxy_resolver.cc b/proxy_resolver.cc
index fd233de..c6ba03b 100644
--- a/proxy_resolver.cc
+++ b/proxy_resolver.cc
@@ -20,7 +20,7 @@
}
}
-bool DirectProxyResolver::GetProxiesForUrl(const std::string& url,
+bool DirectProxyResolver::GetProxiesForUrl(const string& url,
ProxiesResolvedFn callback,
void* data) {
base::Closure* closure = new base::Closure(base::Bind(
@@ -41,7 +41,7 @@
idle_callback_id_ = 0;
// Initialize proxy pool with as many proxies as indicated (all identical).
- std::deque<std::string> proxies(num_proxies_, kNoProxy);
+ deque<string> proxies(num_proxies_, kNoProxy);
(*callback)(proxies, data);
}
diff --git a/subprocess.cc b/subprocess.cc
index 253ba17..9b90920 100644
--- a/subprocess.cc
+++ b/subprocess.cc
@@ -240,9 +240,9 @@
return success;
}
-bool Subprocess::SynchronousExec(const std::vector<std::string>& cmd,
+bool Subprocess::SynchronousExec(const vector<string>& cmd,
int* return_code,
- std::string* stdout) {
+ string* stdout) {
return SynchronousExecFlags(cmd,
static_cast<GSpawnFlags>(0),
return_code,
diff --git a/test_http_server.cc b/test_http_server.cc
index 2687d99..5c85dbf 100644
--- a/test_http_server.cc
+++ b/test_http_server.cc
@@ -39,7 +39,6 @@
// HTTP end-of-line delimiter; sorry, this needs to be a macro.
#define EOL "\r\n"
-using std::min;
using std::string;
using std::vector;
@@ -86,12 +85,12 @@
<< "\n--8<------8<------8<------8<----";
// Break header into lines.
- std::vector<string> lines;
+ vector<string> lines;
base::SplitStringUsingSubstr(
headers.substr(0, headers.length() - strlen(EOL EOL)), EOL, &lines);
// Decode URL line.
- std::vector<string> terms;
+ vector<string> terms;
base::SplitStringAlongWhitespace(lines[0], &terms);
CHECK_EQ(terms.size(), static_cast<vector<string>::size_type>(3));
CHECK_EQ(terms[0], "GET");
@@ -101,7 +100,7 @@
// Decode remaining lines.
size_t i;
for (i = 1; i < lines.size(); i++) {
- std::vector<string> terms;
+ vector<string> terms;
base::SplitStringAlongWhitespace(lines[i], &terms);
if (terms[0] == "Range:") {
@@ -115,7 +114,7 @@
if (range.find('-') < range.length() - 1)
request->end_offset = atoll(range.c_str() + range.find('-') + 1) + 1;
request->return_code = kHttpResponsePartialContent;
- std::string tmp_str = base::StringPrintf("decoded range offsets: "
+ string tmp_str = base::StringPrintf("decoded range offsets: "
"start=%jd end=",
(intmax_t)request->start_offset);
if (request->end_offset > 0)
@@ -481,7 +480,7 @@
}
private:
- std::vector<string> terms;
+ vector<string> terms;
};
void HandleConnection(int fd) {
diff --git a/test_utils.cc b/test_utils.cc
index 70eb35c..3619e5a 100644
--- a/test_utils.cc
+++ b/test_utils.cc
@@ -32,15 +32,15 @@
const char* const kMountPathTemplate = "UpdateEngineTests_mnt-XXXXXX";
-bool WriteFileVector(const std::string& path, const std::vector<char>& data) {
+bool WriteFileVector(const string& path, const vector<char>& data) {
return utils::WriteFile(path.c_str(), &data[0], data.size());
}
-bool WriteFileString(const std::string& path, const std::string& data) {
+bool WriteFileString(const string& path, const string& data) {
return utils::WriteFile(path.c_str(), data.data(), data.size());
}
-std::string Readlink(const std::string& path) {
+string Readlink(const string& path) {
vector<char> buf(PATH_MAX + 1);
ssize_t r = readlink(path.c_str(), &buf[0], buf.size());
if (r < 0)
@@ -52,7 +52,7 @@
return ret;
}
-std::vector<char> GzipCompressData(const std::vector<char>& data) {
+vector<char> GzipCompressData(const vector<char>& data) {
const char fname[] = "/tmp/GzipCompressDataTemp";
if (!WriteFileVector(fname, data)) {
EXPECT_EQ(0, system((string("rm ") + fname).c_str()));
diff --git a/update_attempter.cc b/update_attempter.cc
index 370cfd9..2911540 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -60,8 +60,6 @@
using chromeos_update_manager::EvalStatus;
using chromeos_update_manager::Policy;
using chromeos_update_manager::UpdateCheckParams;
-using google::protobuf::NewPermanentCallback;
-using std::make_pair;
using std::set;
using std::shared_ptr;
using std::string;
@@ -133,7 +131,7 @@
UpdateAttempter::UpdateAttempter(SystemState* system_state,
DBusWrapperInterface* dbus_iface,
- const std::string& update_completed_marker)
+ const string& update_completed_marker)
: processor_(new ActionProcessor()),
system_state_(system_state),
dbus_iface_(dbus_iface),
@@ -176,12 +174,12 @@
bool UpdateAttempter::CheckAndReportDailyMetrics() {
int64_t stored_value;
- base::Time now = system_state_->clock()->GetWallclockTime();
+ Time now = system_state_->clock()->GetWallclockTime();
if (system_state_->prefs()->Exists(kPrefsDailyMetricsLastReportedAt) &&
system_state_->prefs()->GetInt64(kPrefsDailyMetricsLastReportedAt,
&stored_value)) {
- base::Time last_reported_at = base::Time::FromInternalValue(stored_value);
- base::TimeDelta time_reported_since = now - last_reported_at;
+ Time last_reported_at = Time::FromInternalValue(stored_value);
+ TimeDelta time_reported_since = now - last_reported_at;
if (time_reported_since.InSeconds() < 0) {
LOG(WARNING) << "Last reported daily metrics "
<< utils::FormatTimeDelta(time_reported_since) << " ago "
@@ -222,9 +220,9 @@
return;
}
- base::Time lsb_release_timestamp = utils::TimeFromStructTimespec(&sb.st_ctim);
- base::Time now = system_state_->clock()->GetWallclockTime();
- base::TimeDelta age = now - lsb_release_timestamp;
+ Time lsb_release_timestamp = utils::TimeFromStructTimespec(&sb.st_ctim);
+ Time now = system_state_->clock()->GetWallclockTime();
+ TimeDelta age = now - lsb_release_timestamp;
if (age.InSeconds() < 0) {
LOG(ERROR) << "The OS age (" << utils::FormatTimeDelta(age)
<< ") is negative. Maybe the clock is wrong? "
@@ -232,7 +230,7 @@
return;
}
- std::string metric = "Installer.OSAgeDays";
+ string metric = "Installer.OSAgeDays";
LOG(INFO) << "Uploading " << utils::FormatTimeDelta(age)
<< " for metric " << metric;
system_state_->metrics_lib()->SendToUMA(
@@ -751,11 +749,11 @@
return (status_ == UPDATE_STATUS_IDLE && !GetRollbackPartition().empty());
}
-std::string UpdateAttempter::GetRollbackPartition() const {
- std::vector<std::string> kernel_devices =
+string UpdateAttempter::GetRollbackPartition() const {
+ vector<string> kernel_devices =
system_state_->hardware()->GetKernelDevices();
- std::string boot_kernel_device =
+ string boot_kernel_device =
system_state_->hardware()->BootKernelDevice();
LOG(INFO) << "UpdateAttempter::GetRollbackPartition";
@@ -769,10 +767,10 @@
if (current == kernel_devices.end()) {
LOG(ERROR) << "Unable to find the boot kernel device in the list of "
<< "available devices";
- return std::string();
+ return string();
}
- for (std::string const& device_name : kernel_devices) {
+ for (string const& device_name : kernel_devices) {
if (device_name != *current) {
bool bootable = false;
if (system_state_->hardware()->IsKernelBootable(device_name, &bootable) &&
@@ -782,21 +780,21 @@
}
}
- return std::string();
+ return string();
}
-std::vector<std::pair<std::string, bool>>
+vector<std::pair<string, bool>>
UpdateAttempter::GetKernelDevices() const {
- std::vector<std::string> kernel_devices =
+ vector<string> kernel_devices =
system_state_->hardware()->GetKernelDevices();
- std::string boot_kernel_device =
+ string boot_kernel_device =
system_state_->hardware()->BootKernelDevice();
- std::vector<std::pair<std::string, bool>> info_list;
+ vector<std::pair<string, bool>> info_list;
info_list.reserve(kernel_devices.size());
- for (std::string device_name : kernel_devices) {
+ for (string device_name : kernel_devices) {
bool bootable = false;
system_state_->hardware()->IsKernelBootable(device_name, &bootable);
// Add '*' to the name of the partition we booted from.
@@ -840,7 +838,7 @@
return;
int64_t value = system_state_->clock()->GetBootTime().ToInternalValue();
- string contents = base::StringPrintf("%" PRIi64, value);
+ string contents = StringPrintf("%" PRIi64, value);
utils::WriteFile(update_completed_marker_.c_str(),
contents.c_str(),
@@ -1592,7 +1590,7 @@
return true;
}
-bool UpdateAttempter::GetBootTimeAtUpdate(base::Time *out_boot_time) {
+bool UpdateAttempter::GetBootTimeAtUpdate(Time *out_boot_time) {
if (update_completed_marker_.empty())
return false;
diff --git a/update_attempter_unittest.cc b/update_attempter_unittest.cc
index 31b1452..9098180 100644
--- a/update_attempter_unittest.cc
+++ b/update_attempter_unittest.cc
@@ -32,7 +32,6 @@
using base::TimeDelta;
using std::string;
using std::unique_ptr;
-using testing::_;
using testing::DoAll;
using testing::InSequence;
using testing::Ne;
@@ -40,6 +39,7 @@
using testing::Property;
using testing::Return;
using testing::SetArgumentPointee;
+using testing::_;
namespace chromeos_update_engine {
@@ -57,7 +57,7 @@
UpdateAttempterUnderTest(SystemState* system_state,
DBusWrapperInterface* dbus_iface,
- const std::string& update_completed_marker)
+ const string& update_completed_marker)
: UpdateAttempter(system_state, dbus_iface, update_completed_marker) {}
// Wrap the update scheduling method, allowing us to opt out of scheduled
@@ -497,12 +497,12 @@
if (enterprise_rollback) {
// We return an empty owner as this is an enterprise.
EXPECT_CALL(*device_policy, GetOwner(_)).WillRepeatedly(
- DoAll(SetArgumentPointee<0>(std::string("")),
+ DoAll(SetArgumentPointee<0>(string("")),
Return(true)));
} else {
// We return a fake owner as this is an owned consumer device.
EXPECT_CALL(*device_policy, GetOwner(_)).WillRepeatedly(
- DoAll(SetArgumentPointee<0>(std::string("[email protected]")),
+ DoAll(SetArgumentPointee<0>(string("[email protected]")),
Return(true)));
}
diff --git a/update_engine_client.cc b/update_engine_client.cc
index 0fe511c..5936f47 100644
--- a/update_engine_client.cc
+++ b/update_engine_client.cc
@@ -177,7 +177,7 @@
return true;
}
-std::string GetRollbackPartition() {
+string GetRollbackPartition() {
DBusGProxy* proxy;
GError* error = nullptr;
@@ -189,12 +189,12 @@
&error);
CHECK_EQ(rc, TRUE) << "Error while querying rollback partition availabilty: "
<< GetAndFreeGError(&error);
- std::string partition = rollback_partition;
+ string partition = rollback_partition;
g_free(rollback_partition);
return partition;
}
-std::string GetKernelDevices() {
+string GetKernelDevices() {
DBusGProxy* proxy;
GError* error = nullptr;
@@ -206,7 +206,7 @@
&error);
CHECK_EQ(rc, TRUE) << "Error while getting a list of kernel devices: "
<< GetAndFreeGError(&error);
- std::string devices = kernel_devices;
+ string devices = kernel_devices;
g_free(kernel_devices);
return devices;
}
@@ -588,7 +588,7 @@
// Show the rollback availability.
if (FLAGS_can_rollback) {
- std::string rollback_partition = GetRollbackPartition();
+ string rollback_partition = GetRollbackPartition();
bool can_rollback = true;
if (rollback_partition.empty()) {
rollback_partition = "UNAVAILABLE";
diff --git a/update_manager/boxed_value.cc b/update_manager/boxed_value.cc
index 773431c..2307f8d 100644
--- a/update_manager/boxed_value.cc
+++ b/update_manager/boxed_value.cc
@@ -78,7 +78,7 @@
return chromeos_update_engine::utils::FormatTimeDelta(*val);
}
-static std::string ConnectionTypeToString(ConnectionType type) {
+static string ConnectionTypeToString(ConnectionType type) {
switch (type) {
case ConnectionType::kEthernet:
return "Ethernet";
diff --git a/update_manager/chromeos_policy.cc b/update_manager/chromeos_policy.cc
index 19f9dc8..86a2dc4 100644
--- a/update_manager/chromeos_policy.cc
+++ b/update_manager/chromeos_policy.cc
@@ -516,7 +516,7 @@
ec->GetValue(updater_provider->var_updater_started_time());
POLICY_CHECK_VALUE_AND_FAIL(updater_started_time, error);
- const base::Time* last_checked_time =
+ const Time* last_checked_time =
ec->GetValue(updater_provider->var_last_checked_time());
const uint64_t* seed = ec->GetValue(state->random_provider()->var_seed());
@@ -587,7 +587,7 @@
}
EvalStatus ChromeOSPolicy::UpdateBackoffAndDownloadUrl(
- EvaluationContext* ec, State* state, std::string* error,
+ EvaluationContext* ec, State* state, string* error,
UpdateBackoffAndDownloadUrlResult* result,
const UpdateState& update_state) const {
// Sanity checks.
@@ -755,10 +755,10 @@
const uint64_t* seed = ec->GetValue(state->random_provider()->var_seed());
POLICY_CHECK_VALUE_AND_FAIL(seed, error);
PRNG prng(*seed);
- int exp = std::min(update_state.num_failures,
+ int exp = min(update_state.num_failures,
static_cast<int>(sizeof(int)) * 8 - 2);
TimeDelta backoff_interval = TimeDelta::FromDays(
- std::min(1 << exp, kAttemptBackoffMaxIntervalInDays));
+ min(1 << exp, kAttemptBackoffMaxIntervalInDays));
TimeDelta backoff_fuzz = TimeDelta::FromHours(kAttemptBackoffFuzzInHours);
TimeDelta wait_period = FuzzedInterval(&prng, backoff_interval.InSeconds(),
backoff_fuzz.InSeconds());
diff --git a/update_manager/chromeos_policy_unittest.cc b/update_manager/chromeos_policy_unittest.cc
index 10e6324..b99074c 100644
--- a/update_manager/chromeos_policy_unittest.cc
+++ b/update_manager/chromeos_policy_unittest.cc
@@ -21,7 +21,6 @@
using base::TimeDelta;
using chromeos_update_engine::ErrorCode;
using chromeos_update_engine::FakeClock;
-using std::make_tuple;
using std::set;
using std::string;
using std::tuple;
@@ -1019,7 +1018,8 @@
update_state.p2p_num_attempts = 1;
update_state.p2p_first_attempted =
fake_clock_.GetWallclockTime() -
- TimeDelta::FromSeconds(ChromeOSPolicy::kMaxP2PAttemptsPeriodInSeconds + 1);
+ TimeDelta::FromSeconds(
+ ChromeOSPolicy::kMaxP2PAttemptsPeriodInSeconds + 1);
UpdateDownloadParams result;
ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
update_state);
diff --git a/update_manager/evaluation_context.cc b/update_manager/evaluation_context.cc
index 9ab6771..3584ac8 100644
--- a/update_manager/evaluation_context.cc
+++ b/update_manager/evaluation_context.cc
@@ -28,8 +28,8 @@
// Returns whether |curr_time| surpassed |ref_time|; if not, also checks whether
// |ref_time| is sooner than the current value of |*reeval_time|, in which case
// the latter is updated to the former.
-bool IsTimeGreaterThanHelper(base::Time ref_time, base::Time curr_time,
- base::Time* reeval_time) {
+bool IsTimeGreaterThanHelper(Time ref_time, Time curr_time,
+ Time* reeval_time) {
if (curr_time > ref_time)
return true;
// Remember the nearest reference we've checked against in this evaluation.
@@ -40,7 +40,7 @@
// If |expires| never happens (maximal value), returns the maximal interval;
// otherwise, returns the difference between |expires| and |curr|.
-TimeDelta GetTimeout(base::Time curr, base::Time expires) {
+TimeDelta GetTimeout(Time curr, Time expires) {
if (expires.is_max())
return TimeDelta::Max();
return expires - curr;
@@ -114,12 +114,12 @@
callback->Run();
}
-bool EvaluationContext::IsWallclockTimeGreaterThan(base::Time timestamp) {
+bool EvaluationContext::IsWallclockTimeGreaterThan(Time timestamp) {
return IsTimeGreaterThanHelper(timestamp, evaluation_start_wallclock_,
&reevaluation_time_wallclock_);
}
-bool EvaluationContext::IsMonotonicTimeGreaterThan(base::Time timestamp) {
+bool EvaluationContext::IsMonotonicTimeGreaterThan(Time timestamp) {
return IsTimeGreaterThanHelper(timestamp, evaluation_start_monotonic_,
&reevaluation_time_monotonic_);
}
diff --git a/update_manager/evaluation_context_unittest.cc b/update_manager/evaluation_context_unittest.cc
index 014d10c..19e3419 100644
--- a/update_manager/evaluation_context_unittest.cc
+++ b/update_manager/evaluation_context_unittest.cc
@@ -101,7 +101,7 @@
EXPECT_TRUE(fake_poll_var_.observer_list_.empty());
}
- base::TimeDelta default_timeout_ = base::TimeDelta::FromSeconds(5);
+ TimeDelta default_timeout_ = TimeDelta::FromSeconds(5);
FakeClock fake_clock_;
scoped_refptr<EvaluationContext> eval_ctx_;
@@ -344,7 +344,7 @@
}
TEST_F(UmEvaluationContextTest, ResetEvaluationResetsTimesWallclock) {
- base::Time cur_time = fake_clock_.GetWallclockTime();
+ Time cur_time = fake_clock_.GetWallclockTime();
// Advance the time on the clock but don't call ResetEvaluation yet.
fake_clock_.SetWallclockTime(cur_time + TimeDelta::FromSeconds(4));
@@ -365,7 +365,7 @@
}
TEST_F(UmEvaluationContextTest, ResetEvaluationResetsTimesMonotonic) {
- base::Time cur_time = fake_clock_.GetMonotonicTime();
+ Time cur_time = fake_clock_.GetMonotonicTime();
// Advance the time on the clock but don't call ResetEvaluation yet.
fake_clock_.SetMonotonicTime(cur_time + TimeDelta::FromSeconds(4));
diff --git a/update_manager/generic_variables_unittest.cc b/update_manager/generic_variables_unittest.cc
index f0ea60c..784ac4a 100644
--- a/update_manager/generic_variables_unittest.cc
+++ b/update_manager/generic_variables_unittest.cc
@@ -12,7 +12,6 @@
#include "update_engine/test_utils.h"
#include "update_engine/update_manager/umtest_utils.h"
-using base::TimeDelta;
using chromeos_update_engine::RunGMainLoopMaxIterations;
using std::unique_ptr;
diff --git a/update_manager/real_config_provider.cc b/update_manager/real_config_provider.cc
index d986b10..ac334c4 100644
--- a/update_manager/real_config_provider.cc
+++ b/update_manager/real_config_provider.cc
@@ -13,7 +13,6 @@
#include "update_engine/utils.h"
using chromeos::KeyValueStore;
-using std::string;
namespace {
diff --git a/update_manager/real_device_policy_provider.cc b/update_manager/real_device_policy_provider.cc
index 9a68956..f74a7be 100644
--- a/update_manager/real_device_policy_provider.cc
+++ b/update_manager/real_device_policy_provider.cc
@@ -51,7 +51,7 @@
template<typename T>
void RealDevicePolicyProvider::UpdateVariable(
AsyncCopyVariable<T>* var,
- bool (policy::DevicePolicy::*getter_method)(T*) const) {
+ bool (DevicePolicy::*getter_method)(T*) const) {
T new_value;
if (policy_provider_->device_policy_is_loaded() &&
(policy_provider_->GetDevicePolicy().*getter_method)(&new_value)) {
@@ -95,7 +95,7 @@
}
bool RealDevicePolicyProvider::ConvertScatterFactor(
- base::TimeDelta* scatter_factor) const {
+ TimeDelta* scatter_factor) const {
int64_t scatter_factor_in_seconds;
if (!policy_provider_->GetDevicePolicy().GetScatterFactorInSeconds(
&scatter_factor_in_seconds)) {
@@ -106,7 +106,7 @@
<< scatter_factor_in_seconds;
return false;
}
- *scatter_factor = base::TimeDelta::FromSeconds(scatter_factor_in_seconds);
+ *scatter_factor = TimeDelta::FromSeconds(scatter_factor_in_seconds);
return true;
}
diff --git a/update_manager/real_device_policy_provider_unittest.cc b/update_manager/real_device_policy_provider_unittest.cc
index 52b036b..627027e 100644
--- a/update_manager/real_device_policy_provider_unittest.cc
+++ b/update_manager/real_device_policy_provider_unittest.cc
@@ -18,7 +18,6 @@
using std::set;
using std::string;
using std::unique_ptr;
-using testing::AtLeast;
using testing::DoAll;
using testing::Mock;
using testing::Return;
@@ -138,7 +137,7 @@
.WillOnce(DoAll(SetArgumentPointee<0>(1234), Return(true)));
EXPECT_TRUE(provider_->Init());
- UmTestUtils::ExpectVariableHasValue(base::TimeDelta::FromSeconds(1234),
+ UmTestUtils::ExpectVariableHasValue(TimeDelta::FromSeconds(1234),
provider_->var_scatter_factor());
}
diff --git a/update_manager/real_random_provider_unittest.cc b/update_manager/real_random_provider_unittest.cc
index d7b2d98..d7dfeb2 100644
--- a/update_manager/real_random_provider_unittest.cc
+++ b/update_manager/real_random_provider_unittest.cc
@@ -9,7 +9,6 @@
#include "update_engine/update_manager/real_random_provider.h"
#include "update_engine/update_manager/umtest_utils.h"
-using base::TimeDelta;
using std::unique_ptr;
namespace chromeos_update_manager {
diff --git a/update_manager/real_shill_provider_unittest.cc b/update_manager/real_shill_provider_unittest.cc
index 7c64d81..7859501 100644
--- a/update_manager/real_shill_provider_unittest.cc
+++ b/update_manager/real_shill_provider_unittest.cc
@@ -26,7 +26,6 @@
using std::unique_ptr;
using testing::Eq;
using testing::Mock;
-using testing::NiceMock;
using testing::Return;
using testing::SaveArg;
using testing::SetArgPointee;
diff --git a/update_manager/real_system_provider.cc b/update_manager/real_system_provider.cc
index 8d5f4f4..1410106 100644
--- a/update_manager/real_system_provider.cc
+++ b/update_manager/real_system_provider.cc
@@ -20,11 +20,7 @@
#include "update_engine/update_manager/generic_variables.h"
#include "update_engine/utils.h"
-using base::StringPrintf;
-using base::Time;
-using base::TimeDelta;
using std::string;
-using std::vector;
namespace chromeos_update_manager {
diff --git a/update_manager/real_time_provider.cc b/update_manager/real_time_provider.cc
index e9ac3c2..dab9829 100644
--- a/update_manager/real_time_provider.cc
+++ b/update_manager/real_time_provider.cc
@@ -26,7 +26,7 @@
: Variable<Time>(name, TimeDelta::FromHours(1)), clock_(clock) {}
protected:
- virtual const Time* GetValue(base::TimeDelta /* timeout */,
+ virtual const Time* GetValue(TimeDelta /* timeout */,
string* /* errmsg */) {
Time::Exploded now_exp;
clock_->GetWallclockTime().LocalExplode(&now_exp);
@@ -49,7 +49,7 @@
: Variable<int>(name, TimeDelta::FromMinutes(5)), clock_(clock) {}
protected:
- virtual const int* GetValue(base::TimeDelta /* timeout */,
+ virtual const int* GetValue(TimeDelta /* timeout */,
string* /* errmsg */) {
Time::Exploded exploded;
clock_->GetWallclockTime().LocalExplode(&exploded);
diff --git a/update_manager/real_time_provider_unittest.cc b/update_manager/real_time_provider_unittest.cc
index da69e49..3532ff3 100644
--- a/update_manager/real_time_provider_unittest.cc
+++ b/update_manager/real_time_provider_unittest.cc
@@ -13,7 +13,6 @@
#include "update_engine/update_manager/umtest_utils.h"
using base::Time;
-using base::TimeDelta;
using chromeos_update_engine::FakeClock;
using std::unique_ptr;
diff --git a/update_manager/real_updater_provider_unittest.cc b/update_manager/real_updater_provider_unittest.cc
index eeee245..1477187 100644
--- a/update_manager/real_updater_provider_unittest.cc
+++ b/update_manager/real_updater_provider_unittest.cc
@@ -22,7 +22,6 @@
using base::TimeDelta;
using chromeos_update_engine::FakeClock;
using chromeos_update_engine::FakeSystemState;
-using chromeos_update_engine::MockUpdateAttempter;
using chromeos_update_engine::OmahaRequestParams;
using chromeos_update_engine::PrefsMock;
using std::string;
diff --git a/update_manager/update_manager_unittest.cc b/update_manager/update_manager_unittest.cc
index a9e4b22..42edc40 100644
--- a/update_manager/update_manager_unittest.cc
+++ b/update_manager/update_manager_unittest.cc
@@ -35,9 +35,6 @@
using std::tuple;
using std::unique_ptr;
using std::vector;
-using testing::Return;
-using testing::StrictMock;
-using testing::_;
namespace {
@@ -89,7 +86,7 @@
}
protected:
- std::string PolicyName() const override { return "FailingPolicy"; }
+ string PolicyName() const override { return "FailingPolicy"; }
private:
int* num_called_p_;
@@ -104,7 +101,7 @@
}
protected:
- std::string PolicyName() const override { return "LazyPolicy"; }
+ string PolicyName() const override { return "LazyPolicy"; }
};
// A policy that sleeps for a predetermined amount of time, then checks for a
@@ -137,7 +134,7 @@
}
protected:
- std::string PolicyName() const override { return "DelayPolicy"; }
+ string PolicyName() const override { return "DelayPolicy"; }
private:
int sleep_secs_;
diff --git a/utils.cc b/utils.cc
index d7ece2d..eb4ccd2 100644
--- a/utils.cc
+++ b/utils.cc
@@ -183,13 +183,13 @@
// Append |nbytes| of content from |buf| to the vector pointed to by either
// |vec_p| or |str_p|.
static void AppendBytes(const char* buf, size_t nbytes,
- std::vector<char>* vec_p) {
+ vector<char>* vec_p) {
CHECK(buf);
CHECK(vec_p);
vec_p->insert(vec_p->end(), buf, buf + nbytes);
}
static void AppendBytes(const char* buf, size_t nbytes,
- std::string* str_p) {
+ string* str_p) {
CHECK(buf);
CHECK(str_p);
str_p->append(buf, nbytes);
@@ -229,7 +229,7 @@
// |out_p|. Starts reading the file from |offset|. If |offset| is beyond the end
// of the file, returns success. If |size| is not -1, reads up to |size| bytes.
template <class T>
-static bool ReadFileChunkAndAppend(const std::string& path,
+static bool ReadFileChunkAndAppend(const string& path,
off_t offset,
off_t size,
T* out_p) {
@@ -252,7 +252,7 @@
// Invokes a pipe |cmd|, then uses |append_func| to append its stdout to a
// container |out_p|.
template <class T>
-static bool ReadPipeAndAppend(const std::string& cmd, T* out_p) {
+static bool ReadPipeAndAppend(const string& cmd, T* out_p) {
FILE* fp = popen(cmd.c_str(), "r");
if (!fp)
return false;
@@ -377,7 +377,7 @@
};
} // namespace
-bool RecursiveUnlinkDir(const std::string& path) {
+bool RecursiveUnlinkDir(const string& path) {
struct stat stbuf;
int r = lstat(path.c_str(), &stbuf);
TEST_AND_RETURN_FALSE_ERRNO((r == 0) || (errno == ENOENT));
@@ -417,20 +417,20 @@
return true;
}
-std::string GetDiskName(const string& partition_name) {
- std::string disk_name;
+string GetDiskName(const string& partition_name) {
+ string disk_name;
return SplitPartitionName(partition_name, &disk_name, nullptr) ?
- disk_name : std::string();
+ disk_name : string();
}
-int GetPartitionNumber(const std::string& partition_name) {
+int GetPartitionNumber(const string& partition_name) {
int partition_num = 0;
return SplitPartitionName(partition_name, nullptr, &partition_num) ?
partition_num : 0;
}
-bool SplitPartitionName(const std::string& partition_name,
- std::string* out_disk_name,
+bool SplitPartitionName(const string& partition_name,
+ string* out_disk_name,
int* out_partition_num) {
if (!StringHasPrefix(partition_name, "/dev/")) {
LOG(ERROR) << "Invalid partition device name: " << partition_name;
@@ -444,7 +444,7 @@
return false;
}
- size_t partition_name_len = std::string::npos;
+ size_t partition_name_len = string::npos;
if (partition_name[last_nondigit_pos] == '_') {
// NAND block devices have weird naming which could be something
// like "/dev/ubiblock2_0". We discard "_0" in such a case.
@@ -473,26 +473,25 @@
}
if (out_partition_num) {
- std::string partition_str = partition_name.substr(last_nondigit_pos + 1,
- partition_name_len);
+ string partition_str = partition_name.substr(last_nondigit_pos + 1,
+ partition_name_len);
*out_partition_num = atoi(partition_str.c_str());
}
return true;
}
-std::string MakePartitionName(const std::string& disk_name,
- int partition_num) {
+string MakePartitionName(const string& disk_name, int partition_num) {
if (!StringHasPrefix(disk_name, "/dev/")) {
LOG(ERROR) << "Invalid disk name: " << disk_name;
- return std::string();
+ return string();
}
if (partition_num < 1) {
LOG(ERROR) << "Invalid partition number: " << partition_num;
- return std::string();
+ return string();
}
- std::string partition_name = disk_name;
+ string partition_name = disk_name;
if (isdigit(partition_name.back())) {
// Special case for devices with names ending with a digit.
// Add "p" to separate the disk name from partition number,
@@ -517,7 +516,7 @@
return base::FilePath("/sys/block").Append(device_path.BaseName()).value();
}
-bool IsRemovableDevice(const std::string& device) {
+bool IsRemovableDevice(const string& device) {
string sysfs_block = SysfsBlockDevice(device);
string removable;
if (sysfs_block.empty() ||
@@ -529,13 +528,13 @@
return removable == "1";
}
-std::string ErrnoNumberAsString(int err) {
+string ErrnoNumberAsString(int err) {
char buf[100];
buf[0] = '\0';
return strerror_r(err, buf, sizeof(buf));
}
-std::string NormalizePath(const std::string& path, bool strip_trailing_slash) {
+string NormalizePath(const string& path, bool strip_trailing_slash) {
string ret;
bool last_insert_was_slash = false;
for (string::const_iterator it = path.begin(); it != path.end(); ++it) {
@@ -589,8 +588,8 @@
return prefix + "/" + path;
}
-bool MakeTempFile(const std::string& base_filename_template,
- std::string* filename,
+bool MakeTempFile(const string& base_filename_template,
+ string* filename,
int* fd) {
const string filename_template = PrependTmpdir(base_filename_template);
DCHECK(filename || fd);
@@ -611,8 +610,8 @@
return true;
}
-bool MakeTempDirectory(const std::string& base_dirname_template,
- std::string* dirname) {
+bool MakeTempDirectory(const string& base_dirname_template,
+ string* dirname) {
const string dirname_template = PrependTmpdir(base_dirname_template);
DCHECK(dirname);
vector<char> buf(dirname_template.size() + 1);
@@ -625,13 +624,13 @@
return true;
}
-bool StringHasSuffix(const std::string& str, const std::string& suffix) {
+bool StringHasSuffix(const string& str, const string& suffix) {
if (suffix.size() > str.size())
return false;
return 0 == str.compare(str.size() - suffix.size(), suffix.size(), suffix);
}
-bool StringHasPrefix(const std::string& str, const std::string& prefix) {
+bool StringHasPrefix(const string& str, const string& prefix) {
if (prefix.size() > str.size())
return false;
return 0 == str.compare(0, prefix.size(), prefix);
@@ -663,7 +662,7 @@
return true;
}
-bool GetFilesystemSize(const std::string& device,
+bool GetFilesystemSize(const string& device,
int* out_block_count,
int* out_block_size) {
int fd = HANDLE_EINTR(open(device.c_str(), O_RDONLY));
@@ -1414,8 +1413,8 @@
return result;
}
-bool GetInstallDev(const std::string& boot_dev, std::string* install_dev) {
- std::string disk_name;
+bool GetInstallDev(const string& boot_dev, string* install_dev) {
+ string disk_name;
int partition_num;
if (!SplitPartitionName(boot_dev, &disk_name, &partition_num))
return false;
@@ -1441,21 +1440,21 @@
return Time::UnixEpoch() + TimeDelta::FromMicroseconds(us);
}
-gchar** StringVectorToGStrv(const vector<string> &vector) {
+gchar** StringVectorToGStrv(const vector<string> &vec_str) {
GPtrArray *p = g_ptr_array_new();
- for (std::vector<string>::const_iterator i = vector.begin();
- i != vector.end(); ++i) {
+ for (vector<string>::const_iterator i = vec_str.begin();
+ i != vec_str.end(); ++i) {
g_ptr_array_add(p, g_strdup(i->c_str()));
}
g_ptr_array_add(p, nullptr);
return reinterpret_cast<gchar**>(g_ptr_array_free(p, FALSE));
}
-string StringVectorToString(const vector<string> &vector) {
+string StringVectorToString(const vector<string> &vec_str) {
string str = "[";
- for (std::vector<string>::const_iterator i = vector.begin();
- i != vector.end(); ++i) {
- if (i != vector.begin())
+ for (vector<string>::const_iterator i = vec_str.begin();
+ i != vec_str.end(); ++i) {
+ if (i != vec_str.begin())
str += ", ";
str += '"';
str += *i;
@@ -1505,7 +1504,7 @@
return xattr_res == 0;
}
-bool DecodeAndStoreBase64String(const std::string& base64_encoded,
+bool DecodeAndStoreBase64String(const string& base64_encoded,
base::FilePath *out_path) {
vector<char> contents;
@@ -1547,7 +1546,7 @@
return true;
}
-bool ConvertToOmahaInstallDate(base::Time time, int *out_num_days) {
+bool ConvertToOmahaInstallDate(Time time, int *out_num_days) {
time_t unix_time = time.ToTimeT();
// Output of: date +"%s" --date="Jan 1, 2007 0:00 PST".
const time_t kOmahaEpoch = 1167638400;
@@ -1569,14 +1568,14 @@
}
bool WallclockDurationHelper(SystemState* system_state,
- const std::string& state_variable_key,
- base::TimeDelta* out_duration) {
+ const string& state_variable_key,
+ TimeDelta* out_duration) {
bool ret = false;
- base::Time now = system_state->clock()->GetWallclockTime();
+ Time now = system_state->clock()->GetWallclockTime();
int64_t stored_value;
if (system_state->prefs()->GetInt64(state_variable_key, &stored_value)) {
- base::Time stored_time = base::Time::FromInternalValue(stored_value);
+ Time stored_time = Time::FromInternalValue(stored_value);
if (stored_time > now) {
LOG(ERROR) << "Stored time-stamp used for " << state_variable_key
<< " is in the future.";
@@ -1596,12 +1595,12 @@
bool MonotonicDurationHelper(SystemState* system_state,
int64_t* storage,
- base::TimeDelta* out_duration) {
+ TimeDelta* out_duration) {
bool ret = false;
- base::Time now = system_state->clock()->GetMonotonicTime();
+ Time now = system_state->clock()->GetMonotonicTime();
if (*storage != 0) {
- base::Time stored_time = base::Time::FromInternalValue(*storage);
+ Time stored_time = Time::FromInternalValue(*storage);
*out_duration = now - stored_time;
ret = true;
}
diff --git a/utils.h b/utils.h
index 647f52c..f9b3c28 100644
--- a/utils.h
+++ b/utils.h
@@ -41,11 +41,11 @@
// Converts a vector of strings to a NUL-terminated array of
// strings. The resulting array should be freed with g_strfreev()
// when are you done with it.
-gchar** StringVectorToGStrv(const std::vector<std::string> &vector);
+gchar** StringVectorToGStrv(const std::vector<std::string> &vec_str);
-// Formats |vector| as a string of the form ["<elem1>", "<elem2>"].
+// Formats |vec_str| as a string of the form ["<elem1>", "<elem2>"].
// Does no escaping, only use this for presentation in error messages.
-std::string StringVectorToString(const std::vector<std::string> &vector);
+std::string StringVectorToString(const std::vector<std::string> &vec_str);
// Calculates the p2p file id from payload hash and size
std::string CalculateP2PFileId(const std::string& payload_hash,
diff --git a/zip_unittest.cc b/zip_unittest.cc
index c73d28d..72fb9a6 100644
--- a/zip_unittest.cc
+++ b/zip_unittest.cc
@@ -22,14 +22,14 @@
template <typename T>
class ZipTest : public ::testing::Test {
public:
- bool ZipDecompress(const std::vector<char>& in,
- std::vector<char>* out) const = 0;
- bool ZipCompress(const std::vector<char>& in,
- std::vector<char>* out) const = 0;
- bool ZipCompressString(const std::string& str,
- std::vector<char>* out) const = 0;
- bool ZipDecompressString(const std::string& str,
- std::vector<char>* out) const = 0;
+ bool ZipDecompress(const vector<char>& in,
+ vector<char>* out) const = 0;
+ bool ZipCompress(const vector<char>& in,
+ vector<char>* out) const = 0;
+ bool ZipCompressString(const string& str,
+ vector<char>* out) const = 0;
+ bool ZipDecompressString(const string& str,
+ vector<char>* out) const = 0;
};
class BzipTest {};
@@ -37,20 +37,20 @@
template <>
class ZipTest<BzipTest> : public ::testing::Test {
public:
- bool ZipDecompress(const std::vector<char>& in,
- std::vector<char>* out) const {
+ bool ZipDecompress(const vector<char>& in,
+ vector<char>* out) const {
return BzipDecompress(in, out);
}
- bool ZipCompress(const std::vector<char>& in,
- std::vector<char>* out) const {
+ bool ZipCompress(const vector<char>& in,
+ vector<char>* out) const {
return BzipCompress(in, out);
}
- bool ZipCompressString(const std::string& str,
- std::vector<char>* out) const {
+ bool ZipCompressString(const string& str,
+ vector<char>* out) const {
return BzipCompressString(str, out);
}
- bool ZipDecompressString(const std::string& str,
- std::vector<char>* out) const {
+ bool ZipDecompressString(const string& str,
+ vector<char>* out) const {
return BzipDecompressString(str, out);
}
};