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 <avakulenko@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
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_;