update_engine: Run clang-format on update_manager/
BUG=none
TEST=unittest
Change-Id: I80b56209d757d1156dd5f55bdd758a1ae8388dcc
Reviewed-on: https://chromium-review.googlesource.com/1409707
Commit-Ready: Amin Hassani <[email protected]>
Tested-by: Amin Hassani <[email protected]>
Reviewed-by: Amin Hassani <[email protected]>
Reviewed-by: Sen Jiang <[email protected]>
diff --git a/update_manager/boxed_value.cc b/update_manager/boxed_value.cc
index 35bfb1f..cee1ece8 100644
--- a/update_manager/boxed_value.cc
+++ b/update_manager/boxed_value.cc
@@ -42,13 +42,13 @@
// Template instantiation for common types; used in BoxedValue::ToString().
// Keep in sync with boxed_value_unitttest.cc.
-template<>
+template <>
string BoxedValue::ValuePrinter<string>(const void* value) {
const string* val = reinterpret_cast<const string*>(value);
return *val;
}
-template<>
+template <>
string BoxedValue::ValuePrinter<int>(const void* value) {
const int* val = reinterpret_cast<const int*>(value);
#if BASE_VER < 576279
@@ -58,7 +58,7 @@
#endif
}
-template<>
+template <>
string BoxedValue::ValuePrinter<unsigned int>(const void* value) {
const unsigned int* val = reinterpret_cast<const unsigned int*>(value);
#if BASE_VER < 576279
@@ -68,7 +68,7 @@
#endif
}
-template<>
+template <>
string BoxedValue::ValuePrinter<int64_t>(const void* value) {
const int64_t* val = reinterpret_cast<const int64_t*>(value);
#if BASE_VER < 576279
@@ -78,10 +78,9 @@
#endif
}
-template<>
+template <>
string BoxedValue::ValuePrinter<uint64_t>(const void* value) {
- const uint64_t* val =
- reinterpret_cast<const uint64_t*>(value);
+ const uint64_t* val = reinterpret_cast<const uint64_t*>(value);
#if BASE_VER < 576279
return base::Uint64ToString(*val);
#else
@@ -89,13 +88,13 @@
#endif
}
-template<>
+template <>
string BoxedValue::ValuePrinter<bool>(const void* value) {
const bool* val = reinterpret_cast<const bool*>(value);
return *val ? "true" : "false";
}
-template<>
+template <>
string BoxedValue::ValuePrinter<double>(const void* value) {
const double* val = reinterpret_cast<const double*>(value);
#if BASE_VER < 576279
@@ -105,25 +104,25 @@
#endif
}
-template<>
+template <>
string BoxedValue::ValuePrinter<base::Time>(const void* value) {
const base::Time* val = reinterpret_cast<const base::Time*>(value);
return chromeos_update_engine::utils::ToString(*val);
}
-template<>
+template <>
string BoxedValue::ValuePrinter<base::TimeDelta>(const void* value) {
const base::TimeDelta* val = reinterpret_cast<const base::TimeDelta*>(value);
return chromeos_update_engine::utils::FormatTimeDelta(*val);
}
-template<>
+template <>
string BoxedValue::ValuePrinter<ConnectionType>(const void* value) {
const ConnectionType* val = reinterpret_cast<const ConnectionType*>(value);
return StringForConnectionType(*val);
}
-template<>
+template <>
string BoxedValue::ValuePrinter<set<ConnectionType>>(const void* value) {
string ret = "";
const set<ConnectionType>* val =
@@ -137,7 +136,7 @@
return ret;
}
-template<>
+template <>
string BoxedValue::ValuePrinter<ConnectionTethering>(const void* value) {
const ConnectionTethering* val =
reinterpret_cast<const ConnectionTethering*>(value);
@@ -178,7 +177,7 @@
return "Unknown";
}
-template<>
+template <>
string BoxedValue::ValuePrinter<Stage>(const void* value) {
const Stage* val = reinterpret_cast<const Stage*>(value);
switch (*val) {
@@ -205,7 +204,7 @@
return "Unknown";
}
-template<>
+template <>
string BoxedValue::ValuePrinter<UpdateRequestStatus>(const void* value) {
const UpdateRequestStatus* val =
reinterpret_cast<const UpdateRequestStatus*>(value);
diff --git a/update_manager/boxed_value.h b/update_manager/boxed_value.h
index c40215e..62b4b9d 100644
--- a/update_manager/boxed_value.h
+++ b/update_manager/boxed_value.h
@@ -60,10 +60,11 @@
// Creates a BoxedValue for the passed pointer |value|. The BoxedValue keeps
// the ownership of this pointer and can't be released.
- template<typename T>
+ template <typename T>
explicit BoxedValue(const T* value)
- : value_(static_cast<const void*>(value)), deleter_(ValueDeleter<T>),
- printer_(ValuePrinter<T>) {}
+ : value_(static_cast<const void*>(value)),
+ deleter_(ValueDeleter<T>),
+ printer_(ValuePrinter<T>) {}
// The move constructor takes ownership of the pointer since the semantics of
// it allows to render the passed BoxedValue undefined. You need to use the
@@ -97,14 +98,14 @@
}
// Static method to call the destructor of the right type.
- template<typename T>
+ template <typename T>
static void ValueDeleter(const void* value) {
delete reinterpret_cast<const T*>(value);
}
// Static method to print a type. See boxed_value.cc for common
// instantiations.
- template<typename T>
+ template <typename T>
static std::string ValuePrinter(const void* value);
private:
diff --git a/update_manager/boxed_value_unittest.cc b/update_manager/boxed_value_unittest.cc
index 212db36..2fa94ec 100644
--- a/update_manager/boxed_value_unittest.cc
+++ b/update_manager/boxed_value_unittest.cc
@@ -51,14 +51,14 @@
~DeleterMarker() { *marker_ = true; }
private:
- friend string BoxedValue::ValuePrinter<DeleterMarker>(const void *);
+ friend string BoxedValue::ValuePrinter<DeleterMarker>(const void*);
// Pointer to the bool marker.
bool* marker_;
};
-template<>
-string BoxedValue::ValuePrinter<DeleterMarker>(const void *value) {
+template <>
+string BoxedValue::ValuePrinter<DeleterMarker>(const void* value) {
const DeleterMarker* val = reinterpret_cast<const DeleterMarker*>(value);
return base::StringPrintf("DeleterMarker:%s",
*val->marker_ ? "true" : "false");
@@ -112,8 +112,7 @@
}
TEST(UmBoxedValueTest, StringToString) {
- EXPECT_EQ("Hej Verden!",
- BoxedValue(new string("Hej Verden!")).ToString());
+ EXPECT_EQ("Hej Verden!", BoxedValue(new string("Hej Verden!")).ToString());
}
TEST(UmBoxedValueTest, IntToString) {
@@ -122,8 +121,8 @@
TEST(UmBoxedValueTest, Int64ToString) {
// -123456789012345 doesn't fit in 32-bit integers.
- EXPECT_EQ("-123456789012345", BoxedValue(
- new int64_t(-123456789012345LL)).ToString());
+ EXPECT_EQ("-123456789012345",
+ BoxedValue(new int64_t(-123456789012345LL)).ToString());
}
TEST(UmBoxedValueTest, UnsignedIntToString) {
@@ -134,8 +133,8 @@
TEST(UmBoxedValueTest, UnsignedInt64ToString) {
// 18446744073709551615 is the biggest possible 64-bit unsigned integer.
- EXPECT_EQ("18446744073709551615", BoxedValue(
- new uint64_t(18446744073709551615ULL)).ToString());
+ EXPECT_EQ("18446744073709551615",
+ BoxedValue(new uint64_t(18446744073709551615ULL)).ToString());
}
TEST(UmBoxedValueTest, BoolToString) {
@@ -155,46 +154,47 @@
TEST(UmBoxedValueTest, TimeDeltaToString) {
// 12345 seconds is 3 hours, 25 minutes and 45 seconds.
- EXPECT_EQ("3h25m45s",
- BoxedValue(new TimeDelta(TimeDelta::FromSeconds(12345)))
- .ToString());
+ EXPECT_EQ(
+ "3h25m45s",
+ BoxedValue(new TimeDelta(TimeDelta::FromSeconds(12345))).ToString());
}
TEST(UmBoxedValueTest, ConnectionTypeToString) {
EXPECT_EQ(
"Disconnected",
BoxedValue(new ConnectionType(ConnectionType::kDisconnected)).ToString());
- EXPECT_EQ("ethernet",
- BoxedValue(new ConnectionType(ConnectionType::kEthernet))
- .ToString());
+ EXPECT_EQ(
+ "ethernet",
+ BoxedValue(new ConnectionType(ConnectionType::kEthernet)).ToString());
EXPECT_EQ("wifi",
BoxedValue(new ConnectionType(ConnectionType::kWifi)).ToString());
EXPECT_EQ("wimax",
BoxedValue(new ConnectionType(ConnectionType::kWimax)).ToString());
- EXPECT_EQ("bluetooth",
- BoxedValue(new ConnectionType(ConnectionType::kBluetooth))
- .ToString());
- EXPECT_EQ("cellular",
- BoxedValue(new ConnectionType(ConnectionType::kCellular))
- .ToString());
- EXPECT_EQ("Unknown",
- BoxedValue(new ConnectionType(ConnectionType::kUnknown))
- .ToString());
+ EXPECT_EQ(
+ "bluetooth",
+ BoxedValue(new ConnectionType(ConnectionType::kBluetooth)).ToString());
+ EXPECT_EQ(
+ "cellular",
+ BoxedValue(new ConnectionType(ConnectionType::kCellular)).ToString());
+ EXPECT_EQ(
+ "Unknown",
+ BoxedValue(new ConnectionType(ConnectionType::kUnknown)).ToString());
}
TEST(UmBoxedValueTest, ConnectionTetheringToString) {
- EXPECT_EQ("Not Detected",
- BoxedValue(new ConnectionTethering(
- ConnectionTethering::kNotDetected)).ToString());
+ EXPECT_EQ(
+ "Not Detected",
+ BoxedValue(new ConnectionTethering(ConnectionTethering::kNotDetected))
+ .ToString());
EXPECT_EQ("Suspected",
BoxedValue(new ConnectionTethering(ConnectionTethering::kSuspected))
- .ToString());
+ .ToString());
EXPECT_EQ("Confirmed",
BoxedValue(new ConnectionTethering(ConnectionTethering::kConfirmed))
- .ToString());
+ .ToString());
EXPECT_EQ("Unknown",
BoxedValue(new ConnectionTethering(ConnectionTethering::kUnknown))
- .ToString());
+ .ToString());
}
TEST(UmBoxedValueTest, RollbackToTargetVersionToString) {
@@ -234,18 +234,15 @@
}
TEST(UmBoxedValueTest, StageToString) {
- EXPECT_EQ("Idle",
- BoxedValue(new Stage(Stage::kIdle)).ToString());
+ EXPECT_EQ("Idle", BoxedValue(new Stage(Stage::kIdle)).ToString());
EXPECT_EQ("Checking For Update",
BoxedValue(new Stage(Stage::kCheckingForUpdate)).ToString());
EXPECT_EQ("Update Available",
BoxedValue(new Stage(Stage::kUpdateAvailable)).ToString());
EXPECT_EQ("Downloading",
BoxedValue(new Stage(Stage::kDownloading)).ToString());
- EXPECT_EQ("Verifying",
- BoxedValue(new Stage(Stage::kVerifying)).ToString());
- EXPECT_EQ("Finalizing",
- BoxedValue(new Stage(Stage::kFinalizing)).ToString());
+ EXPECT_EQ("Verifying", BoxedValue(new Stage(Stage::kVerifying)).ToString());
+ EXPECT_EQ("Finalizing", BoxedValue(new Stage(Stage::kFinalizing)).ToString());
EXPECT_EQ("Updated, Need Reboot",
BoxedValue(new Stage(Stage::kUpdatedNeedReboot)).ToString());
EXPECT_EQ("Reporting Error Event",
diff --git a/update_manager/chromeos_policy.cc b/update_manager/chromeos_policy.cc
index 587ac67..bdb88f8 100644
--- a/update_manager/chromeos_policy.cc
+++ b/update_manager/chromeos_policy.cc
@@ -154,22 +154,22 @@
<< " (" << static_cast<int>(err_code) << ")";
return false;
- case ErrorCode::kSuccess: // success code
- case ErrorCode::kUmaReportedMax: // not an error code
- case ErrorCode::kOmahaRequestHTTPResponseBase: // aggregated already
- case ErrorCode::kDevModeFlag: // not an error code
- case ErrorCode::kResumedFlag: // not an error code
- case ErrorCode::kTestImageFlag: // not an error code
- case ErrorCode::kTestOmahaUrlFlag: // not an error code
- case ErrorCode::kSpecialFlags: // not an error code
+ case ErrorCode::kSuccess: // success code
+ case ErrorCode::kUmaReportedMax: // not an error code
+ case ErrorCode::kOmahaRequestHTTPResponseBase: // aggregated already
+ case ErrorCode::kDevModeFlag: // not an error code
+ case ErrorCode::kResumedFlag: // not an error code
+ case ErrorCode::kTestImageFlag: // not an error code
+ case ErrorCode::kTestOmahaUrlFlag: // not an error code
+ case ErrorCode::kSpecialFlags: // not an error code
// These shouldn't happen. Enumerating these explicitly here so that we
// can let the compiler warn about new error codes that are added to
// action_processor.h but not added here.
LOG(WARNING) << "Unexpected error "
<< chromeos_update_engine::utils::ErrorCodeToString(err_code)
<< " (" << static_cast<int>(err_code) << ")";
- // Note: Not adding a default here so as to let the compiler warn us of
- // any new enums that were added in the .h but not listed in this switch.
+ // Note: Not adding a default here so as to let the compiler warn us of
+ // any new enums that were added in the .h but not listed in this switch.
}
return false;
}
@@ -177,8 +177,8 @@
// Checks whether |url| can be used under given download restrictions.
bool IsUrlUsable(const string& url, bool http_allowed) {
return http_allowed ||
- !base::StartsWith(url, "http://",
- base::CompareCase::INSENSITIVE_ASCII);
+ !base::StartsWith(
+ url, "http://", base::CompareCase::INSENSITIVE_ASCII);
}
} // namespace
@@ -198,9 +198,10 @@
const int ChromeOSPolicy::kMaxP2PAttempts = 10;
const int ChromeOSPolicy::kMaxP2PAttemptsPeriodInSeconds = 5 * 24 * 60 * 60;
-EvalStatus ChromeOSPolicy::UpdateCheckAllowed(
- EvaluationContext* ec, State* state, string* error,
- UpdateCheckParams* result) const {
+EvalStatus ChromeOSPolicy::UpdateCheckAllowed(EvaluationContext* ec,
+ State* state,
+ string* error,
+ UpdateCheckParams* result) const {
// Set the default return values.
result->updates_enabled = true;
result->target_channel.clear();
@@ -343,8 +344,8 @@
bool is_scattering_active = false;
EvalStatus scattering_status = EvalStatus::kSucceeded;
- const bool* device_policy_is_loaded_p = ec->GetValue(
- dp_provider->var_device_policy_is_loaded());
+ const bool* device_policy_is_loaded_p =
+ ec->GetValue(dp_provider->var_device_policy_is_loaded());
if (device_policy_is_loaded_p && *device_policy_is_loaded_p) {
// Check whether scattering applies to this update attempt. We should not be
// scattering if this is an interactive update check, or if OOBE is enabled
@@ -358,13 +359,13 @@
result->scatter_wait_period = kZeroInterval;
result->scatter_check_threshold = 0;
if (!update_state.interactive) {
- const bool* is_oobe_enabled_p = ec->GetValue(
- state->config_provider()->var_is_oobe_enabled());
+ const bool* is_oobe_enabled_p =
+ ec->GetValue(state->config_provider()->var_is_oobe_enabled());
if (is_oobe_enabled_p && !(*is_oobe_enabled_p)) {
is_scattering_applicable = true;
} else {
- const bool* is_oobe_complete_p = ec->GetValue(
- state->system_provider()->var_is_oobe_complete());
+ const bool* is_oobe_complete_p =
+ ec->GetValue(state->system_provider()->var_is_oobe_complete());
is_scattering_applicable = (is_oobe_complete_p && *is_oobe_complete_p);
}
}
@@ -372,8 +373,8 @@
// Compute scattering values.
if (is_scattering_applicable) {
UpdateScatteringResult scatter_result;
- scattering_status = UpdateScattering(ec, state, error, &scatter_result,
- update_state);
+ scattering_status =
+ UpdateScattering(ec, state, error, &scatter_result, update_state);
if (scattering_status == EvalStatus::kFailed) {
return EvalStatus::kFailed;
} else {
@@ -461,22 +462,21 @@
// updates over a cellular network (disabled by default). We may want to
// revisit this semantics, allowing greater flexibility in defining specific
// permissions over all types of networks.
-EvalStatus ChromeOSPolicy::UpdateDownloadAllowed(
- EvaluationContext* ec,
- State* state,
- string* error,
- bool* result) const {
+EvalStatus ChromeOSPolicy::UpdateDownloadAllowed(EvaluationContext* ec,
+ State* state,
+ string* error,
+ bool* result) const {
// Get the current connection type.
ShillProvider* const shill_provider = state->shill_provider();
- const ConnectionType* conn_type_p = ec->GetValue(
- shill_provider->var_conn_type());
+ const ConnectionType* conn_type_p =
+ ec->GetValue(shill_provider->var_conn_type());
POLICY_CHECK_VALUE_AND_FAIL(conn_type_p, error);
ConnectionType conn_type = *conn_type_p;
// If we're tethering, treat it as a cellular connection.
if (conn_type != ConnectionType::kCellular) {
- const ConnectionTethering* conn_tethering_p = ec->GetValue(
- shill_provider->var_conn_tethering());
+ const ConnectionTethering* conn_tethering_p =
+ ec->GetValue(shill_provider->var_conn_tethering());
POLICY_CHECK_VALUE_AND_FAIL(conn_tethering_p, error);
if (*conn_tethering_p == ConnectionTethering::kConfirmed)
conn_type = ConnectionType::kCellular;
@@ -513,11 +513,11 @@
// Check whether the device policy specifically allows this connection.
if (device_policy_can_override) {
DevicePolicyProvider* const dp_provider = state->device_policy_provider();
- const bool* device_policy_is_loaded_p = ec->GetValue(
- dp_provider->var_device_policy_is_loaded());
+ const bool* device_policy_is_loaded_p =
+ ec->GetValue(dp_provider->var_device_policy_is_loaded());
if (device_policy_is_loaded_p && *device_policy_is_loaded_p) {
- const set<ConnectionType>* allowed_conn_types_p = ec->GetValue(
- dp_provider->var_allowed_connection_types_for_update());
+ const set<ConnectionType>* allowed_conn_types_p =
+ ec->GetValue(dp_provider->var_allowed_connection_types_for_update());
if (allowed_conn_types_p) {
if (allowed_conn_types_p->count(conn_type)) {
*result = true;
@@ -526,8 +526,8 @@
} else if (conn_type == ConnectionType::kCellular) {
// Local user settings can allow updates over cellular iff a policy was
// loaded but no allowed connections were specified in it.
- const bool* update_over_cellular_allowed_p = ec->GetValue(
- state->updater_provider()->var_cellular_enabled());
+ const bool* update_over_cellular_allowed_p =
+ ec->GetValue(state->updater_provider()->var_cellular_enabled());
if (update_over_cellular_allowed_p && *update_over_cellular_allowed_p)
*result = true;
}
@@ -547,11 +547,11 @@
// explicitly allowed, we allow it if the device is enterprise enrolled (that
// is, missing or empty owner string).
DevicePolicyProvider* const dp_provider = state->device_policy_provider();
- const bool* device_policy_is_loaded_p = ec->GetValue(
- dp_provider->var_device_policy_is_loaded());
+ const bool* device_policy_is_loaded_p =
+ ec->GetValue(dp_provider->var_device_policy_is_loaded());
if (device_policy_is_loaded_p && *device_policy_is_loaded_p) {
- const bool* policy_au_p2p_enabled_p = ec->GetValue(
- dp_provider->var_au_p2p_enabled());
+ const bool* policy_au_p2p_enabled_p =
+ ec->GetValue(dp_provider->var_au_p2p_enabled());
if (policy_au_p2p_enabled_p) {
enabled = *policy_au_p2p_enabled_p;
} else {
@@ -564,8 +564,8 @@
// Enable P2P, if so mandated by the updater configuration. This is additive
// to whether or not P2P is enabled by device policy.
if (!enabled) {
- const bool* updater_p2p_enabled_p = ec->GetValue(
- state->updater_provider()->var_p2p_enabled());
+ const bool* updater_p2p_enabled_p =
+ ec->GetValue(state->updater_provider()->var_p2p_enabled());
enabled = updater_p2p_enabled_p && *updater_p2p_enabled_p;
}
@@ -585,7 +585,9 @@
}
EvalStatus ChromeOSPolicy::UpdateBackoffAndDownloadUrl(
- EvaluationContext* ec, State* state, string* error,
+ EvaluationContext* ec,
+ State* state,
+ string* error,
UpdateBackoffAndDownloadUrlResult* result,
const UpdateState& update_state) const {
// Sanity checks.
@@ -597,8 +599,8 @@
result->url_idx = -1;
result->url_num_errors = 0;
- const bool* is_official_build_p = ec->GetValue(
- state->system_provider()->var_is_official_build());
+ const bool* is_official_build_p =
+ ec->GetValue(state->system_provider()->var_is_official_build());
bool is_official_build = (is_official_build_p ? *is_official_build_p : true);
// Check whether backoff is enabled.
@@ -627,11 +629,11 @@
bool http_allowed = true;
if (is_official_build) {
DevicePolicyProvider* const dp_provider = state->device_policy_provider();
- const bool* device_policy_is_loaded_p = ec->GetValue(
- dp_provider->var_device_policy_is_loaded());
+ const bool* device_policy_is_loaded_p =
+ ec->GetValue(dp_provider->var_device_policy_is_loaded());
if (device_policy_is_loaded_p && *device_policy_is_loaded_p) {
- const bool* policy_http_downloads_enabled_p = ec->GetValue(
- dp_provider->var_http_downloads_enabled());
+ const bool* policy_http_downloads_enabled_p =
+ ec->GetValue(dp_provider->var_http_downloads_enabled());
http_allowed = (!policy_http_downloads_enabled_p ||
*policy_http_downloads_enabled_p);
}
@@ -753,8 +755,8 @@
const uint64_t* seed = ec->GetValue(state->random_provider()->var_seed());
POLICY_CHECK_VALUE_AND_FAIL(seed, error);
PRNG prng(*seed);
- int exp = min(update_state.num_failures,
- static_cast<int>(sizeof(int)) * 8 - 2);
+ int exp =
+ min(update_state.num_failures, static_cast<int>(sizeof(int)) * 8 - 2);
TimeDelta backoff_interval = TimeDelta::FromDays(min(
1 << exp,
kNextUpdateCheckPolicyConstants.attempt_backoff_max_interval_in_days));
@@ -794,14 +796,14 @@
DevicePolicyProvider* const dp_provider = state->device_policy_provider();
// Ensure that a device policy is loaded.
- const bool* device_policy_is_loaded_p = ec->GetValue(
- dp_provider->var_device_policy_is_loaded());
+ const bool* device_policy_is_loaded_p =
+ ec->GetValue(dp_provider->var_device_policy_is_loaded());
if (!(device_policy_is_loaded_p && *device_policy_is_loaded_p))
return EvalStatus::kSucceeded;
// Is scattering enabled by policy?
- const TimeDelta* scatter_factor_p = ec->GetValue(
- dp_provider->var_scatter_factor());
+ const TimeDelta* scatter_factor_p =
+ ec->GetValue(dp_provider->var_scatter_factor());
if (!scatter_factor_p || *scatter_factor_p == kZeroInterval)
return EvalStatus::kSucceeded;
@@ -833,9 +835,8 @@
// one.
int check_threshold = update_state.scatter_check_threshold;
if (check_threshold == 0) {
- check_threshold = prng.RandMinMax(
- update_state.scatter_check_threshold_min,
- update_state.scatter_check_threshold_max);
+ check_threshold = prng.RandMinMax(update_state.scatter_check_threshold_min,
+ update_state.scatter_check_threshold_max);
}
// If the update check threshold is not within allowed range then nullify it.
diff --git a/update_manager/chromeos_policy.h b/update_manager/chromeos_policy.h
index d4ce4a6..ded5164 100644
--- a/update_manager/chromeos_policy.h
+++ b/update_manager/chromeos_policy.h
@@ -54,9 +54,10 @@
~ChromeOSPolicy() override {}
// Policy overrides.
- EvalStatus UpdateCheckAllowed(
- EvaluationContext* ec, State* state, std::string* error,
- UpdateCheckParams* result) const override;
+ EvalStatus UpdateCheckAllowed(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ UpdateCheckParams* result) const override;
EvalStatus UpdateCanBeApplied(
EvaluationContext* ec,
@@ -65,31 +66,27 @@
chromeos_update_engine::ErrorCode* result,
chromeos_update_engine::InstallPlan* install_plan) const override;
- EvalStatus UpdateCanStart(
- EvaluationContext* ec,
- State* state,
- std::string* error,
- UpdateDownloadParams* result,
- UpdateState update_state) const override;
+ EvalStatus UpdateCanStart(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ UpdateDownloadParams* result,
+ UpdateState update_state) const override;
- EvalStatus UpdateDownloadAllowed(
- EvaluationContext* ec,
- State* state,
- std::string* error,
- bool* result) const override;
+ EvalStatus UpdateDownloadAllowed(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ bool* result) const override;
- EvalStatus P2PEnabled(
- EvaluationContext* ec,
- State* state,
- std::string* error,
- bool* result) const override;
+ EvalStatus P2PEnabled(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ bool* result) const override;
- EvalStatus P2PEnabledChanged(
- EvaluationContext* ec,
- State* state,
- std::string* error,
- bool* result,
- bool prev_result) const override;
+ EvalStatus P2PEnabledChanged(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ bool* result,
+ bool prev_result) const override;
protected:
// Policy override.
@@ -151,7 +148,9 @@
// In any of these cases, returns |EvalStatus::kSucceeded|. If an error
// occurred, returns |EvalStatus::kFailed|.
EvalStatus UpdateBackoffAndDownloadUrl(
- EvaluationContext* ec, State* state, std::string* error,
+ EvaluationContext* ec,
+ State* state,
+ std::string* error,
UpdateBackoffAndDownloadUrlResult* result,
const UpdateState& update_state) const;
@@ -167,7 +166,8 @@
// threshold, or zero if no such threshold is known. If not scattering, or if
// any of the scattering values has changed, returns |EvalStatus::kSucceeded|;
// otherwise, |EvalStatus::kAskMeAgainLater|.
- EvalStatus UpdateScattering(EvaluationContext* ec, State* state,
+ EvalStatus UpdateScattering(EvaluationContext* ec,
+ State* state,
std::string* error,
UpdateScatteringResult* result,
const UpdateState& update_state) const;
diff --git a/update_manager/chromeos_policy_unittest.cc b/update_manager/chromeos_policy_unittest.cc
index 15bb09f..5341ebb 100644
--- a/update_manager/chromeos_policy_unittest.cc
+++ b/update_manager/chromeos_policy_unittest.cc
@@ -49,8 +49,7 @@
UmPolicyTestBase::SetUpDefaultState();
// OOBE is enabled by default.
- fake_state_.config_provider()->var_is_oobe_enabled()->reset(
- new bool(true));
+ fake_state_.config_provider()->var_is_oobe_enabled()->reset(new bool(true));
// For the purpose of the tests, this is an official build and OOBE was
// completed.
@@ -62,10 +61,10 @@
fake_state_.system_provider()->var_num_slots()->reset(new unsigned int(2));
// Connection is wifi, untethered.
- fake_state_.shill_provider()->var_conn_type()->
- reset(new ConnectionType(ConnectionType::kWifi));
- fake_state_.shill_provider()->var_conn_tethering()->
- reset(new ConnectionTethering(ConnectionTethering::kNotDetected));
+ fake_state_.shill_provider()->var_conn_type()->reset(
+ new ConnectionType(ConnectionType::kWifi));
+ fake_state_.shill_provider()->var_conn_tethering()->reset(
+ new ConnectionTethering(ConnectionTethering::kNotDetected));
}
// Sets up a default device policy that does not impose any restrictions
@@ -75,16 +74,18 @@
new bool(true));
fake_state_.device_policy_provider()->var_update_disabled()->reset(
new bool(false));
- fake_state_.device_policy_provider()->
- var_allowed_connection_types_for_update()->reset(nullptr);
+ fake_state_.device_policy_provider()
+ ->var_allowed_connection_types_for_update()
+ ->reset(nullptr);
fake_state_.device_policy_provider()->var_scatter_factor()->reset(
new TimeDelta());
fake_state_.device_policy_provider()->var_http_downloads_enabled()->reset(
new bool(true));
fake_state_.device_policy_provider()->var_au_p2p_enabled()->reset(
new bool(false));
- fake_state_.device_policy_provider()->var_release_channel_delegated()->
- reset(new bool(true));
+ fake_state_.device_policy_provider()
+ ->var_release_channel_delegated()
+ ->reset(new bool(true));
fake_state_.device_policy_provider()
->var_disallowed_time_intervals()
->reset(new WeeklyTimeIntervalVector());
@@ -195,16 +196,16 @@
fake_state_.updater_provider()->var_last_checked_time()->reset(
new Time(last_checked_time));
fake_clock_.SetWallclockTime(next_update_check - TimeDelta::FromSeconds(1));
- ExpectPolicyStatus(EvalStatus::kAskMeAgainLater,
- &Policy::UpdateCheckAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kAskMeAgainLater, &Policy::UpdateCheckAllowed, &result);
SetUpDefaultClock();
SetUpDefaultState();
fake_state_.updater_provider()->var_last_checked_time()->reset(
new Time(last_checked_time));
fake_clock_.SetWallclockTime(next_update_check + TimeDelta::FromSeconds(1));
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateCheckAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCheckAllowed, &result);
EXPECT_TRUE(result.updates_enabled);
EXPECT_FALSE(result.interactive);
}
@@ -228,12 +229,11 @@
fake_state_.updater_provider()->var_last_checked_time()->reset(
new Time(last_checked_time));
fake_clock_.SetWallclockTime(next_update_check + TimeDelta::FromSeconds(1));
- fake_state_.system_provider()->var_is_oobe_complete()->reset(
- new bool(false));
+ fake_state_.system_provider()->var_is_oobe_complete()->reset(new bool(false));
UpdateCheckParams result;
- ExpectPolicyStatus(EvalStatus::kAskMeAgainLater,
- &Policy::UpdateCheckAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kAskMeAgainLater, &Policy::UpdateCheckAllowed, &result);
// Now check that it is allowed if OOBE is completed.
SetUpDefaultClock();
@@ -241,8 +241,8 @@
fake_state_.updater_provider()->var_last_checked_time()->reset(
new Time(last_checked_time));
fake_clock_.SetWallclockTime(next_update_check + TimeDelta::FromSeconds(1));
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateCheckAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCheckAllowed, &result);
EXPECT_TRUE(result.updates_enabled);
EXPECT_FALSE(result.interactive);
}
@@ -253,19 +253,19 @@
SetUpdateCheckAllowed(true);
// Override specific device policy attributes.
- fake_state_.device_policy_provider()->var_target_version_prefix()->
- reset(new string("1.2"));
+ fake_state_.device_policy_provider()->var_target_version_prefix()->reset(
+ new string("1.2"));
fake_state_.device_policy_provider()
->var_rollback_allowed_milestones()
->reset(new int(5));
fake_state_.device_policy_provider()->var_release_channel_delegated()->reset(
new bool(false));
- fake_state_.device_policy_provider()->var_release_channel()->
- reset(new string("foo-channel"));
+ fake_state_.device_policy_provider()->var_release_channel()->reset(
+ new string("foo-channel"));
UpdateCheckParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateCheckAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCheckAllowed, &result);
EXPECT_TRUE(result.updates_enabled);
EXPECT_EQ("1.2", result.target_version_prefix);
EXPECT_EQ(5, result.rollback_allowed_milestones);
@@ -340,8 +340,8 @@
new bool(false));
UpdateCheckParams result;
- ExpectPolicyStatus(EvalStatus::kAskMeAgainLater,
- &Policy::UpdateCheckAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kAskMeAgainLater, &Policy::UpdateCheckAllowed, &result);
}
TEST_F(UmChromeOSPolicyTest,
@@ -353,8 +353,8 @@
fake_state_.system_provider()->var_num_slots()->reset(new unsigned int(1));
UpdateCheckParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateCheckAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCheckAllowed, &result);
EXPECT_FALSE(result.updates_enabled);
}
@@ -367,8 +367,8 @@
new bool(true));
UpdateCheckParams result;
- ExpectPolicyStatus(EvalStatus::kAskMeAgainLater,
- &Policy::UpdateCheckAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kAskMeAgainLater, &Policy::UpdateCheckAllowed, &result);
}
TEST_F(UmChromeOSPolicyTest,
@@ -381,8 +381,8 @@
new UpdateRequestStatus(UpdateRequestStatus::kInteractive));
UpdateCheckParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateCheckAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCheckAllowed, &result);
EXPECT_TRUE(result.updates_enabled);
EXPECT_TRUE(result.interactive);
}
@@ -396,8 +396,8 @@
new UpdateRequestStatus(UpdateRequestStatus::kPeriodic));
UpdateCheckParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateCheckAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCheckAllowed, &result);
EXPECT_TRUE(result.updates_enabled);
EXPECT_FALSE(result.interactive);
}
@@ -409,8 +409,8 @@
SetKioskAppControlsChromeOsVersion();
UpdateCheckParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateCheckAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCheckAllowed, &result);
EXPECT_TRUE(result.updates_enabled);
EXPECT_EQ("1234.", result.target_version_prefix);
EXPECT_FALSE(result.interactive);
@@ -429,8 +429,8 @@
->reset(new bool(false));
UpdateCheckParams result;
- ExpectPolicyStatus(EvalStatus::kAskMeAgainLater,
- &Policy::UpdateCheckAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kAskMeAgainLater, &Policy::UpdateCheckAllowed, &result);
}
TEST_F(UmChromeOSPolicyTest, UpdateCheckAllowedKioskPinWithNoRequiredVersion) {
@@ -449,8 +449,8 @@
new string());
UpdateCheckParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateCheckAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCheckAllowed, &result);
EXPECT_TRUE(result.updates_enabled);
EXPECT_TRUE(result.target_version_prefix.empty());
EXPECT_FALSE(result.interactive);
@@ -469,8 +469,8 @@
nullptr);
UpdateCheckParams result;
- ExpectPolicyStatus(EvalStatus::kAskMeAgainLater,
- &Policy::UpdateCheckAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kAskMeAgainLater, &Policy::UpdateCheckAllowed, &result);
}
TEST_F(UmChromeOSPolicyTest, UpdateCanStartFailsCheckAllowedError) {
@@ -483,8 +483,8 @@
// Check that the UpdateCanStart fails.
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromMinutes(10));
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kFailed,
- &Policy::UpdateCanStart, &result, update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kFailed, &Policy::UpdateCanStart, &result, update_state);
}
TEST_F(UmChromeOSPolicyTest, UpdateCanStartNotAllowedCheckDue) {
@@ -496,8 +496,8 @@
// Check that the UpdateCanStart returns false.
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromMinutes(10));
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateCanStart, &result, update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_FALSE(result.update_can_start);
EXPECT_EQ(UpdateCannotStartReason::kCheckDue, result.cannot_start_reason);
EXPECT_EQ(0, result.download_url_idx);
@@ -514,8 +514,8 @@
// Check that the UpdateCanStart returns true with no further attributes.
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromMinutes(10));
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateCanStart, &result, update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_FALSE(result.p2p_downloading_allowed);
EXPECT_FALSE(result.p2p_sharing_allowed);
@@ -534,8 +534,8 @@
// Check that the UpdateCanStart returns true.
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromMinutes(10));
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateCanStart, &result, update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_FALSE(result.p2p_downloading_allowed);
EXPECT_FALSE(result.p2p_sharing_allowed);
@@ -556,17 +556,19 @@
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromSeconds(10));
update_state.download_errors_max = 1;
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(8));
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(2));
// Check that UpdateCanStart returns false and a new backoff expiry is
// generated.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_FALSE(result.update_can_start);
EXPECT_EQ(UpdateCannotStartReason::kBackoff, result.cannot_start_reason);
EXPECT_TRUE(result.do_increment_failures);
@@ -584,10 +586,12 @@
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromSeconds(10));
update_state.download_errors_max = 1;
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(8));
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(2));
update_state.failures_last_updated = curr_time;
update_state.backoff_expiry = curr_time + TimeDelta::FromMinutes(3);
@@ -595,8 +599,10 @@
// Check that UpdateCanStart returns false and a new backoff expiry is
// generated.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kAskMeAgainLater, &Policy::UpdateCanStart,
- &result, update_state);
+ ExpectPolicyStatus(EvalStatus::kAskMeAgainLater,
+ &Policy::UpdateCanStart,
+ &result,
+ update_state);
EXPECT_FALSE(result.update_can_start);
EXPECT_EQ(UpdateCannotStartReason::kBackoff, result.cannot_start_reason);
EXPECT_FALSE(result.do_increment_failures);
@@ -613,10 +619,12 @@
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromSeconds(10));
update_state.download_errors_max = 1;
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(8));
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(2));
update_state.failures_last_updated = curr_time - TimeDelta::FromSeconds(1);
update_state.backoff_expiry = curr_time - TimeDelta::FromSeconds(1);
@@ -624,8 +632,8 @@
// Check that UpdateCanStart returns false and a new backoff expiry is
// generated.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart,
- &result, update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(UpdateCannotStartReason::kUndefined, result.cannot_start_reason);
EXPECT_EQ(0, result.download_url_idx);
@@ -645,18 +653,20 @@
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromSeconds(10));
update_state.download_errors_max = 1;
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(8));
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(2));
update_state.is_backoff_disabled = true;
// Check that UpdateCanStart returns false and a new backoff expiry is
// generated.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(UpdateCannotStartReason::kUndefined, result.cannot_start_reason);
EXPECT_EQ(0, result.download_url_idx);
@@ -676,18 +686,20 @@
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromSeconds(10));
update_state.download_errors_max = 1;
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(8));
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(2));
update_state.interactive = true;
// Check that UpdateCanStart returns false and a new backoff expiry is
// generated.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(UpdateCannotStartReason::kUndefined, result.cannot_start_reason);
EXPECT_EQ(0, result.download_url_idx);
@@ -707,18 +719,20 @@
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromSeconds(10));
update_state.download_errors_max = 1;
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(8));
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(2));
update_state.is_delta_payload = true;
// Check that UpdateCanStart returns false and a new backoff expiry is
// generated.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(UpdateCannotStartReason::kUndefined, result.cannot_start_reason);
EXPECT_EQ(0, result.download_url_idx);
@@ -738,20 +752,22 @@
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromSeconds(10));
update_state.download_errors_max = 1;
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(8));
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(2));
- fake_state_.system_provider()->var_is_official_build()->
- reset(new bool(false));
+ fake_state_.system_provider()->var_is_official_build()->reset(
+ new bool(false));
// Check that UpdateCanStart returns false and a new backoff expiry is
// generated.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(UpdateCannotStartReason::kUndefined, result.cannot_start_reason);
EXPECT_EQ(0, result.download_url_idx);
@@ -777,8 +793,8 @@
// Check that the UpdateCanStart fails.
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromSeconds(1));
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kFailed,
- &Policy::UpdateCanStart, &result, update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kFailed, &Policy::UpdateCanStart, &result, update_state);
}
TEST_F(UmChromeOSPolicyTest,
@@ -791,14 +807,13 @@
fake_state_.device_policy_provider()->var_scatter_factor()->reset(
new TimeDelta(TimeDelta::FromMinutes(2)));
-
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromSeconds(1));
// Check that the UpdateCanStart returns false and a new wait period
// generated.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_FALSE(result.update_can_start);
EXPECT_EQ(UpdateCannotStartReason::kScattering, result.cannot_start_reason);
EXPECT_LT(TimeDelta(), result.scatter_wait_period);
@@ -821,8 +836,10 @@
// Check that the UpdateCanStart returns false and a new wait period
// generated.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kAskMeAgainLater, &Policy::UpdateCanStart,
- &result, update_state);
+ ExpectPolicyStatus(EvalStatus::kAskMeAgainLater,
+ &Policy::UpdateCanStart,
+ &result,
+ update_state);
EXPECT_FALSE(result.update_can_start);
EXPECT_EQ(UpdateCannotStartReason::kScattering, result.cannot_start_reason);
EXPECT_EQ(TimeDelta::FromSeconds(35), result.scatter_wait_period);
@@ -847,8 +864,8 @@
// Check that the UpdateCanStart returns false.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_FALSE(result.update_can_start);
EXPECT_EQ(UpdateCannotStartReason::kScattering, result.cannot_start_reason);
EXPECT_LE(2, result.scatter_check_threshold);
@@ -871,8 +888,8 @@
// Check that the UpdateCanStart returns false.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_FALSE(result.update_can_start);
EXPECT_EQ(UpdateCannotStartReason::kScattering, result.cannot_start_reason);
EXPECT_EQ(3, result.scatter_check_threshold);
@@ -896,8 +913,8 @@
// Check that the UpdateCanStart returns true.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(TimeDelta(), result.scatter_wait_period);
EXPECT_EQ(0, result.scatter_check_threshold);
@@ -925,8 +942,8 @@
// Check that the UpdateCanStart returns true.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(TimeDelta(), result.scatter_wait_period);
EXPECT_EQ(0, result.scatter_check_threshold);
@@ -936,8 +953,7 @@
EXPECT_FALSE(result.do_increment_failures);
}
-TEST_F(UmChromeOSPolicyTest,
- UpdateCanStartAllowedOobePreventsScattering) {
+TEST_F(UmChromeOSPolicyTest, UpdateCanStartAllowedOobePreventsScattering) {
// The UpdateCanStart policy returns true; device policy is loaded and
// scattering would have applied, except that OOBE was not completed and so it
// is suppressed.
@@ -955,8 +971,8 @@
// Check that the UpdateCanStart returns true.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(TimeDelta(), result.scatter_wait_period);
EXPECT_EQ(0, result.scatter_check_threshold);
@@ -981,8 +997,8 @@
// Check that the UpdateCanStart returns true.
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromMinutes(10));
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_TRUE(result.p2p_downloading_allowed);
EXPECT_TRUE(result.p2p_sharing_allowed);
@@ -1005,8 +1021,8 @@
// Check that the UpdateCanStart returns true.
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromMinutes(10));
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_TRUE(result.p2p_downloading_allowed);
EXPECT_TRUE(result.p2p_sharing_allowed);
@@ -1034,15 +1050,14 @@
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromMinutes(10));
update_state.p2p_downloading_disabled = true;
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_FALSE(result.p2p_downloading_allowed);
EXPECT_TRUE(result.p2p_sharing_allowed);
}
-TEST_F(UmChromeOSPolicyTest,
- UpdateCanStartAllowedP2PSharingBlockedDueToOmaha) {
+TEST_F(UmChromeOSPolicyTest, UpdateCanStartAllowedP2PSharingBlockedDueToOmaha) {
// The UpdateCanStart policy returns true; device policy permits HTTP, but
// policy blocks P2P sharing because Omaha forbids it. P2P downloading is
// still permitted.
@@ -1059,8 +1074,8 @@
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromMinutes(10));
update_state.p2p_sharing_disabled = true;
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_TRUE(result.p2p_downloading_allowed);
EXPECT_FALSE(result.p2p_sharing_allowed);
@@ -1084,8 +1099,8 @@
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromMinutes(10));
update_state.p2p_num_attempts = ChromeOSPolicy::kMaxP2PAttempts;
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_FALSE(result.p2p_downloading_allowed);
EXPECT_TRUE(result.p2p_sharing_allowed);
@@ -1110,11 +1125,11 @@
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);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_FALSE(result.p2p_downloading_allowed);
EXPECT_TRUE(result.p2p_sharing_allowed);
@@ -1131,14 +1146,14 @@
// Override specific device policy attributes.
fake_state_.device_policy_provider()->var_http_downloads_enabled()->reset(
new bool(false));
- fake_state_.system_provider()->var_is_official_build()->
- reset(new bool(false));
+ fake_state_.system_provider()->var_is_official_build()->reset(
+ new bool(false));
// Check that the UpdateCanStart returns true.
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromMinutes(10));
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(0, result.download_url_idx);
EXPECT_TRUE(result.download_url_allowed);
@@ -1162,8 +1177,8 @@
// Check that the UpdateCanStart returns true.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(1, result.download_url_idx);
EXPECT_TRUE(result.download_url_allowed);
@@ -1192,8 +1207,8 @@
// Check that the UpdateCanStart returns true.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(0, result.download_url_idx);
EXPECT_TRUE(result.download_url_allowed);
@@ -1221,8 +1236,8 @@
// Check that the UpdateCanStart returns true.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(1, result.download_url_idx);
EXPECT_TRUE(result.download_url_allowed);
@@ -1242,13 +1257,14 @@
update_state.num_checks = 10;
update_state.download_urls.emplace_back("http://another/fake/url/");
update_state.download_errors.emplace_back(
- 0, ErrorCode::kPayloadHashMismatchError,
+ 0,
+ ErrorCode::kPayloadHashMismatchError,
fake_clock_.GetWallclockTime() - TimeDelta::FromSeconds(1));
// Check that the UpdateCanStart returns true.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(1, result.download_url_idx);
EXPECT_TRUE(result.download_url_allowed);
@@ -1270,13 +1286,14 @@
update_state.is_backoff_disabled = true;
update_state.download_urls.emplace_back("http://another/fake/url/");
update_state.download_errors.emplace_back(
- 1, ErrorCode::kPayloadHashMismatchError,
+ 1,
+ ErrorCode::kPayloadHashMismatchError,
fake_clock_.GetWallclockTime() - TimeDelta::FromSeconds(1));
// Check that the UpdateCanStart returns true.
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(0, result.download_url_idx);
EXPECT_TRUE(result.download_url_allowed);
@@ -1302,8 +1319,8 @@
// Check that the UpdateCanStart returns false.
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromMinutes(10));
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_FALSE(result.update_can_start);
EXPECT_EQ(UpdateCannotStartReason::kCannotDownload,
result.cannot_start_reason);
@@ -1329,8 +1346,8 @@
// Check that the UpdateCanStart returns true.
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromMinutes(10));
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_TRUE(result.p2p_downloading_allowed);
EXPECT_TRUE(result.p2p_sharing_allowed);
@@ -1361,8 +1378,8 @@
// Check that the UpdateCanStart returns true.
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromMinutes(10));
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_TRUE(result.p2p_downloading_allowed);
EXPECT_TRUE(result.p2p_sharing_allowed);
@@ -1375,24 +1392,24 @@
TEST_F(UmChromeOSPolicyTest, UpdateDownloadAllowedEthernetDefault) {
// Ethernet is always allowed.
- fake_state_.shill_provider()->var_conn_type()->
- reset(new ConnectionType(ConnectionType::kEthernet));
+ fake_state_.shill_provider()->var_conn_type()->reset(
+ new ConnectionType(ConnectionType::kEthernet));
bool result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateDownloadAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateDownloadAllowed, &result);
EXPECT_TRUE(result);
}
TEST_F(UmChromeOSPolicyTest, UpdateDownloadAllowedWifiDefault) {
// Wifi is allowed if not tethered.
- fake_state_.shill_provider()->var_conn_type()->
- reset(new ConnectionType(ConnectionType::kWifi));
+ fake_state_.shill_provider()->var_conn_type()->reset(
+ new ConnectionType(ConnectionType::kWifi));
bool result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateDownloadAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateDownloadAllowed, &result);
EXPECT_TRUE(result);
}
@@ -1400,45 +1417,44 @@
UpdateCurrentConnectionNotAllowedWifiTetheredDefault) {
// Tethered wifi is not allowed by default.
- fake_state_.shill_provider()->var_conn_type()->
- reset(new ConnectionType(ConnectionType::kWifi));
- fake_state_.shill_provider()->var_conn_tethering()->
- reset(new ConnectionTethering(ConnectionTethering::kConfirmed));
+ fake_state_.shill_provider()->var_conn_type()->reset(
+ new ConnectionType(ConnectionType::kWifi));
+ fake_state_.shill_provider()->var_conn_tethering()->reset(
+ new ConnectionTethering(ConnectionTethering::kConfirmed));
bool result;
- ExpectPolicyStatus(EvalStatus::kAskMeAgainLater,
- &Policy::UpdateDownloadAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kAskMeAgainLater, &Policy::UpdateDownloadAllowed, &result);
}
-TEST_F(UmChromeOSPolicyTest,
- UpdateDownloadAllowedWifiTetheredPolicyOverride) {
+TEST_F(UmChromeOSPolicyTest, UpdateDownloadAllowedWifiTetheredPolicyOverride) {
// Tethered wifi can be allowed by policy.
- fake_state_.shill_provider()->var_conn_type()->
- reset(new ConnectionType(ConnectionType::kWifi));
- fake_state_.shill_provider()->var_conn_tethering()->
- reset(new ConnectionTethering(ConnectionTethering::kConfirmed));
+ fake_state_.shill_provider()->var_conn_type()->reset(
+ new ConnectionType(ConnectionType::kWifi));
+ fake_state_.shill_provider()->var_conn_tethering()->reset(
+ new ConnectionTethering(ConnectionTethering::kConfirmed));
set<ConnectionType> allowed_connections;
allowed_connections.insert(ConnectionType::kCellular);
- fake_state_.device_policy_provider()->
- var_allowed_connection_types_for_update()->
- reset(new set<ConnectionType>(allowed_connections));
+ fake_state_.device_policy_provider()
+ ->var_allowed_connection_types_for_update()
+ ->reset(new set<ConnectionType>(allowed_connections));
bool result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateDownloadAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateDownloadAllowed, &result);
EXPECT_TRUE(result);
}
TEST_F(UmChromeOSPolicyTest, UpdateDownloadAllowedWimaxDefault) {
// Wimax is always allowed.
- fake_state_.shill_provider()->var_conn_type()->
- reset(new ConnectionType(ConnectionType::kWifi));
+ fake_state_.shill_provider()->var_conn_type()->reset(
+ new ConnectionType(ConnectionType::kWifi));
bool result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateDownloadAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateDownloadAllowed, &result);
EXPECT_TRUE(result);
}
@@ -1446,80 +1462,76 @@
UpdateCurrentConnectionNotAllowedBluetoothDefault) {
// Bluetooth is never allowed.
- fake_state_.shill_provider()->var_conn_type()->
- reset(new ConnectionType(ConnectionType::kBluetooth));
+ fake_state_.shill_provider()->var_conn_type()->reset(
+ new ConnectionType(ConnectionType::kBluetooth));
bool result;
- ExpectPolicyStatus(EvalStatus::kAskMeAgainLater,
- &Policy::UpdateDownloadAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kAskMeAgainLater, &Policy::UpdateDownloadAllowed, &result);
}
TEST_F(UmChromeOSPolicyTest,
UpdateCurrentConnectionNotAllowedBluetoothPolicyCannotOverride) {
// Bluetooth cannot be allowed even by policy.
- fake_state_.shill_provider()->var_conn_type()->
- reset(new ConnectionType(ConnectionType::kBluetooth));
+ fake_state_.shill_provider()->var_conn_type()->reset(
+ new ConnectionType(ConnectionType::kBluetooth));
set<ConnectionType> allowed_connections;
allowed_connections.insert(ConnectionType::kBluetooth);
- fake_state_.device_policy_provider()->
- var_allowed_connection_types_for_update()->
- reset(new set<ConnectionType>(allowed_connections));
+ fake_state_.device_policy_provider()
+ ->var_allowed_connection_types_for_update()
+ ->reset(new set<ConnectionType>(allowed_connections));
bool result;
- ExpectPolicyStatus(EvalStatus::kAskMeAgainLater,
- &Policy::UpdateDownloadAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kAskMeAgainLater, &Policy::UpdateDownloadAllowed, &result);
}
TEST_F(UmChromeOSPolicyTest, UpdateCurrentConnectionNotAllowedCellularDefault) {
// Cellular is not allowed by default.
- fake_state_.shill_provider()->var_conn_type()->
- reset(new ConnectionType(ConnectionType::kCellular));
+ fake_state_.shill_provider()->var_conn_type()->reset(
+ new ConnectionType(ConnectionType::kCellular));
bool result;
- ExpectPolicyStatus(EvalStatus::kAskMeAgainLater,
- &Policy::UpdateDownloadAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kAskMeAgainLater, &Policy::UpdateDownloadAllowed, &result);
}
-TEST_F(UmChromeOSPolicyTest,
- UpdateDownloadAllowedCellularPolicyOverride) {
+TEST_F(UmChromeOSPolicyTest, UpdateDownloadAllowedCellularPolicyOverride) {
// Update over cellular can be enabled by policy.
- fake_state_.shill_provider()->var_conn_type()->
- reset(new ConnectionType(ConnectionType::kCellular));
+ fake_state_.shill_provider()->var_conn_type()->reset(
+ new ConnectionType(ConnectionType::kCellular));
set<ConnectionType> allowed_connections;
allowed_connections.insert(ConnectionType::kCellular);
- fake_state_.device_policy_provider()->
- var_allowed_connection_types_for_update()->
- reset(new set<ConnectionType>(allowed_connections));
+ fake_state_.device_policy_provider()
+ ->var_allowed_connection_types_for_update()
+ ->reset(new set<ConnectionType>(allowed_connections));
bool result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateDownloadAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateDownloadAllowed, &result);
EXPECT_TRUE(result);
}
-TEST_F(UmChromeOSPolicyTest,
- UpdateDownloadAllowedCellularUserOverride) {
+TEST_F(UmChromeOSPolicyTest, UpdateDownloadAllowedCellularUserOverride) {
// Update over cellular can be enabled by user settings, but only if policy
// is present and does not determine allowed connections.
- fake_state_.shill_provider()->var_conn_type()->
- reset(new ConnectionType(ConnectionType::kCellular));
+ fake_state_.shill_provider()->var_conn_type()->reset(
+ new ConnectionType(ConnectionType::kCellular));
set<ConnectionType> allowed_connections;
allowed_connections.insert(ConnectionType::kCellular);
- fake_state_.updater_provider()->var_cellular_enabled()->
- reset(new bool(true));
+ fake_state_.updater_provider()->var_cellular_enabled()->reset(new bool(true));
bool result;
- ExpectPolicyStatus(EvalStatus::kSucceeded,
- &Policy::UpdateDownloadAllowed, &result);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateDownloadAllowed, &result);
EXPECT_TRUE(result);
}
-TEST_F(UmChromeOSPolicyTest,
- UpdateCanStartAllowedScatteringSupressedDueToP2P) {
+TEST_F(UmChromeOSPolicyTest, UpdateCanStartAllowedScatteringSupressedDueToP2P) {
// The UpdateCanStart policy returns true; scattering should have applied, but
// P2P download is allowed. Scattering values are nonetheless returned, and so
// are download URL values, albeit the latter are not allowed to be used.
@@ -1533,8 +1545,8 @@
update_state.scatter_wait_period = TimeDelta::FromSeconds(35);
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart,
- &result, update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(0, result.download_url_idx);
EXPECT_FALSE(result.download_url_allowed);
@@ -1546,8 +1558,7 @@
EXPECT_EQ(0, result.scatter_check_threshold);
}
-TEST_F(UmChromeOSPolicyTest,
- UpdateCanStartAllowedBackoffSupressedDueToP2P) {
+TEST_F(UmChromeOSPolicyTest, UpdateCanStartAllowedBackoffSupressedDueToP2P) {
// The UpdateCanStart policy returns true; backoff should have applied, but
// P2P download is allowed. Backoff values are nonetheless returned, and so
// are download URL values, albeit the latter are not allowed to be used.
@@ -1558,16 +1569,18 @@
UpdateState update_state = GetDefaultUpdateState(TimeDelta::FromSeconds(10));
update_state.download_errors_max = 1;
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(8));
update_state.download_errors.emplace_back(
- 0, ErrorCode::kDownloadTransferError,
+ 0,
+ ErrorCode::kDownloadTransferError,
curr_time - TimeDelta::FromSeconds(2));
fake_state_.updater_provider()->var_p2p_enabled()->reset(new bool(true));
UpdateDownloadParams result;
- ExpectPolicyStatus(EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result,
- update_state);
+ ExpectPolicyStatus(
+ EvalStatus::kSucceeded, &Policy::UpdateCanStart, &result, update_state);
EXPECT_TRUE(result.update_can_start);
EXPECT_EQ(0, result.download_url_idx);
EXPECT_FALSE(result.download_url_allowed);
@@ -1612,8 +1625,8 @@
TEST_F(UmChromeOSPolicyTest, P2PEnabledChangedBlocks) {
bool result;
- ExpectPolicyStatus(EvalStatus::kAskMeAgainLater, &Policy::P2PEnabledChanged,
- &result, false);
+ ExpectPolicyStatus(
+ EvalStatus::kAskMeAgainLater, &Policy::P2PEnabledChanged, &result, false);
}
TEST_F(UmChromeOSPolicyTest,
diff --git a/update_manager/default_policy.cc b/update_manager/default_policy.cc
index 5509abc..81ab795 100644
--- a/update_manager/default_policy.cc
+++ b/update_manager/default_policy.cc
@@ -34,9 +34,10 @@
DefaultPolicy::DefaultPolicy(chromeos_update_engine::ClockInterface* clock)
: clock_(clock), aux_state_(new DefaultPolicyState()) {}
-EvalStatus DefaultPolicy::UpdateCheckAllowed(
- EvaluationContext* ec, State* state, std::string* error,
- UpdateCheckParams* result) const {
+EvalStatus DefaultPolicy::UpdateCheckAllowed(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ UpdateCheckParams* result) const {
result->updates_enabled = true;
result->target_channel.clear();
result->target_version_prefix.clear();
@@ -67,12 +68,11 @@
return EvalStatus::kSucceeded;
}
-EvalStatus DefaultPolicy::UpdateCanStart(
- EvaluationContext* ec,
- State* state,
- std::string* error,
- UpdateDownloadParams* result,
- const UpdateState update_state) const {
+EvalStatus DefaultPolicy::UpdateCanStart(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ UpdateDownloadParams* result,
+ const UpdateState update_state) const {
result->update_can_start = true;
result->cannot_start_reason = UpdateCannotStartReason::kUndefined;
result->download_url_idx = 0;
@@ -87,30 +87,27 @@
return EvalStatus::kSucceeded;
}
-EvalStatus DefaultPolicy::UpdateDownloadAllowed(
- EvaluationContext* ec,
- State* state,
- std::string* error,
- bool* result) const {
+EvalStatus DefaultPolicy::UpdateDownloadAllowed(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ bool* result) const {
*result = true;
return EvalStatus::kSucceeded;
}
-EvalStatus DefaultPolicy::P2PEnabled(
- EvaluationContext* ec,
- State* state,
- std::string* error,
- bool* result) const {
+EvalStatus DefaultPolicy::P2PEnabled(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ bool* result) const {
*result = false;
return EvalStatus::kSucceeded;
}
-EvalStatus DefaultPolicy::P2PEnabledChanged(
- EvaluationContext* ec,
- State* state,
- std::string* error,
- bool* result,
- bool prev_result) const {
+EvalStatus DefaultPolicy::P2PEnabledChanged(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ bool* result,
+ bool prev_result) const {
// This policy will always prohibit P2P, so this is signaling to the caller
// that the decision is final (because the current value is the same as the
// previous one) and there's no need to issue another call.
diff --git a/update_manager/default_policy.h b/update_manager/default_policy.h
index 136ca35..1b284f4 100644
--- a/update_manager/default_policy.h
+++ b/update_manager/default_policy.h
@@ -65,9 +65,10 @@
~DefaultPolicy() override {}
// Policy overrides.
- EvalStatus UpdateCheckAllowed(
- EvaluationContext* ec, State* state, std::string* error,
- UpdateCheckParams* result) const override;
+ EvalStatus UpdateCheckAllowed(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ UpdateCheckParams* result) const override;
EvalStatus UpdateCanBeApplied(
EvaluationContext* ec,
@@ -76,22 +77,27 @@
chromeos_update_engine::ErrorCode* result,
chromeos_update_engine::InstallPlan* install_plan) const override;
- EvalStatus UpdateCanStart(
- EvaluationContext* ec, State* state, std::string* error,
- UpdateDownloadParams* result,
- UpdateState update_state) const override;
+ EvalStatus UpdateCanStart(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ UpdateDownloadParams* result,
+ UpdateState update_state) const override;
- EvalStatus UpdateDownloadAllowed(
- EvaluationContext* ec, State* state, std::string* error,
- bool* result) const override;
+ EvalStatus UpdateDownloadAllowed(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ bool* result) const override;
- EvalStatus P2PEnabled(
- EvaluationContext* ec, State* state, std::string* error,
- bool* result) const override;
+ EvalStatus P2PEnabled(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ bool* result) const override;
- EvalStatus P2PEnabledChanged(
- EvaluationContext* ec, State* state, std::string* error,
- bool* result, bool prev_result) const override;
+ EvalStatus P2PEnabledChanged(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ bool* result,
+ bool prev_result) const override;
protected:
// Policy override.
diff --git a/update_manager/device_policy_provider.h b/update_manager/device_policy_provider.h
index 80dcfa2..873282e 100644
--- a/update_manager/device_policy_provider.h
+++ b/update_manager/device_policy_provider.h
@@ -51,7 +51,7 @@
// Variable returning what should happen if the target_version_prefix is
// earlier than the current Chrome OS version.
virtual Variable<RollbackToTargetVersion>*
- var_rollback_to_target_version() = 0;
+ var_rollback_to_target_version() = 0;
// Variable returning the number of Chrome milestones rollback should be
// possible. Rollback protection will be postponed by this many versions.
@@ -64,7 +64,7 @@
// identifiers returned are consistent with the ones returned by the
// ShillProvider.
virtual Variable<std::set<chromeos_update_engine::ConnectionType>>*
- var_allowed_connection_types_for_update() = 0;
+ var_allowed_connection_types_for_update() = 0;
// Variable stating the name of the device owner. For enterprise enrolled
// devices, this will be an empty string.
diff --git a/update_manager/evaluation_context-inl.h b/update_manager/evaluation_context-inl.h
index 937adf4..59d85da 100644
--- a/update_manager/evaluation_context-inl.h
+++ b/update_manager/evaluation_context-inl.h
@@ -23,7 +23,7 @@
namespace chromeos_update_manager {
-template<typename T>
+template <typename T>
const T* EvaluationContext::GetValue(Variable<T>* var) {
if (var == nullptr) {
LOG(ERROR) << "GetValue received an uninitialized variable.";
@@ -37,16 +37,15 @@
// Get the value from the variable if not found on the cache.
std::string errmsg;
- const T* result = var->GetValue(RemainingTime(evaluation_monotonic_deadline_),
- &errmsg);
+ const T* result =
+ var->GetValue(RemainingTime(evaluation_monotonic_deadline_), &errmsg);
if (result == nullptr) {
LOG(WARNING) << "Error reading Variable " << var->GetName() << ": \""
- << errmsg << "\"";
+ << errmsg << "\"";
}
// Cache the value for the next time. The map of CachedValues keeps the
// ownership of the pointer until the map is destroyed.
- value_cache_.emplace(
- static_cast<BaseVariable*>(var), BoxedValue(result));
+ value_cache_.emplace(static_cast<BaseVariable*>(var), BoxedValue(result));
return result;
}
diff --git a/update_manager/evaluation_context.cc b/update_manager/evaluation_context.cc
index b6c7b91..e796fec 100644
--- a/update_manager/evaluation_context.cc
+++ b/update_manager/evaluation_context.cc
@@ -43,8 +43,7 @@
// 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(Time ref_time, Time curr_time,
- 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.
@@ -104,8 +103,8 @@
}
Time EvaluationContext::MonotonicDeadline(TimeDelta timeout) {
- return (timeout.is_max() ? Time::Max() :
- clock_->GetMonotonicTime() + timeout);
+ return (timeout.is_max() ? Time::Max()
+ : clock_->GetMonotonicTime() + timeout);
}
void EvaluationContext::ValueChanged(BaseVariable* var) {
@@ -130,13 +129,13 @@
}
bool EvaluationContext::IsWallclockTimeGreaterThan(Time timestamp) {
- return IsTimeGreaterThanHelper(timestamp, evaluation_start_wallclock_,
- &reevaluation_time_wallclock_);
+ return IsTimeGreaterThanHelper(
+ timestamp, evaluation_start_wallclock_, &reevaluation_time_wallclock_);
}
bool EvaluationContext::IsMonotonicTimeGreaterThan(Time timestamp) {
- return IsTimeGreaterThanHelper(timestamp, evaluation_start_monotonic_,
- &reevaluation_time_monotonic_);
+ return IsTimeGreaterThanHelper(
+ timestamp, evaluation_start_monotonic_, &reevaluation_time_monotonic_);
}
void EvaluationContext::ResetEvaluation() {
@@ -147,7 +146,7 @@
evaluation_monotonic_deadline_ = MonotonicDeadline(evaluation_timeout_);
// Remove the cached values of non-const variables
- for (auto it = value_cache_.begin(); it != value_cache_.end(); ) {
+ for (auto it = value_cache_.begin(); it != value_cache_.end();) {
if (it->first->GetMode() == kVariableModeConst) {
++it;
} else {
diff --git a/update_manager/evaluation_context.h b/update_manager/evaluation_context.h
index 0bdbaec..c68c430 100644
--- a/update_manager/evaluation_context.h
+++ b/update_manager/evaluation_context.h
@@ -73,8 +73,10 @@
EvaluationContext(chromeos_update_engine::ClockInterface* clock,
base::TimeDelta evaluation_timeout)
: EvaluationContext(
- clock, evaluation_timeout, base::TimeDelta::Max(),
- std::unique_ptr<base::Callback<void(EvaluationContext*)>>()) {}
+ clock,
+ evaluation_timeout,
+ base::TimeDelta::Max(),
+ std::unique_ptr<base::Callback<void(EvaluationContext*)>>()) {}
~EvaluationContext();
// Returns a pointer to the value returned by the passed variable |var|. The
@@ -83,7 +85,7 @@
// passed Variable changes it.
//
// In case of error, a null value is returned.
- template<typename T>
+ template <typename T>
const T* GetValue(Variable<T>* var);
// Returns whether the evaluation time has surpassed |timestamp|, on either
@@ -163,8 +165,7 @@
// The TaskId returned by the message loop identifying the timeout callback.
// Used for canceling the timeout callback.
- brillo::MessageLoop::TaskId timeout_event_ =
- brillo::MessageLoop::kTaskIdNull;
+ brillo::MessageLoop::TaskId timeout_event_ = brillo::MessageLoop::kTaskIdNull;
// Whether a timeout event firing marks the expiration of the evaluation
// context.
diff --git a/update_manager/evaluation_context_unittest.cc b/update_manager/evaluation_context_unittest.cc
index d172885..eb42eb7 100644
--- a/update_manager/evaluation_context_unittest.cc
+++ b/update_manager/evaluation_context_unittest.cc
@@ -41,9 +41,9 @@
using chromeos_update_engine::FakeClock;
using std::string;
using std::unique_ptr;
+using testing::_;
using testing::Return;
using testing::StrictMock;
-using testing::_;
namespace chromeos_update_manager {
@@ -58,15 +58,17 @@
return *value;
}
-template<typename T>
+template <typename T>
void ReadVar(scoped_refptr<EvaluationContext> ec, Variable<T>* var) {
ec->GetValue(var);
}
// Runs |evaluation|; if the value pointed by |count_p| is greater than zero,
// decrement it and schedule a reevaluation; otherwise, writes true to |done_p|.
-void EvaluateRepeatedly(Closure evaluation, scoped_refptr<EvaluationContext> ec,
- int* count_p, bool* done_p) {
+void EvaluateRepeatedly(Closure evaluation,
+ scoped_refptr<EvaluationContext> ec,
+ int* count_p,
+ bool* done_p) {
evaluation.Run();
// Schedule reevaluation if needed.
@@ -91,7 +93,9 @@
// Mar 2, 2006 1:23:45 UTC.
fake_clock_.SetWallclockTime(Time::FromTimeT(1141262625));
eval_ctx_ = new EvaluationContext(
- &fake_clock_, default_timeout_, default_timeout_,
+ &fake_clock_,
+ default_timeout_,
+ default_timeout_,
unique_ptr<base::Callback<void(EvaluationContext*)>>(nullptr));
}
@@ -133,10 +137,10 @@
FakeVariable<string> fake_const_var_ = {"fake_const", kVariableModeConst};
FakeVariable<string> fake_poll_var_ = {"fake_poll",
TimeDelta::FromSeconds(1)};
- StrictMock<MockVariable<string>> mock_var_async_ {
- "mock_var_async", kVariableModeAsync};
- StrictMock<MockVariable<string>> mock_var_poll_ {
- "mock_var_poll", kVariableModePoll};
+ StrictMock<MockVariable<string>> mock_var_async_{"mock_var_async",
+ kVariableModeAsync};
+ StrictMock<MockVariable<string>> mock_var_poll_{"mock_var_poll",
+ kVariableModePoll};
};
TEST_F(UmEvaluationContextTest, GetValueFails) {
@@ -329,8 +333,8 @@
evaluation.Run();
// Schedule repeated reevaluations.
- Closure closure = Bind(EvaluateRepeatedly, evaluation, eval_ctx_,
- &num_reevaluations, &done);
+ Closure closure = Bind(
+ EvaluateRepeatedly, evaluation, eval_ctx_, &num_reevaluations, &done);
ASSERT_TRUE(eval_ctx_->RunOnValueChangeOrTimeout(closure));
MessageLoopRunUntil(MessageLoop::current(),
TimeDelta::FromSeconds(10),
@@ -384,13 +388,12 @@
}
TEST_F(UmEvaluationContextTest, TimeoutUpdatesWithMonotonicTime) {
- fake_clock_.SetMonotonicTime(
- fake_clock_.GetMonotonicTime() + TimeDelta::FromSeconds(1));
+ fake_clock_.SetMonotonicTime(fake_clock_.GetMonotonicTime() +
+ TimeDelta::FromSeconds(1));
TimeDelta timeout = default_timeout_ - TimeDelta::FromSeconds(1);
- EXPECT_CALL(mock_var_async_, GetValue(timeout, _))
- .WillOnce(Return(nullptr));
+ EXPECT_CALL(mock_var_async_, GetValue(timeout, _)).WillOnce(Return(nullptr));
EXPECT_EQ(nullptr, eval_ctx_->GetValue(&mock_var_async_));
}
@@ -399,20 +402,20 @@
// Advance the time on the clock but don't call ResetEvaluation yet.
fake_clock_.SetWallclockTime(cur_time + TimeDelta::FromSeconds(4));
- EXPECT_TRUE(eval_ctx_->IsWallclockTimeGreaterThan(
- cur_time - TimeDelta::FromSeconds(1)));
+ EXPECT_TRUE(eval_ctx_->IsWallclockTimeGreaterThan(cur_time -
+ TimeDelta::FromSeconds(1)));
EXPECT_FALSE(eval_ctx_->IsWallclockTimeGreaterThan(cur_time));
EXPECT_FALSE(eval_ctx_->IsWallclockTimeGreaterThan(
- cur_time + TimeDelta::FromSeconds(1)));
+ cur_time + TimeDelta::FromSeconds(1)));
// Call ResetEvaluation now, which should use the new evaluation time.
eval_ctx_->ResetEvaluation();
cur_time = fake_clock_.GetWallclockTime();
- EXPECT_TRUE(eval_ctx_->IsWallclockTimeGreaterThan(
- cur_time - TimeDelta::FromSeconds(1)));
+ EXPECT_TRUE(eval_ctx_->IsWallclockTimeGreaterThan(cur_time -
+ TimeDelta::FromSeconds(1)));
EXPECT_FALSE(eval_ctx_->IsWallclockTimeGreaterThan(cur_time));
EXPECT_FALSE(eval_ctx_->IsWallclockTimeGreaterThan(
- cur_time + TimeDelta::FromSeconds(1)));
+ cur_time + TimeDelta::FromSeconds(1)));
}
TEST_F(UmEvaluationContextTest, ResetEvaluationResetsTimesMonotonic) {
@@ -420,20 +423,20 @@
// Advance the time on the clock but don't call ResetEvaluation yet.
fake_clock_.SetMonotonicTime(cur_time + TimeDelta::FromSeconds(4));
- EXPECT_TRUE(eval_ctx_->IsMonotonicTimeGreaterThan(
- cur_time - TimeDelta::FromSeconds(1)));
+ EXPECT_TRUE(eval_ctx_->IsMonotonicTimeGreaterThan(cur_time -
+ TimeDelta::FromSeconds(1)));
EXPECT_FALSE(eval_ctx_->IsMonotonicTimeGreaterThan(cur_time));
EXPECT_FALSE(eval_ctx_->IsMonotonicTimeGreaterThan(
- cur_time + TimeDelta::FromSeconds(1)));
+ cur_time + TimeDelta::FromSeconds(1)));
// Call ResetEvaluation now, which should use the new evaluation time.
eval_ctx_->ResetEvaluation();
cur_time = fake_clock_.GetMonotonicTime();
- EXPECT_TRUE(eval_ctx_->IsMonotonicTimeGreaterThan(
- cur_time - TimeDelta::FromSeconds(1)));
+ EXPECT_TRUE(eval_ctx_->IsMonotonicTimeGreaterThan(cur_time -
+ TimeDelta::FromSeconds(1)));
EXPECT_FALSE(eval_ctx_->IsMonotonicTimeGreaterThan(cur_time));
EXPECT_FALSE(eval_ctx_->IsMonotonicTimeGreaterThan(
- cur_time + TimeDelta::FromSeconds(1)));
+ cur_time + TimeDelta::FromSeconds(1)));
}
TEST_F(UmEvaluationContextTest,
@@ -521,16 +524,17 @@
// Note that the variables are printed in alphabetical order. Also
// see UmEvaluationContextText::SetUp() where the values used for
// |evaluation_start_{monotonic,wallclock| are set.
- EXPECT_EQ("{\n"
- " \"evaluation_start_monotonic\": \"4/22/2009 19:25:00 GMT\",\n"
- " \"evaluation_start_wallclock\": \"3/2/2006 1:23:45 GMT\",\n"
- " \"variables\": {\n"
- " \"fail_var\": \"(no value)\",\n"
- " \"fake_int\": \"42\",\n"
- " \"fake_poll\": \"Hello \\\"world\\\"!\"\n"
- " }\n"
- "}",
- eval_ctx_->DumpContext());
+ EXPECT_EQ(
+ "{\n"
+ " \"evaluation_start_monotonic\": \"4/22/2009 19:25:00 GMT\",\n"
+ " \"evaluation_start_wallclock\": \"3/2/2006 1:23:45 GMT\",\n"
+ " \"variables\": {\n"
+ " \"fail_var\": \"(no value)\",\n"
+ " \"fake_int\": \"42\",\n"
+ " \"fake_poll\": \"Hello \\\"world\\\"!\"\n"
+ " }\n"
+ "}",
+ eval_ctx_->DumpContext());
}
} // namespace chromeos_update_manager
diff --git a/update_manager/fake_config_provider.h b/update_manager/fake_config_provider.h
index 6a324df..7e6c35b 100644
--- a/update_manager/fake_config_provider.h
+++ b/update_manager/fake_config_provider.h
@@ -32,8 +32,8 @@
}
private:
- FakeVariable<bool> var_is_oobe_enabled_{ // NOLINT(whitespace/braces)
- "is_oobe_enabled", kVariableModeConst};
+ FakeVariable<bool> var_is_oobe_enabled_{"is_oobe_enabled",
+ kVariableModeConst};
DISALLOW_COPY_AND_ASSIGN(FakeConfigProvider);
};
diff --git a/update_manager/fake_device_policy_provider.h b/update_manager/fake_device_policy_provider.h
index d70e0c3..7cd4d7b 100644
--- a/update_manager/fake_device_policy_provider.h
+++ b/update_manager/fake_device_policy_provider.h
@@ -64,13 +64,11 @@
}
FakeVariable<std::set<chromeos_update_engine::ConnectionType>>*
- var_allowed_connection_types_for_update() override {
+ var_allowed_connection_types_for_update() override {
return &var_allowed_connection_types_for_update_;
}
- FakeVariable<std::string>* var_owner() override {
- return &var_owner_;
- }
+ FakeVariable<std::string>* var_owner() override { return &var_owner_; }
FakeVariable<bool>* var_http_downloads_enabled() override {
return &var_http_downloads_enabled_;
@@ -94,28 +92,27 @@
}
private:
- FakeVariable<bool> var_device_policy_is_loaded_{
- "policy_is_loaded", kVariableModePoll};
- FakeVariable<std::string> var_release_channel_{
- "release_channel", kVariableModePoll};
- FakeVariable<bool> var_release_channel_delegated_{
- "release_channel_delegated", kVariableModePoll};
- FakeVariable<bool> var_update_disabled_{
- "update_disabled", kVariableModePoll};
- FakeVariable<std::string> var_target_version_prefix_{
- "target_version_prefix", kVariableModePoll};
+ FakeVariable<bool> var_device_policy_is_loaded_{"policy_is_loaded",
+ kVariableModePoll};
+ FakeVariable<std::string> var_release_channel_{"release_channel",
+ kVariableModePoll};
+ FakeVariable<bool> var_release_channel_delegated_{"release_channel_delegated",
+ kVariableModePoll};
+ FakeVariable<bool> var_update_disabled_{"update_disabled", kVariableModePoll};
+ FakeVariable<std::string> var_target_version_prefix_{"target_version_prefix",
+ kVariableModePoll};
FakeVariable<RollbackToTargetVersion> var_rollback_to_target_version_{
"rollback_to_target_version", kVariableModePoll};
FakeVariable<int> var_rollback_allowed_milestones_{
"rollback_allowed_milestones", kVariableModePoll};
- FakeVariable<base::TimeDelta> var_scatter_factor_{
- "scatter_factor", kVariableModePoll};
+ FakeVariable<base::TimeDelta> var_scatter_factor_{"scatter_factor",
+ kVariableModePoll};
FakeVariable<std::set<chromeos_update_engine::ConnectionType>>
var_allowed_connection_types_for_update_{
"allowed_connection_types_for_update", kVariableModePoll};
FakeVariable<std::string> var_owner_{"owner", kVariableModePoll};
- FakeVariable<bool> var_http_downloads_enabled_{
- "http_downloads_enabled", kVariableModePoll};
+ FakeVariable<bool> var_http_downloads_enabled_{"http_downloads_enabled",
+ kVariableModePoll};
FakeVariable<bool> var_au_p2p_enabled_{"au_p2p_enabled", kVariableModePoll};
FakeVariable<bool> var_allow_kiosk_app_control_chrome_version_{
"allow_kiosk_app_control_chrome_version", kVariableModePoll};
diff --git a/update_manager/fake_shill_provider.h b/update_manager/fake_shill_provider.h
index 7f1c8f5..7a23507 100644
--- a/update_manager/fake_shill_provider.h
+++ b/update_manager/fake_shill_provider.h
@@ -27,9 +27,7 @@
public:
FakeShillProvider() {}
- FakeVariable<bool>* var_is_connected() override {
- return &var_is_connected_;
- }
+ FakeVariable<bool>* var_is_connected() override { return &var_is_connected_; }
FakeVariable<chromeos_update_engine::ConnectionType>* var_conn_type()
override {
@@ -37,7 +35,7 @@
}
FakeVariable<chromeos_update_engine::ConnectionTethering>*
- var_conn_tethering() override {
+ var_conn_tethering() override {
return &var_conn_tethering_;
}
@@ -51,8 +49,8 @@
"conn_type", kVariableModePoll};
FakeVariable<chromeos_update_engine::ConnectionTethering> var_conn_tethering_{
"conn_tethering", kVariableModePoll};
- FakeVariable<base::Time> var_conn_last_changed_{
- "conn_last_changed", kVariableModePoll};
+ FakeVariable<base::Time> var_conn_last_changed_{"conn_last_changed",
+ kVariableModePoll};
DISALLOW_COPY_AND_ASSIGN(FakeShillProvider);
};
diff --git a/update_manager/fake_state.h b/update_manager/fake_state.h
index fd7a88c..0fd584f 100644
--- a/update_manager/fake_state.h
+++ b/update_manager/fake_state.h
@@ -46,29 +46,19 @@
~FakeState() override {}
// Downcasted getters to access the fake instances during testing.
- FakeConfigProvider* config_provider() override {
- return &config_provider_;
- }
+ FakeConfigProvider* config_provider() override { return &config_provider_; }
FakeDevicePolicyProvider* device_policy_provider() override {
return &device_policy_provider_;
}
- FakeRandomProvider* random_provider() override {
- return &random_provider_;
- }
+ FakeRandomProvider* random_provider() override { return &random_provider_; }
- FakeShillProvider* shill_provider() override {
- return &shill_provider_;
- }
+ FakeShillProvider* shill_provider() override { return &shill_provider_; }
- FakeSystemProvider* system_provider() override {
- return &system_provider_;
- }
+ FakeSystemProvider* system_provider() override { return &system_provider_; }
- FakeTimeProvider* time_provider() override {
- return &time_provider_;
- }
+ FakeTimeProvider* time_provider() override { return &time_provider_; }
FakeUpdaterProvider* updater_provider() override {
return &updater_provider_;
diff --git a/update_manager/fake_system_provider.h b/update_manager/fake_system_provider.h
index 0f4dff4..f54951b 100644
--- a/update_manager/fake_system_provider.h
+++ b/update_manager/fake_system_provider.h
@@ -17,9 +17,12 @@
#ifndef UPDATE_ENGINE_UPDATE_MANAGER_FAKE_SYSTEM_PROVIDER_H_
#define UPDATE_ENGINE_UPDATE_MANAGER_FAKE_SYSTEM_PROVIDER_H_
-#include "update_engine/update_manager/fake_variable.h"
#include "update_engine/update_manager/system_provider.h"
+#include <string>
+
+#include "update_engine/update_manager/fake_variable.h"
+
namespace chromeos_update_manager {
// Fake implementation of the SystemProvider base class.
@@ -48,12 +51,12 @@
}
private:
- FakeVariable<bool> var_is_normal_boot_mode_{ // NOLINT(whitespace/braces)
- "is_normal_boot_mode", kVariableModeConst};
- FakeVariable<bool> var_is_official_build_{ // NOLINT(whitespace/braces)
- "is_official_build", kVariableModeConst};
- FakeVariable<bool> var_is_oobe_complete_{ // NOLINT(whitespace/braces)
- "is_oobe_complete", kVariableModePoll};
+ FakeVariable<bool> var_is_normal_boot_mode_{"is_normal_boot_mode",
+ kVariableModeConst};
+ FakeVariable<bool> var_is_official_build_{"is_official_build",
+ kVariableModeConst};
+ FakeVariable<bool> var_is_oobe_complete_{"is_oobe_complete",
+ kVariableModePoll};
FakeVariable<unsigned int> var_num_slots_{"num_slots", kVariableModePoll};
FakeVariable<std::string> var_kiosk_required_platform_version_{
"kiosk_required_platform_version", kVariableModePoll};
diff --git a/update_manager/fake_update_manager.h b/update_manager/fake_update_manager.h
index 2ea00b6..173b1a9 100644
--- a/update_manager/fake_update_manager.h
+++ b/update_manager/fake_update_manager.h
@@ -27,8 +27,10 @@
class FakeUpdateManager : public UpdateManager {
public:
explicit FakeUpdateManager(chromeos_update_engine::ClockInterface* clock)
- : UpdateManager(clock, base::TimeDelta::FromSeconds(5),
- base::TimeDelta::FromHours(1), new FakeState()) {
+ : UpdateManager(clock,
+ base::TimeDelta::FromSeconds(5),
+ base::TimeDelta::FromHours(1),
+ new FakeState()) {
// The FakeUpdateManager uses a DefaultPolicy.
set_policy(new DefaultPolicy(clock));
}
diff --git a/update_manager/fake_variable.h b/update_manager/fake_variable.h
index 2f8e079..ef5b4f3 100644
--- a/update_manager/fake_variable.h
+++ b/update_manager/fake_variable.h
@@ -26,7 +26,7 @@
// A fake typed variable to use while testing policy implementations. The
// variable can be instructed to return any object of its type.
-template<typename T>
+template <typename T>
class FakeVariable : public Variable<T> {
public:
FakeVariable(const std::string& name, VariableMode mode)
@@ -39,14 +39,10 @@
// returned by GetValue(), the pointer is released and has to be set again.
// A value of null means that the GetValue() call will fail and return
// null.
- void reset(const T* p_value) {
- ptr_.reset(p_value);
- }
+ void reset(const T* p_value) { ptr_.reset(p_value); }
// Make the NotifyValueChanged() public for FakeVariables.
- void NotifyValueChanged() {
- Variable<T>::NotifyValueChanged();
- }
+ void NotifyValueChanged() { Variable<T>::NotifyValueChanged(); }
protected:
// Variable<T> overrides.
diff --git a/update_manager/generic_variables.h b/update_manager/generic_variables.h
index f87a05e..afbdcbe 100644
--- a/update_manager/generic_variables.h
+++ b/update_manager/generic_variables.h
@@ -47,7 +47,7 @@
// private:
// MyType foo_;
// };
-template<typename T>
+template <typename T>
class PollCopyVariable : public Variable<T> {
public:
// Creates the variable returning copies of the passed |ref|. The reference to
@@ -55,24 +55,35 @@
// method is called. If |is_set_p| is not null, then this flag will be
// consulted prior to returning the value, and an |errmsg| will be returned if
// it is not set.
- PollCopyVariable(const std::string& name, const T& ref, const bool* is_set_p,
+ PollCopyVariable(const std::string& name,
+ const T& ref,
+ const bool* is_set_p,
const std::string& errmsg)
- : Variable<T>(name, kVariableModePoll), ref_(ref), is_set_p_(is_set_p),
+ : Variable<T>(name, kVariableModePoll),
+ ref_(ref),
+ is_set_p_(is_set_p),
errmsg_(errmsg) {}
PollCopyVariable(const std::string& name, const T& ref, const bool* is_set_p)
: PollCopyVariable(name, ref, is_set_p, std::string()) {}
PollCopyVariable(const std::string& name, const T& ref)
: PollCopyVariable(name, ref, nullptr) {}
- PollCopyVariable(const std::string& name, const base::TimeDelta poll_interval,
- const T& ref, const bool* is_set_p,
+ PollCopyVariable(const std::string& name,
+ const base::TimeDelta poll_interval,
+ const T& ref,
+ const bool* is_set_p,
const std::string& errmsg)
- : Variable<T>(name, poll_interval), ref_(ref), is_set_p_(is_set_p),
+ : Variable<T>(name, poll_interval),
+ ref_(ref),
+ is_set_p_(is_set_p),
errmsg_(errmsg) {}
- PollCopyVariable(const std::string& name, const base::TimeDelta poll_interval,
- const T& ref, const bool* is_set_p)
+ PollCopyVariable(const std::string& name,
+ const base::TimeDelta poll_interval,
+ const T& ref,
+ const bool* is_set_p)
: PollCopyVariable(name, poll_interval, ref, is_set_p, std::string()) {}
- PollCopyVariable(const std::string& name, const base::TimeDelta poll_interval,
+ PollCopyVariable(const std::string& name,
+ const base::TimeDelta poll_interval,
const T& ref)
: PollCopyVariable(name, poll_interval, ref, nullptr) {}
@@ -109,7 +120,7 @@
// Variable class returning a constant value that is cached on the variable when
// it is created.
-template<typename T>
+template <typename T>
class ConstCopyVariable : public Variable<T> {
public:
// Creates the variable returning copies of the passed |obj|. The value passed
@@ -132,7 +143,7 @@
// Variable class returning a copy of a value returned by a given function. The
// function is called every time the variable is being polled.
-template<typename T>
+template <typename T>
class CallCopyVariable : public Variable<T> {
public:
CallCopyVariable(const std::string& name, base::Callback<T(void)> func)
@@ -160,7 +171,6 @@
DISALLOW_COPY_AND_ASSIGN(CallCopyVariable);
};
-
// A Variable class to implement simple Async variables. It provides two methods
// SetValue and UnsetValue to modify the current value of the variable and
// notify the registered observers whenever the value changed.
@@ -168,7 +178,7 @@
// The type T needs to be copy-constructible, default-constructible and have an
// operator== (to determine if the value changed), which makes this class
// suitable for basic types.
-template<typename T>
+template <typename T>
class AsyncCopyVariable : public Variable<T> {
public:
explicit AsyncCopyVariable(const std::string& name)
@@ -176,7 +186,8 @@
AsyncCopyVariable(const std::string& name, const T value)
: Variable<T>(name, kVariableModeAsync),
- has_value_(true), value_(value) {}
+ has_value_(true),
+ value_(value) {}
void SetValue(const T& new_value) {
bool should_notify = !(has_value_ && new_value == value_);
diff --git a/update_manager/generic_variables_unittest.cc b/update_manager/generic_variables_unittest.cc
index cb0c48f..0ff97e3 100644
--- a/update_manager/generic_variables_unittest.cc
+++ b/update_manager/generic_variables_unittest.cc
@@ -34,15 +34,14 @@
class UmPollCopyVariableTest : public ::testing::Test {};
-
TEST_F(UmPollCopyVariableTest, SimpleTest) {
// Tests that copies are generated as intended.
int source = 5;
PollCopyVariable<int> var("var", source);
// Generate and validate a copy.
- unique_ptr<const int> copy_1(var.GetValue(
- UmTestUtils::DefaultTimeout(), nullptr));
+ unique_ptr<const int> copy_1(
+ var.GetValue(UmTestUtils::DefaultTimeout(), nullptr));
ASSERT_NE(nullptr, copy_1.get());
EXPECT_EQ(5, *copy_1);
@@ -70,7 +69,6 @@
UmTestUtils::ExpectVariableHasValue(5, &var);
}
-
class CopyConstructorTestClass {
public:
CopyConstructorTestClass(void) : copied_(false) {}
@@ -84,7 +82,6 @@
int val_ = 0;
};
-
TEST_F(UmPollCopyVariableTest, UseCopyConstructorTest) {
// Ensures that CopyVariables indeed uses the copy constructor.
const CopyConstructorTestClass source;
@@ -97,7 +94,6 @@
EXPECT_TRUE(copy->copied_);
}
-
class UmConstCopyVariableTest : public ::testing::Test {};
TEST_F(UmConstCopyVariableTest, SimpleTest) {
@@ -110,7 +106,6 @@
UmTestUtils::ExpectVariableHasValue(5, &var);
}
-
class UmCallCopyVariableTest : public ::testing::Test {};
CopyConstructorTestClass test_func(CopyConstructorTestClass* obj) {
@@ -126,8 +121,8 @@
ASSERT_FALSE(test_obj.copied_);
test_obj.val_ = 5;
- base::Callback<CopyConstructorTestClass(void)> cb = base::Bind(
- test_func, &test_obj);
+ base::Callback<CopyConstructorTestClass(void)> cb =
+ base::Bind(test_func, &test_obj);
CallCopyVariable<CopyConstructorTestClass> var("var", cb);
unique_ptr<const CopyConstructorTestClass> copy(
@@ -148,16 +143,13 @@
class UmAsyncCopyVariableTest : public ::testing::Test {
protected:
- void SetUp() override {
- loop_.SetAsCurrent();
- }
+ void SetUp() override { loop_.SetAsCurrent(); }
void TearDown() override {
// No remaining event on the main loop.
EXPECT_FALSE(loop_.PendingTasks());
}
-
brillo::FakeMessageLoop loop_{nullptr};
};
@@ -185,9 +177,7 @@
class CallCounterObserver : public BaseVariable::ObserverInterface {
public:
- void ValueChanged(BaseVariable* variable) {
- calls_count_++;
- }
+ void ValueChanged(BaseVariable* variable) { calls_count_++; }
int calls_count_ = 0;
};
diff --git a/update_manager/mock_policy.h b/update_manager/mock_policy.h
index 8060bf8..46b6c78 100644
--- a/update_manager/mock_policy.h
+++ b/update_manager/mock_policy.h
@@ -32,39 +32,42 @@
explicit MockPolicy(chromeos_update_engine::ClockInterface* clock)
: default_policy_(clock) {
// We defer to the corresponding DefaultPolicy methods, by default.
- ON_CALL(*this, UpdateCheckAllowed(testing::_, testing::_, testing::_,
- testing::_))
- .WillByDefault(testing::Invoke(
- &default_policy_, &DefaultPolicy::UpdateCheckAllowed));
+ ON_CALL(*this,
+ UpdateCheckAllowed(testing::_, testing::_, testing::_, testing::_))
+ .WillByDefault(testing::Invoke(&default_policy_,
+ &DefaultPolicy::UpdateCheckAllowed));
ON_CALL(*this,
UpdateCanBeApplied(
testing::_, testing::_, testing::_, testing::_, testing::_))
.WillByDefault(testing::Invoke(&default_policy_,
&DefaultPolicy::UpdateCanBeApplied));
- ON_CALL(*this, UpdateCanStart(testing::_, testing::_, testing::_,
- testing::_, testing::_))
- .WillByDefault(testing::Invoke(
- &default_policy_, &DefaultPolicy::UpdateCanStart));
- ON_CALL(*this, UpdateDownloadAllowed(testing::_, testing::_, testing::_,
- testing::_))
- .WillByDefault(testing::Invoke(
- &default_policy_, &DefaultPolicy::UpdateDownloadAllowed));
+ ON_CALL(*this,
+ UpdateCanStart(
+ testing::_, testing::_, testing::_, testing::_, testing::_))
+ .WillByDefault(
+ testing::Invoke(&default_policy_, &DefaultPolicy::UpdateCanStart));
+ ON_CALL(
+ *this,
+ UpdateDownloadAllowed(testing::_, testing::_, testing::_, testing::_))
+ .WillByDefault(testing::Invoke(&default_policy_,
+ &DefaultPolicy::UpdateDownloadAllowed));
ON_CALL(*this, P2PEnabled(testing::_, testing::_, testing::_, testing::_))
- .WillByDefault(testing::Invoke(
- &default_policy_, &DefaultPolicy::P2PEnabled));
- ON_CALL(*this, P2PEnabledChanged(testing::_, testing::_, testing::_,
- testing::_, testing::_))
- .WillByDefault(testing::Invoke(
- &default_policy_, &DefaultPolicy::P2PEnabledChanged));
+ .WillByDefault(
+ testing::Invoke(&default_policy_, &DefaultPolicy::P2PEnabled));
+ ON_CALL(*this,
+ P2PEnabledChanged(
+ testing::_, testing::_, testing::_, testing::_, testing::_))
+ .WillByDefault(testing::Invoke(&default_policy_,
+ &DefaultPolicy::P2PEnabledChanged));
}
MockPolicy() : MockPolicy(nullptr) {}
~MockPolicy() override {}
// Policy overrides.
- MOCK_CONST_METHOD4(UpdateCheckAllowed,
- EvalStatus(EvaluationContext*, State*, std::string*,
- UpdateCheckParams*));
+ MOCK_CONST_METHOD4(
+ UpdateCheckAllowed,
+ EvalStatus(EvaluationContext*, State*, std::string*, UpdateCheckParams*));
MOCK_CONST_METHOD5(UpdateCanBeApplied,
EvalStatus(EvaluationContext*,
@@ -74,20 +77,22 @@
chromeos_update_engine::InstallPlan*));
MOCK_CONST_METHOD5(UpdateCanStart,
- EvalStatus(EvaluationContext*, State*, std::string*,
- UpdateDownloadParams*, UpdateState));
+ EvalStatus(EvaluationContext*,
+ State*,
+ std::string*,
+ UpdateDownloadParams*,
+ UpdateState));
- MOCK_CONST_METHOD4(UpdateDownloadAllowed,
- EvalStatus(EvaluationContext*, State*, std::string*,
- bool*));
+ MOCK_CONST_METHOD4(
+ UpdateDownloadAllowed,
+ EvalStatus(EvaluationContext*, State*, std::string*, bool*));
- MOCK_CONST_METHOD4(P2PEnabled,
- EvalStatus(EvaluationContext*, State*, std::string*,
- bool*));
+ MOCK_CONST_METHOD4(
+ P2PEnabled, EvalStatus(EvaluationContext*, State*, std::string*, bool*));
- MOCK_CONST_METHOD5(P2PEnabledChanged,
- EvalStatus(EvaluationContext*, State*, std::string*,
- bool*, bool));
+ MOCK_CONST_METHOD5(
+ P2PEnabledChanged,
+ EvalStatus(EvaluationContext*, State*, std::string*, bool*, bool));
protected:
// Policy override.
diff --git a/update_manager/mock_variable.h b/update_manager/mock_variable.h
index 1493491..8b6c276 100644
--- a/update_manager/mock_variable.h
+++ b/update_manager/mock_variable.h
@@ -26,7 +26,7 @@
namespace chromeos_update_manager {
// This is a generic mock of the Variable class.
-template<typename T>
+template <typename T>
class MockVariable : public Variable<T> {
public:
using Variable<T>::Variable;
diff --git a/update_manager/policy.h b/update_manager/policy.h
index ee163b3..5d65d9a 100644
--- a/update_manager/policy.h
+++ b/update_manager/policy.h
@@ -204,37 +204,34 @@
// Returns the name of a public policy request.
// IMPORTANT: Be sure to add a conditional for each new public policy that is
// being added to this class in the future.
- template<typename R, typename... Args>
- std::string PolicyRequestName(
- EvalStatus (Policy::*policy_method)(EvaluationContext*, State*,
- std::string*, R*,
- Args...) const) const {
+ template <typename R, typename... Args>
+ std::string PolicyRequestName(EvalStatus (Policy::*policy_method)(
+ EvaluationContext*, State*, std::string*, R*, Args...) const) const {
std::string class_name = PolicyName() + "::";
- if (reinterpret_cast<typeof(&Policy::UpdateCheckAllowed)>(
- policy_method) == &Policy::UpdateCheckAllowed)
+ if (reinterpret_cast<typeof(&Policy::UpdateCheckAllowed)>(policy_method) ==
+ &Policy::UpdateCheckAllowed)
return class_name + "UpdateCheckAllowed";
if (reinterpret_cast<typeof(&Policy::UpdateCanBeApplied)>(policy_method) ==
&Policy::UpdateCanBeApplied)
return class_name + "UpdateCanBeApplied";
- if (reinterpret_cast<typeof(&Policy::UpdateCanStart)>(
- policy_method) == &Policy::UpdateCanStart)
+ if (reinterpret_cast<typeof(&Policy::UpdateCanStart)>(policy_method) ==
+ &Policy::UpdateCanStart)
return class_name + "UpdateCanStart";
if (reinterpret_cast<typeof(&Policy::UpdateDownloadAllowed)>(
policy_method) == &Policy::UpdateDownloadAllowed)
return class_name + "UpdateDownloadAllowed";
- if (reinterpret_cast<typeof(&Policy::P2PEnabled)>(
- policy_method) == &Policy::P2PEnabled)
+ if (reinterpret_cast<typeof(&Policy::P2PEnabled)>(policy_method) ==
+ &Policy::P2PEnabled)
return class_name + "P2PEnabled";
- if (reinterpret_cast<typeof(&Policy::P2PEnabledChanged)>(
- policy_method) == &Policy::P2PEnabledChanged)
+ if (reinterpret_cast<typeof(&Policy::P2PEnabledChanged)>(policy_method) ==
+ &Policy::P2PEnabledChanged)
return class_name + "P2PEnabledChanged";
NOTREACHED();
return class_name + "(unknown)";
}
-
// List of policy requests. A policy request takes an EvaluationContext as the
// first argument, a State instance, a returned error message, a returned
// value and optionally followed by one or more arbitrary constant arguments.
@@ -244,9 +241,10 @@
// UpdateCheckAllowed returns whether it is allowed to request an update check
// to Omaha.
- virtual EvalStatus UpdateCheckAllowed(
- EvaluationContext* ec, State* state, std::string* error,
- UpdateCheckParams* result) const = 0;
+ virtual EvalStatus UpdateCheckAllowed(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ UpdateCheckParams* result) const = 0;
// UpdateCanBeApplied returns whether the given |install_plan| can be acted
// on at this time. The reason for not applying is returned in |result|.
@@ -265,12 +263,11 @@
// that need to be persisted has changed, returns
// EvalStatus::kAskMeAgainLater. Arguments include an |update_state| that
// encapsulates data pertaining to the current ongoing update process.
- virtual EvalStatus UpdateCanStart(
- EvaluationContext* ec,
- State* state,
- std::string* error,
- UpdateDownloadParams* result,
- UpdateState update_state) const = 0;
+ virtual EvalStatus UpdateCanStart(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ UpdateDownloadParams* result,
+ UpdateState update_state) const = 0;
// Checks whether downloading of an update is allowed; currently, this checks
// whether the network connection type is suitable for updating over. May
@@ -278,26 +275,28 @@
// Returns |EvalStatus::kSucceeded|, setting |result| according to whether or
// not the current connection can be used; on error, returns
// |EvalStatus::kFailed| and sets |error| accordingly.
- virtual EvalStatus UpdateDownloadAllowed(
- EvaluationContext* ec,
- State* state,
- std::string* error,
- bool* result) const = 0;
+ virtual EvalStatus UpdateDownloadAllowed(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ bool* result) const = 0;
// Checks whether P2P is enabled. This may consult device policy and other
// global settings.
- virtual EvalStatus P2PEnabled(
- EvaluationContext* ec, State* state, std::string* error,
- bool* result) const = 0;
+ virtual EvalStatus P2PEnabled(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ bool* result) const = 0;
// Checks whether P2P is enabled, but blocks (returns
// |EvalStatus::kAskMeAgainLater|) until it is different from |prev_result|.
// If the P2P enabled status is not expected to change, will return
// immediately with |EvalStatus::kSucceeded|. This internally uses the
// P2PEnabled() policy above.
- virtual EvalStatus P2PEnabledChanged(
- EvaluationContext* ec, State* state, std::string* error,
- bool* result, bool prev_result) const = 0;
+ virtual EvalStatus P2PEnabledChanged(EvaluationContext* ec,
+ State* state,
+ std::string* error,
+ bool* result,
+ bool prev_result) const = 0;
protected:
Policy() {}
diff --git a/update_manager/policy_utils.h b/update_manager/policy_utils.h
index eaf9ee9..3204780 100644
--- a/update_manager/policy_utils.h
+++ b/update_manager/policy_utils.h
@@ -30,13 +30,13 @@
// const int* my_value = ec->GetValue(state->my_provider()->var_my_value());
// POLICY_CHECK_VALUE_AND_FAIL(my_value, error);
//
-#define POLICY_CHECK_VALUE_AND_FAIL(ptr, error) \
- do { \
- if ((ptr) == nullptr) { \
- *(error) = #ptr " is required but is null."; \
- return EvalStatus::kFailed; \
- } \
- } while (false)
+#define POLICY_CHECK_VALUE_AND_FAIL(ptr, error) \
+ do { \
+ if ((ptr) == nullptr) { \
+ *(error) = #ptr " is required but is null."; \
+ return EvalStatus::kFailed; \
+ } \
+ } while (false)
namespace chromeos_update_manager {
diff --git a/update_manager/prng_unittest.cc b/update_manager/prng_unittest.cc
index 2a3f689..cb35f0a 100644
--- a/update_manager/prng_unittest.cc
+++ b/update_manager/prng_unittest.cc
@@ -63,7 +63,7 @@
TEST(UmPRNGTest, RandCoversRange) {
PRNG a(42);
- int hits[11] = { 0 };
+ int hits[11] = {0};
for (int i = 0; i < 1000; i++) {
int r = a.RandMinMax(0, 10);
diff --git a/update_manager/real_device_policy_provider.cc b/update_manager/real_device_policy_provider.cc
index e0872bb..586ee3e 100644
--- a/update_manager/real_device_policy_provider.cc
+++ b/update_manager/real_device_policy_provider.cc
@@ -103,10 +103,9 @@
TimeDelta::FromMinutes(kDevicePolicyRefreshRateInMinutes));
}
-template<typename T>
+template <typename T>
void RealDevicePolicyProvider::UpdateVariable(
- AsyncCopyVariable<T>* var,
- bool (DevicePolicy::*getter_method)(T*) const) {
+ AsyncCopyVariable<T>* var, bool (DevicePolicy::*getter_method)(T*) const) {
T new_value;
if (policy_provider_->device_policy_is_loaded() &&
(policy_provider_->GetDevicePolicy().*getter_method)(&new_value)) {
@@ -116,7 +115,7 @@
}
}
-template<typename T>
+template <typename T>
void RealDevicePolicyProvider::UpdateVariable(
AsyncCopyVariable<T>* var,
bool (RealDevicePolicyProvider::*getter_method)(T*) const) {
@@ -147,10 +146,10 @@
}
bool RealDevicePolicyProvider::ConvertAllowedConnectionTypesForUpdate(
- set<ConnectionType>* allowed_types) const {
+ set<ConnectionType>* allowed_types) const {
set<string> allowed_types_str;
- if (!policy_provider_->GetDevicePolicy()
- .GetAllowedConnectionTypesForUpdate(&allowed_types_str)) {
+ if (!policy_provider_->GetDevicePolicy().GetAllowedConnectionTypesForUpdate(
+ &allowed_types_str)) {
return false;
}
allowed_types->clear();
@@ -170,7 +169,7 @@
TimeDelta* scatter_factor) const {
int64_t scatter_factor_in_seconds;
if (!policy_provider_->GetDevicePolicy().GetScatterFactorInSeconds(
- &scatter_factor_in_seconds)) {
+ &scatter_factor_in_seconds)) {
return false;
}
if (scatter_factor_in_seconds < 0) {
diff --git a/update_manager/real_device_policy_provider.h b/update_manager/real_device_policy_provider.h
index d999d81..bda4cff 100644
--- a/update_manager/real_device_policy_provider.h
+++ b/update_manager/real_device_policy_provider.h
@@ -85,21 +85,17 @@
}
Variable<std::set<chromeos_update_engine::ConnectionType>>*
- var_allowed_connection_types_for_update() override {
+ var_allowed_connection_types_for_update() override {
return &var_allowed_connection_types_for_update_;
}
- Variable<std::string>* var_owner() override {
- return &var_owner_;
- }
+ Variable<std::string>* var_owner() override { return &var_owner_; }
Variable<bool>* var_http_downloads_enabled() override {
return &var_http_downloads_enabled_;
}
- Variable<bool>* var_au_p2p_enabled() override {
- return &var_au_p2p_enabled_;
- }
+ Variable<bool>* var_au_p2p_enabled() override { return &var_au_p2p_enabled_; }
Variable<bool>* var_allow_kiosk_app_control_chrome_version() override {
return &var_allow_kiosk_app_control_chrome_version_;
@@ -136,16 +132,16 @@
// Updates the async variable |var| based on the result value of the method
// passed, which is a DevicePolicy getter method.
- template<typename T>
+ template <typename T>
void UpdateVariable(AsyncCopyVariable<T>* var,
bool (policy::DevicePolicy::*getter_method)(T*) const);
// Updates the async variable |var| based on the result value of the getter
// method passed, which is a wrapper getter on this class.
- template<typename T>
- void UpdateVariable(
- AsyncCopyVariable<T>* var,
- bool (RealDevicePolicyProvider::*getter_method)(T*) const);
+ template <typename T>
+ void UpdateVariable(AsyncCopyVariable<T>* var,
+ bool (RealDevicePolicyProvider::*getter_method)(T*)
+ const);
// Wrapper for DevicePolicy::GetRollbackToTargetVersion() that converts the
// result to RollbackToTargetVersion.
@@ -182,8 +178,8 @@
#endif // USE_DBUS
// Variable exposing whether the policy is loaded.
- AsyncCopyVariable<bool> var_device_policy_is_loaded_{
- "policy_is_loaded", false};
+ AsyncCopyVariable<bool> var_device_policy_is_loaded_{"policy_is_loaded",
+ false};
// Variables mapping the exposed methods from the policy::DevicePolicy.
AsyncCopyVariable<std::string> var_release_channel_{"release_channel"};
diff --git a/update_manager/real_device_policy_provider_unittest.cc b/update_manager/real_device_policy_provider_unittest.cc
index e9c7b25..0d7b0d0 100644
--- a/update_manager/real_device_policy_provider_unittest.cc
+++ b/update_manager/real_device_policy_provider_unittest.cc
@@ -49,12 +49,12 @@
using std::string;
using std::unique_ptr;
using std::vector;
+using testing::_;
using testing::DoAll;
using testing::Mock;
using testing::Return;
using testing::ReturnRef;
using testing::SetArgPointee;
-using testing::_;
namespace chromeos_update_manager {
@@ -90,8 +90,7 @@
}
void SetUpNonExistentDevicePolicy() {
- ON_CALL(mock_policy_provider_, Reload())
- .WillByDefault(Return(false));
+ ON_CALL(mock_policy_provider_, Reload()).WillByDefault(Return(false));
ON_CALL(mock_policy_provider_, device_policy_is_loaded())
.WillByDefault(Return(false));
EXPECT_CALL(mock_policy_provider_, GetDevicePolicy()).Times(0);
@@ -99,8 +98,7 @@
void SetUpExistentDevicePolicy() {
// Setup the default behavior of the mocked PolicyProvider.
- ON_CALL(mock_policy_provider_, Reload())
- .WillByDefault(Return(true));
+ ON_CALL(mock_policy_provider_, Reload()).WillByDefault(Return(true));
ON_CALL(mock_policy_provider_, device_policy_is_loaded())
.WillByDefault(Return(true));
ON_CALL(mock_policy_provider_, GetDevicePolicy())
diff --git a/update_manager/real_random_provider_unittest.cc b/update_manager/real_random_provider_unittest.cc
index ca67da6..1b22063 100644
--- a/update_manager/real_random_provider_unittest.cc
+++ b/update_manager/real_random_provider_unittest.cc
@@ -55,9 +55,8 @@
// by design, once every 2^320 runs.
bool is_same_value = true;
for (int i = 0; i < 5; i++) {
- unique_ptr<const uint64_t> other_value(
- provider_->var_seed()->GetValue(UmTestUtils::DefaultTimeout(),
- nullptr));
+ unique_ptr<const uint64_t> other_value(provider_->var_seed()->GetValue(
+ UmTestUtils::DefaultTimeout(), nullptr));
ASSERT_NE(nullptr, other_value.get());
is_same_value = is_same_value && *other_value == *value;
}
diff --git a/update_manager/real_shill_provider.cc b/update_manager/real_shill_provider.cc
index 2c58a7e..0144603 100644
--- a/update_manager/real_shill_provider.cc
+++ b/update_manager/real_shill_provider.cc
@@ -94,8 +94,8 @@
// Update the connection status.
default_service_path_ = default_service_path;
- bool is_connected = (default_service_path_.IsValid() &&
- default_service_path_.value() != "/");
+ bool is_connected =
+ (default_service_path_.IsValid() && default_service_path_.value() != "/");
var_is_connected_.SetValue(is_connected);
var_conn_last_changed_.SetValue(clock_->GetWallclockTime());
diff --git a/update_manager/real_shill_provider.h b/update_manager/real_shill_provider.h
index e7708c8..ec5c570 100644
--- a/update_manager/real_shill_provider.h
+++ b/update_manager/real_shill_provider.h
@@ -46,15 +46,14 @@
// Initializes the provider and returns whether it succeeded.
bool Init();
- Variable<bool>* var_is_connected() override {
- return &var_is_connected_;
- }
+ Variable<bool>* var_is_connected() override { return &var_is_connected_; }
Variable<chromeos_update_engine::ConnectionType>* var_conn_type() override {
return &var_conn_type_;
}
- Variable<chromeos_update_engine::ConnectionTethering>* var_conn_tethering() override {
+ Variable<chromeos_update_engine::ConnectionTethering>* var_conn_tethering()
+ override {
return &var_conn_tethering_;
}
diff --git a/update_manager/real_shill_provider_unittest.cc b/update_manager/real_shill_provider_unittest.cc
index 6506923..dcc729a 100644
--- a/update_manager/real_shill_provider_unittest.cc
+++ b/update_manager/real_shill_provider_unittest.cc
@@ -41,10 +41,10 @@
using org::chromium::flimflam::ManagerProxyMock;
using org::chromium::flimflam::ServiceProxyMock;
using std::unique_ptr;
+using testing::_;
using testing::Mock;
using testing::Return;
using testing::SetArgPointee;
-using testing::_;
namespace {
@@ -99,9 +99,7 @@
return time;
}
- Time ConnChangedTime() {
- return InitTime() + TimeDelta::FromSeconds(10);
- }
+ Time ConnChangedTime() { return InitTime() + TimeDelta::FromSeconds(10); }
// Sets the default_service object path in the response from the
// ManagerProxyMock instance.
@@ -210,8 +208,9 @@
chromeos_update_engine::FakeShillProxy* fake_shill_proxy_;
// The registered signal handler for the signal Manager.PropertyChanged.
- chromeos_update_engine::dbus_test_utils::MockSignalHandler<
- void(const std::string&, const brillo::Any&)> manager_property_changed_;
+ chromeos_update_engine::dbus_test_utils::MockSignalHandler<void(
+ const std::string&, const brillo::Any&)>
+ manager_property_changed_;
unique_ptr<RealShillProvider> provider_;
};
@@ -269,7 +268,6 @@
return service_proxy_mock;
}
-
// Query the connection status, type and time last changed, as they were set
// during initialization (no signals).
TEST_F(UmRealShillProviderTest, ReadBaseValues) {
@@ -315,17 +313,15 @@
// Test that Wifi connection is identified correctly.
TEST_F(UmRealShillProviderTest, ReadConnTypeWifi) {
InitWithDefaultService("/");
- SetupConnectionAndTestType(kFakeWifiServicePath,
- shill::kTypeWifi,
- ConnectionType::kWifi);
+ SetupConnectionAndTestType(
+ kFakeWifiServicePath, shill::kTypeWifi, ConnectionType::kWifi);
}
// Test that Wimax connection is identified correctly.
TEST_F(UmRealShillProviderTest, ReadConnTypeWimax) {
InitWithDefaultService("/");
- SetupConnectionAndTestType(kFakeWimaxServicePath,
- shill::kTypeWimax,
- ConnectionType::kWimax);
+ SetupConnectionAndTestType(
+ kFakeWimaxServicePath, shill::kTypeWimax, ConnectionType::kWimax);
}
// Test that Bluetooth connection is identified correctly.
@@ -347,9 +343,8 @@
// Test that an unknown connection is identified as such.
TEST_F(UmRealShillProviderTest, ReadConnTypeUnknown) {
InitWithDefaultService("/");
- SetupConnectionAndTestType(kFakeUnknownServicePath,
- "FooConnectionType",
- ConnectionType::kUnknown);
+ SetupConnectionAndTestType(
+ kFakeUnknownServicePath, "FooConnectionType", ConnectionType::kUnknown);
}
// Tests that VPN connection is identified correctly.
@@ -406,9 +401,8 @@
shill::kTypeEthernet,
ConnectionType::kEthernet);
- SetupConnectionAndTestType(kFakeWifiServicePath,
- shill::kTypeWifi,
- ConnectionType::kWifi);
+ SetupConnectionAndTestType(
+ kFakeWifiServicePath, shill::kTypeWifi, ConnectionType::kWifi);
}
// Test that a non-tethering mode is identified correctly.
@@ -438,9 +432,8 @@
// Test that an unknown tethering mode is identified as such.
TEST_F(UmRealShillProviderTest, ReadConnTetheringUnknown) {
InitWithDefaultService("/");
- SetupConnectionAndTestTethering(kFakeWifiServicePath,
- "FooConnTethering",
- ConnectionTethering::kUnknown);
+ SetupConnectionAndTestTethering(
+ kFakeWifiServicePath, "FooConnTethering", ConnectionTethering::kUnknown);
}
// Ensure that the connection tethering mode is properly cached in the provider.
diff --git a/update_manager/real_state.h b/update_manager/real_state.h
index e83c49d..056d46d 100644
--- a/update_manager/real_state.h
+++ b/update_manager/real_state.h
@@ -34,34 +34,24 @@
ShillProvider* shill_provider,
SystemProvider* system_provider,
TimeProvider* time_provider,
- UpdaterProvider* updater_provider) :
- config_provider_(config_provider),
- device_policy_provider_(device_policy_provider),
- random_provider_(random_provider),
- shill_provider_(shill_provider),
- system_provider_(system_provider),
- time_provider_(time_provider),
- updater_provider_(updater_provider) {}
+ UpdaterProvider* updater_provider)
+ : config_provider_(config_provider),
+ device_policy_provider_(device_policy_provider),
+ random_provider_(random_provider),
+ shill_provider_(shill_provider),
+ system_provider_(system_provider),
+ time_provider_(time_provider),
+ updater_provider_(updater_provider) {}
// These methods return the given provider.
- ConfigProvider* config_provider() override {
- return config_provider_.get();
- }
+ ConfigProvider* config_provider() override { return config_provider_.get(); }
DevicePolicyProvider* device_policy_provider() override {
return device_policy_provider_.get();
}
- RandomProvider* random_provider() override {
- return random_provider_.get();
- }
- ShillProvider* shill_provider() override {
- return shill_provider_.get();
- }
- SystemProvider* system_provider() override {
- return system_provider_.get();
- }
- TimeProvider* time_provider() override {
- return time_provider_.get();
- }
+ RandomProvider* random_provider() override { return random_provider_.get(); }
+ ShillProvider* shill_provider() override { return shill_provider_.get(); }
+ SystemProvider* system_provider() override { return system_provider_.get(); }
+ TimeProvider* time_provider() override { return time_provider_.get(); }
UpdaterProvider* updater_provider() override {
return updater_provider_.get();
}
diff --git a/update_manager/real_system_provider.cc b/update_manager/real_system_provider.cc
index 53e9ab3..a900071 100644
--- a/update_manager/real_system_provider.cc
+++ b/update_manager/real_system_provider.cc
@@ -95,23 +95,20 @@
} // namespace
bool RealSystemProvider::Init() {
- var_is_normal_boot_mode_.reset(
- new ConstCopyVariable<bool>("is_normal_boot_mode",
- hardware_->IsNormalBootMode()));
+ var_is_normal_boot_mode_.reset(new ConstCopyVariable<bool>(
+ "is_normal_boot_mode", hardware_->IsNormalBootMode()));
- var_is_official_build_.reset(
- new ConstCopyVariable<bool>("is_official_build",
- hardware_->IsOfficialBuild()));
+ var_is_official_build_.reset(new ConstCopyVariable<bool>(
+ "is_official_build", hardware_->IsOfficialBuild()));
- var_is_oobe_complete_.reset(
- new CallCopyVariable<bool>(
- "is_oobe_complete",
- base::Bind(&chromeos_update_engine::HardwareInterface::IsOOBEComplete,
- base::Unretained(hardware_), nullptr)));
+ var_is_oobe_complete_.reset(new CallCopyVariable<bool>(
+ "is_oobe_complete",
+ base::Bind(&chromeos_update_engine::HardwareInterface::IsOOBEComplete,
+ base::Unretained(hardware_),
+ nullptr)));
- var_num_slots_.reset(
- new ConstCopyVariable<unsigned int>(
- "num_slots", boot_control_->GetNumSlots()));
+ var_num_slots_.reset(new ConstCopyVariable<unsigned int>(
+ "num_slots", boot_control_->GetNumSlots()));
var_kiosk_required_platform_version_.reset(new RetryPollVariable<string>(
"kiosk_required_platform_version",
diff --git a/update_manager/real_system_provider.h b/update_manager/real_system_provider.h
index 9d71d0d..114c6ea 100644
--- a/update_manager/real_system_provider.h
+++ b/update_manager/real_system_provider.h
@@ -45,7 +45,8 @@
kiosk_app_proxy_(kiosk_app_proxy) {
}
#else
- boot_control_(boot_control) {}
+ boot_control_(boot_control) {
+ }
#endif // USE_CHROME_KIOSK_APP
// Initializes the provider and returns whether it succeeded.
diff --git a/update_manager/real_system_provider_unittest.cc b/update_manager/real_system_provider_unittest.cc
index 4e4da67..f654f7a 100644
--- a/update_manager/real_system_provider_unittest.cc
+++ b/update_manager/real_system_provider_unittest.cc
@@ -39,7 +39,7 @@
#if USE_CHROME_KIOSK_APP
namespace {
-const char kRequiredPlatformVersion[] ="1234.0.0";
+const char kRequiredPlatformVersion[] = "1234.0.0";
} // namespace
#endif // USE_CHROME_KIOSK_APP
diff --git a/update_manager/real_time_provider.cc b/update_manager/real_time_provider.cc
index baa8ae3..efd1747 100644
--- a/update_manager/real_time_provider.cc
+++ b/update_manager/real_time_provider.cc
@@ -38,8 +38,7 @@
: Variable<Time>(name, TimeDelta::FromHours(1)), clock_(clock) {}
protected:
- virtual const Time* GetValue(TimeDelta /* timeout */,
- string* /* errmsg */) {
+ virtual const Time* GetValue(TimeDelta /* timeout */, string* /* errmsg */) {
Time::Exploded now_exp;
clock_->GetWallclockTime().LocalExplode(&now_exp);
now_exp.hour = now_exp.minute = now_exp.second = now_exp.millisecond = 0;
@@ -64,8 +63,7 @@
: Variable<int>(name, TimeDelta::FromMinutes(5)), clock_(clock) {}
protected:
- virtual const int* GetValue(TimeDelta /* timeout */,
- string* /* errmsg */) {
+ virtual const int* GetValue(TimeDelta /* timeout */, string* /* errmsg */) {
Time::Exploded exploded;
clock_->GetWallclockTime().LocalExplode(&exploded);
return new int(exploded.hour);
diff --git a/update_manager/real_time_provider.h b/update_manager/real_time_provider.h
index 989cefb..40dab36 100644
--- a/update_manager/real_time_provider.h
+++ b/update_manager/real_time_provider.h
@@ -39,9 +39,7 @@
return var_curr_date_.get();
}
- Variable<int>* var_curr_hour() override {
- return var_curr_hour_.get();
- }
+ Variable<int>* var_curr_hour() override { return var_curr_hour_.get(); }
Variable<int>* var_curr_minute() override { return var_curr_minute_.get(); }
diff --git a/update_manager/real_updater_provider.cc b/update_manager/real_updater_provider.cc
index 094e79c..134db69 100644
--- a/update_manager/real_updater_provider.cc
+++ b/update_manager/real_updater_provider.cc
@@ -45,10 +45,11 @@
// A templated base class for all update related variables. Provides uniform
// construction and a system state handle.
-template<typename T>
+template <typename T>
class UpdaterVariableBase : public Variable<T> {
public:
- UpdaterVariableBase(const string& name, VariableMode mode,
+ UpdaterVariableBase(const string& name,
+ VariableMode mode,
SystemState* system_state)
: Variable<T>(name, mode), system_state_(system_state) {}
@@ -125,8 +126,8 @@
if (raw.progress() < 0.0 || raw.progress() > 1.0) {
if (errmsg) {
- *errmsg = StringPrintf("Invalid progress value received: %f",
- raw.progress());
+ *errmsg =
+ StringPrintf("Invalid progress value received: %f", raw.progress());
}
return nullptr;
}
@@ -157,22 +158,20 @@
};
const StageVariable::CurrOpStrToStage StageVariable::curr_op_str_to_stage[] = {
- {update_engine::kUpdateStatusIdle, Stage::kIdle},
- {update_engine::kUpdateStatusCheckingForUpdate, Stage::kCheckingForUpdate},
- {update_engine::kUpdateStatusUpdateAvailable, Stage::kUpdateAvailable},
- {update_engine::kUpdateStatusDownloading, Stage::kDownloading},
- {update_engine::kUpdateStatusVerifying, Stage::kVerifying},
- {update_engine::kUpdateStatusFinalizing, Stage::kFinalizing},
- {update_engine::kUpdateStatusUpdatedNeedReboot, Stage::kUpdatedNeedReboot},
- { // NOLINT(whitespace/braces)
- update_engine::kUpdateStatusReportingErrorEvent,
- Stage::kReportingErrorEvent
- },
- {update_engine::kUpdateStatusAttemptingRollback, Stage::kAttemptingRollback},
+ {update_engine::kUpdateStatusIdle, Stage::kIdle},
+ {update_engine::kUpdateStatusCheckingForUpdate, Stage::kCheckingForUpdate},
+ {update_engine::kUpdateStatusUpdateAvailable, Stage::kUpdateAvailable},
+ {update_engine::kUpdateStatusDownloading, Stage::kDownloading},
+ {update_engine::kUpdateStatusVerifying, Stage::kVerifying},
+ {update_engine::kUpdateStatusFinalizing, Stage::kFinalizing},
+ {update_engine::kUpdateStatusUpdatedNeedReboot, Stage::kUpdatedNeedReboot},
+ {update_engine::kUpdateStatusReportingErrorEvent,
+ Stage::kReportingErrorEvent},
+ {update_engine::kUpdateStatusAttemptingRollback,
+ Stage::kAttemptingRollback},
};
-const Stage* StageVariable::GetValue(TimeDelta /* timeout */,
- string* errmsg) {
+const Stage* StageVariable::GetValue(TimeDelta /* timeout */, string* errmsg) {
GetStatusHelper raw(system_state(), errmsg);
if (!raw.is_success())
return nullptr;
@@ -316,9 +315,7 @@
prefs->AddObserver(key, this);
OnPrefSet(key);
}
- ~BooleanPrefVariable() {
- prefs_->RemoveObserver(key_, this);
- }
+ ~BooleanPrefVariable() { prefs_->RemoveObserver(key_, this); }
private:
// Reads the actual value from the Prefs instance and updates the Variable
@@ -331,9 +328,7 @@
SetValue(result);
}
- void OnPrefDeleted(const string& key) override {
- SetValue(default_val_);
- }
+ void OnPrefDeleted(const string& key) override { SetValue(default_val_); }
chromeos_update_engine::PrefsInterface* prefs_;
@@ -350,8 +345,8 @@
public:
ConsecutiveFailedUpdateChecksVariable(const string& name,
SystemState* system_state)
- : UpdaterVariableBase<unsigned int>(name, kVariableModePoll,
- system_state) {}
+ : UpdaterVariableBase<unsigned int>(
+ name, kVariableModePoll, system_state) {}
private:
const unsigned int* GetValue(TimeDelta /* timeout */,
@@ -369,8 +364,8 @@
public:
ServerDictatedPollIntervalVariable(const string& name,
SystemState* system_state)
- : UpdaterVariableBase<unsigned int>(name, kVariableModePoll,
- system_state) {}
+ : UpdaterVariableBase<unsigned int>(
+ name, kVariableModePoll, system_state) {}
private:
const unsigned int* GetValue(TimeDelta /* timeout */,
@@ -388,7 +383,7 @@
public:
ForcedUpdateRequestedVariable(const string& name, SystemState* system_state)
: UpdaterVariableBase<UpdateRequestStatus>::UpdaterVariableBase(
- name, kVariableModeAsync, system_state) {
+ name, kVariableModeAsync, system_state) {
system_state->update_attempter()->set_forced_update_pending_callback(
new base::Callback<void(bool, bool)>( // NOLINT(readability/function)
base::Bind(&ForcedUpdateRequestedVariable::Reset,
diff --git a/update_manager/real_updater_provider.h b/update_manager/real_updater_provider.h
index 5e3e27b..1b46895 100644
--- a/update_manager/real_updater_provider.h
+++ b/update_manager/real_updater_provider.h
@@ -52,13 +52,9 @@
return var_update_completed_time_.get();
}
- Variable<double>* var_progress() override {
- return var_progress_.get();
- }
+ Variable<double>* var_progress() override { return var_progress_.get(); }
- Variable<Stage>* var_stage() override {
- return var_stage_.get();
- }
+ Variable<Stage>* var_stage() override { return var_stage_.get(); }
Variable<std::string>* var_new_version() override {
return var_new_version_.get();
@@ -76,9 +72,7 @@
return var_new_channel_.get();
}
- Variable<bool>* var_p2p_enabled() override {
- return var_p2p_enabled_.get();
- }
+ Variable<bool>* var_p2p_enabled() override { return var_p2p_enabled_.get(); }
Variable<bool>* var_cellular_enabled() override {
return var_cellular_enabled_.get();
diff --git a/update_manager/real_updater_provider_unittest.cc b/update_manager/real_updater_provider_unittest.cc
index b653885..fb7a763 100644
--- a/update_manager/real_updater_provider_unittest.cc
+++ b/update_manager/real_updater_provider_unittest.cc
@@ -114,9 +114,8 @@
Time SetupUpdateCompletedTime(bool valid) {
const TimeDelta kDurationSinceUpdate = TimeDelta::FromMinutes(7);
const Time kUpdateBootTime = Time() + kDurationSinceUpdate * 2;
- const Time kCurrBootTime = (valid ?
- kUpdateBootTime + kDurationSinceUpdate :
- kUpdateBootTime - kDurationSinceUpdate);
+ const Time kCurrBootTime = (valid ? kUpdateBootTime + kDurationSinceUpdate
+ : kUpdateBootTime - kDurationSinceUpdate);
const Time kCurrWallclockTime = FixedTime();
EXPECT_CALL(*fake_sys_state_.mock_update_attempter(),
GetBootTimeAtUpdate(_))
diff --git a/update_manager/shill_provider.h b/update_manager/shill_provider.h
index e6f4628..c7bb2e2 100644
--- a/update_manager/shill_provider.h
+++ b/update_manager/shill_provider.h
@@ -40,7 +40,7 @@
// A variable returning the tethering mode of a network connection. Unknown if
// not connected.
virtual Variable<chromeos_update_engine::ConnectionTethering>*
- var_conn_tethering() = 0;
+ var_conn_tethering() = 0;
// A variable returning the time when network connection last changed.
// Initialized to current time.
diff --git a/update_manager/state_factory.cc b/update_manager/state_factory.cc
index 7293692..78cec6a 100644
--- a/update_manager/state_factory.cc
+++ b/update_manager/state_factory.cc
@@ -76,14 +76,12 @@
unique_ptr<RealUpdaterProvider> updater_provider(
new RealUpdaterProvider(system_state));
- if (!(config_provider->Init() &&
- device_policy_provider->Init() &&
+ if (!(config_provider->Init() && device_policy_provider->Init() &&
random_provider->Init() &&
#if USE_SHILL
shill_provider->Init() &&
#endif // USE_SHILL
- system_provider->Init() &&
- time_provider->Init() &&
+ system_provider->Init() && time_provider->Init() &&
updater_provider->Init())) {
LOG(ERROR) << "Error initializing providers";
return nullptr;
diff --git a/update_manager/umtest_utils.h b/update_manager/umtest_utils.h
index 80693db..576f53c 100644
--- a/update_manager/umtest_utils.h
+++ b/update_manager/umtest_utils.h
@@ -37,7 +37,7 @@
}
// Calls GetValue on |variable| and expects its result to be |expected|.
- template<typename T>
+ template <typename T>
static void ExpectVariableHasValue(const T& expected, Variable<T>* variable) {
ASSERT_NE(nullptr, variable);
std::unique_ptr<const T> value(
@@ -47,7 +47,7 @@
}
// Calls GetValue on |variable| and expects its result to be null.
- template<typename T>
+ template <typename T>
static void ExpectVariableNotSet(Variable<T>* variable) {
ASSERT_NE(nullptr, variable);
std::unique_ptr<const T> value(
diff --git a/update_manager/update_manager-inl.h b/update_manager/update_manager-inl.h
index 77224cf..e9dee3f 100644
--- a/update_manager/update_manager-inl.h
+++ b/update_manager/update_manager-inl.h
@@ -28,13 +28,13 @@
namespace chromeos_update_manager {
-template<typename R, typename... Args>
+template <typename R, typename... Args>
EvalStatus UpdateManager::EvaluatePolicy(
EvaluationContext* ec,
- EvalStatus (Policy::*policy_method)(EvaluationContext*, State*,
- std::string*, R*,
- Args...) const,
- R* result, Args... args) {
+ EvalStatus (Policy::*policy_method)(
+ EvaluationContext*, State*, std::string*, R*, Args...) const,
+ R* result,
+ Args... args) {
// If expiration timeout fired, dump the context and reset expiration.
// IMPORTANT: We must still proceed with evaluation of the policy in this
// case, so that the evaluation time (and corresponding reevaluation timeouts)
@@ -53,15 +53,15 @@
// First try calling the actual policy.
std::string error;
- EvalStatus status = (policy_.get()->*policy_method)(ec, state_.get(), &error,
- result, args...);
+ EvalStatus status = (policy_.get()->*policy_method)(
+ ec, state_.get(), &error, result, args...);
// If evaluating the main policy failed, defer to the default policy.
if (status == EvalStatus::kFailed) {
LOG(WARNING) << "Evaluating policy failed: " << error
<< "\nEvaluation context: " << ec->DumpContext();
error.clear();
- status = (default_policy_.*policy_method)(ec, state_.get(), &error, result,
- args...);
+ status = (default_policy_.*policy_method)(
+ ec, state_.get(), &error, result, args...);
if (status == EvalStatus::kFailed) {
LOG(WARNING) << "Evaluating default policy failed: " << error;
} else if (status == EvalStatus::kAskMeAgainLater) {
@@ -76,13 +76,12 @@
return status;
}
-template<typename R, typename... Args>
+template <typename R, typename... Args>
void UpdateManager::OnPolicyReadyToEvaluate(
scoped_refptr<EvaluationContext> ec,
base::Callback<void(EvalStatus status, const R& result)> callback,
- EvalStatus (Policy::*policy_method)(EvaluationContext*, State*,
- std::string*, R*,
- Args...) const,
+ EvalStatus (Policy::*policy_method)(
+ EvaluationContext*, State*, std::string*, R*, Args...) const,
Args... args) {
// Evaluate the policy.
R result;
@@ -95,10 +94,13 @@
}
// Re-schedule the policy request based on used variables.
- base::Closure reeval_callback = base::Bind(
- &UpdateManager::OnPolicyReadyToEvaluate<R, Args...>,
- base::Unretained(this), ec, callback,
- policy_method, args...);
+ base::Closure reeval_callback =
+ base::Bind(&UpdateManager::OnPolicyReadyToEvaluate<R, Args...>,
+ base::Unretained(this),
+ ec,
+ callback,
+ policy_method,
+ args...);
if (ec->RunOnValueChangeOrTimeout(reeval_callback))
return; // Reevaluation scheduled successfully.
@@ -111,12 +113,12 @@
callback.Run(status, result);
}
-template<typename R, typename... ActualArgs, typename... ExpectedArgs>
+template <typename R, typename... ActualArgs, typename... ExpectedArgs>
EvalStatus UpdateManager::PolicyRequest(
- EvalStatus (Policy::*policy_method)(EvaluationContext*, State*,
- std::string*, R*,
- ExpectedArgs...) const,
- R* result, ActualArgs... args) {
+ EvalStatus (Policy::*policy_method)(
+ EvaluationContext*, State*, std::string*, R*, ExpectedArgs...) const,
+ R* result,
+ ActualArgs... args) {
scoped_refptr<EvaluationContext> ec(
new EvaluationContext(clock_, evaluation_timeout_));
// A PolicyRequest always consists on a single evaluation on a new
@@ -124,8 +126,8 @@
// IMPORTANT: To ensure that ActualArgs can be converted to ExpectedArgs, we
// explicitly instantiate EvaluatePolicy with the latter in lieu of the
// former.
- EvalStatus ret = EvaluatePolicy<R, ExpectedArgs...>(ec.get(), policy_method,
- result, args...);
+ EvalStatus ret = EvaluatePolicy<R, ExpectedArgs...>(
+ ec.get(), policy_method, result, args...);
// Sync policy requests must not block, if they do then this is an error.
DCHECK(EvalStatus::kAskMeAgainLater != ret);
LOG_IF(WARNING, EvalStatus::kAskMeAgainLater == ret)
@@ -133,20 +135,20 @@
return ret;
}
-template<typename R, typename... ActualArgs, typename... ExpectedArgs>
+template <typename R, typename... ActualArgs, typename... ExpectedArgs>
void UpdateManager::AsyncPolicyRequest(
base::Callback<void(EvalStatus, const R& result)> callback,
- EvalStatus (Policy::*policy_method)(EvaluationContext*, State*,
- std::string*, R*,
- ExpectedArgs...) const,
+ EvalStatus (Policy::*policy_method)(
+ EvaluationContext*, State*, std::string*, R*, ExpectedArgs...) const,
ActualArgs... args) {
- scoped_refptr<EvaluationContext> ec =
- new EvaluationContext(
- clock_, evaluation_timeout_, expiration_timeout_,
- std::unique_ptr<base::Callback<void(EvaluationContext*)>>(
- new base::Callback<void(EvaluationContext*)>(
- base::Bind(&UpdateManager::UnregisterEvalContext,
- weak_ptr_factory_.GetWeakPtr()))));
+ scoped_refptr<EvaluationContext> ec = new EvaluationContext(
+ clock_,
+ evaluation_timeout_,
+ expiration_timeout_,
+ std::unique_ptr<base::Callback<void(EvaluationContext*)>>(
+ new base::Callback<void(EvaluationContext*)>(
+ base::Bind(&UpdateManager::UnregisterEvalContext,
+ weak_ptr_factory_.GetWeakPtr()))));
if (!ec_repo_.insert(ec.get()).second) {
LOG(ERROR) << "Failed to register evaluation context; this is a bug.";
}
@@ -154,9 +156,13 @@
// IMPORTANT: To ensure that ActualArgs can be converted to ExpectedArgs, we
// explicitly instantiate UpdateManager::OnPolicyReadyToEvaluate with the
// latter in lieu of the former.
- base::Closure eval_callback = base::Bind(
- &UpdateManager::OnPolicyReadyToEvaluate<R, ExpectedArgs...>,
- base::Unretained(this), ec, callback, policy_method, args...);
+ base::Closure eval_callback =
+ base::Bind(&UpdateManager::OnPolicyReadyToEvaluate<R, ExpectedArgs...>,
+ base::Unretained(this),
+ ec,
+ callback,
+ policy_method,
+ args...);
brillo::MessageLoop::current()->PostTask(FROM_HERE, eval_callback);
}
diff --git a/update_manager/update_manager.cc b/update_manager/update_manager.cc
index 25f3216..5dfc09c 100644
--- a/update_manager/update_manager.cc
+++ b/update_manager/update_manager.cc
@@ -27,11 +27,14 @@
UpdateManager::UpdateManager(chromeos_update_engine::ClockInterface* clock,
base::TimeDelta evaluation_timeout,
- base::TimeDelta expiration_timeout, State* state)
- : default_policy_(clock), state_(state), clock_(clock),
- evaluation_timeout_(evaluation_timeout),
- expiration_timeout_(expiration_timeout),
- weak_ptr_factory_(this) {
+ base::TimeDelta expiration_timeout,
+ State* state)
+ : default_policy_(clock),
+ state_(state),
+ clock_(clock),
+ evaluation_timeout_(evaluation_timeout),
+ expiration_timeout_(expiration_timeout),
+ weak_ptr_factory_(this) {
#ifdef __ANDROID__
policy_.reset(new AndroidThingsPolicy());
#else
diff --git a/update_manager/update_manager.h b/update_manager/update_manager.h
index a2f35df..b0fd97f 100644
--- a/update_manager/update_manager.h
+++ b/update_manager/update_manager.h
@@ -34,7 +34,7 @@
namespace chromeos_update_manager {
// Comparator for scoped_refptr objects.
-template<typename T>
+template <typename T>
struct ScopedRefPtrLess {
bool operator()(const scoped_refptr<T>& first,
const scoped_refptr<T>& second) const {
@@ -49,7 +49,8 @@
// |state|.
UpdateManager(chromeos_update_engine::ClockInterface* clock,
base::TimeDelta evaluation_timeout,
- base::TimeDelta expiration_timeout, State* state);
+ base::TimeDelta expiration_timeout,
+ State* state);
virtual ~UpdateManager();
@@ -68,12 +69,12 @@
//
// An example call to this method is:
// um.PolicyRequest(&Policy::SomePolicyMethod, &bool_result, arg1, arg2);
- template<typename R, typename... ActualArgs, typename... ExpectedArgs>
+ template <typename R, typename... ActualArgs, typename... ExpectedArgs>
EvalStatus PolicyRequest(
- EvalStatus (Policy::*policy_method)(EvaluationContext*, State*,
- std::string*, R*,
- ExpectedArgs...) const,
- R* result, ActualArgs...);
+ EvalStatus (Policy::*policy_method)(
+ EvaluationContext*, State*, std::string*, R*, ExpectedArgs...) const,
+ R* result,
+ ActualArgs...);
// Evaluates the given |policy_method| policy with the provided |args|
// arguments and calls the |callback| callback with the result when done.
@@ -83,19 +84,16 @@
// policy until another status is returned. If the policy implementation based
// its return value solely on const variables, the callback will be called
// with the EvalStatus::kAskMeAgainLater status (which indicates an error).
- template<typename R, typename... ActualArgs, typename... ExpectedArgs>
+ template <typename R, typename... ActualArgs, typename... ExpectedArgs>
void AsyncPolicyRequest(
base::Callback<void(EvalStatus, const R& result)> callback,
- EvalStatus (Policy::*policy_method)(EvaluationContext*, State*,
- std::string*, R*,
- ExpectedArgs...) const,
+ EvalStatus (Policy::*policy_method)(
+ EvaluationContext*, State*, std::string*, R*, ExpectedArgs...) const,
ActualArgs... args);
protected:
// The UpdateManager receives ownership of the passed Policy instance.
- void set_policy(const Policy* policy) {
- policy_.reset(policy);
- }
+ void set_policy(const Policy* policy) { policy_.reset(policy); }
// State getter used for testing.
State* state() { return state_.get(); }
@@ -111,13 +109,13 @@
// EvaluatePolicy() evaluates the passed |policy_method| method on the current
// policy with the given |args| arguments. If the method fails, the default
// policy is used instead.
- template<typename R, typename... Args>
+ template <typename R, typename... Args>
EvalStatus EvaluatePolicy(
EvaluationContext* ec,
- EvalStatus (Policy::*policy_method)(EvaluationContext*, State*,
- std::string*, R*,
- Args...) const,
- R* result, Args... args);
+ EvalStatus (Policy::*policy_method)(
+ EvaluationContext*, State*, std::string*, R*, Args...) const,
+ R* result,
+ Args... args);
// OnPolicyReadyToEvaluate() is called by the main loop when the evaluation
// of the given |policy_method| should be executed. If the evaluation finishes
@@ -125,13 +123,12 @@
// returned by the policy. If the evaluation returns an
// EvalStatus::kAskMeAgainLater state, the |callback| will NOT be called and
// the evaluation will be re-scheduled to be called later.
- template<typename R, typename... Args>
+ template <typename R, typename... Args>
void OnPolicyReadyToEvaluate(
scoped_refptr<EvaluationContext> ec,
base::Callback<void(EvalStatus status, const R& result)> callback,
- EvalStatus (Policy::*policy_method)(EvaluationContext*, State*,
- std::string*, R*,
- Args...) const,
+ EvalStatus (Policy::*policy_method)(
+ EvaluationContext*, State*, std::string*, R*, Args...) const,
Args... args);
// Unregisters (removes from repo) a previously created EvaluationContext.
@@ -163,7 +160,8 @@
// will remove all pending events associated with all outstanding contexts
// (which should, in turn, trigger their destruction).
std::set<scoped_refptr<EvaluationContext>,
- ScopedRefPtrLess<EvaluationContext>> ec_repo_;
+ ScopedRefPtrLess<EvaluationContext>>
+ ec_repo_;
base::WeakPtrFactory<UpdateManager> weak_ptr_factory_;
diff --git a/update_manager/update_manager_unittest.cc b/update_manager/update_manager_unittest.cc
index 125a60c..f1a8d17 100644
--- a/update_manager/update_manager_unittest.cc
+++ b/update_manager/update_manager_unittest.cc
@@ -81,13 +81,13 @@
void SetUp() override {
loop_.SetAsCurrent();
fake_state_ = new FakeState();
- umut_.reset(new UpdateManager(&fake_clock_, TimeDelta::FromSeconds(5),
- TimeDelta::FromSeconds(1), fake_state_));
+ umut_.reset(new UpdateManager(&fake_clock_,
+ TimeDelta::FromSeconds(5),
+ TimeDelta::FromSeconds(1),
+ fake_state_));
}
- void TearDown() override {
- EXPECT_FALSE(loop_.PendingTasks());
- }
+ void TearDown() override { EXPECT_FALSE(loop_.PendingTasks()); }
base::SimpleTestClock test_clock_;
brillo::FakeMessageLoop loop_{&test_clock_};
@@ -103,7 +103,8 @@
public:
explicit FailingPolicy(int* num_called_p) : num_called_p_(num_called_p) {}
FailingPolicy() : FailingPolicy(nullptr) {}
- EvalStatus UpdateCheckAllowed(EvaluationContext* ec, State* state,
+ EvalStatus UpdateCheckAllowed(EvaluationContext* ec,
+ State* state,
string* error,
UpdateCheckParams* result) const override {
if (num_called_p_)
@@ -121,7 +122,8 @@
// The LazyPolicy always returns EvalStatus::kAskMeAgainLater.
class LazyPolicy : public DefaultPolicy {
- EvalStatus UpdateCheckAllowed(EvaluationContext* ec, State* state,
+ EvalStatus UpdateCheckAllowed(EvaluationContext* ec,
+ State* state,
string* error,
UpdateCheckParams* result) const override {
return EvalStatus::kAskMeAgainLater;
@@ -139,9 +141,11 @@
class DelayPolicy : public DefaultPolicy {
public:
DelayPolicy(int sleep_secs, Time time_threshold, int* num_called_p)
- : sleep_secs_(sleep_secs), time_threshold_(time_threshold),
+ : sleep_secs_(sleep_secs),
+ time_threshold_(time_threshold),
num_called_p_(num_called_p) {}
- EvalStatus UpdateCheckAllowed(EvaluationContext* ec, State* state,
+ EvalStatus UpdateCheckAllowed(EvaluationContext* ec,
+ State* state,
string* error,
UpdateCheckParams* result) const override {
if (num_called_p_)
@@ -173,9 +177,10 @@
// of EvalStatus and T instances. This allows to create a callback that keeps
// track of when it is called and the arguments passed to it, to be used with
// the UpdateManager::AsyncPolicyRequest().
-template<typename T>
+template <typename T>
static void AccumulateCallsCallback(vector<pair<EvalStatus, T>>* acc,
- EvalStatus status, const T& result) {
+ EvalStatus status,
+ const T& result) {
acc->push_back(std::make_pair(status, result));
}
@@ -183,8 +188,8 @@
// this tests cover all policy requests as defined in Policy.
TEST_F(UmUpdateManagerTest, PolicyRequestCallUpdateCheckAllowed) {
UpdateCheckParams result;
- EXPECT_EQ(EvalStatus::kSucceeded, umut_->PolicyRequest(
- &Policy::UpdateCheckAllowed, &result));
+ EXPECT_EQ(EvalStatus::kSucceeded,
+ umut_->PolicyRequest(&Policy::UpdateCheckAllowed, &result));
}
TEST_F(UmUpdateManagerTest, PolicyRequestCallUpdateCanStart) {
@@ -213,9 +218,9 @@
update_state.scatter_check_threshold_max = 8;
UpdateDownloadParams result;
- EXPECT_EQ(EvalStatus::kSucceeded,
- umut_->PolicyRequest(&Policy::UpdateCanStart, &result,
- update_state));
+ EXPECT_EQ(
+ EvalStatus::kSucceeded,
+ umut_->PolicyRequest(&Policy::UpdateCanStart, &result, update_state));
}
TEST_F(UmUpdateManagerTest, PolicyRequestCallsDefaultOnError) {
@@ -225,8 +230,8 @@
// which will set this as true.
UpdateCheckParams result;
result.updates_enabled = false;
- EvalStatus status = umut_->PolicyRequest(
- &Policy::UpdateCheckAllowed, &result);
+ EvalStatus status =
+ umut_->PolicyRequest(&Policy::UpdateCheckAllowed, &result);
EXPECT_EQ(EvalStatus::kSucceeded, status);
EXPECT_TRUE(result.updates_enabled);
}
@@ -250,8 +255,8 @@
umut_->set_policy(new FailingPolicy());
vector<pair<EvalStatus, UpdateCheckParams>> calls;
- Callback<void(EvalStatus, const UpdateCheckParams&)> callback = Bind(
- AccumulateCallsCallback<UpdateCheckParams>, &calls);
+ Callback<void(EvalStatus, const UpdateCheckParams&)> callback =
+ Bind(AccumulateCallsCallback<UpdateCheckParams>, &calls);
umut_->AsyncPolicyRequest(callback, &Policy::UpdateCheckAllowed);
// The callback should wait until we run the main loop for it to be executed.
@@ -291,8 +296,9 @@
// reattempted.
int num_called = 0;
umut_->set_policy(new DelayPolicy(
- 0, fake_clock_.GetWallclockTime() + TimeDelta::FromSeconds(3),
- &num_called));
+ 0,
+ fake_clock_.GetWallclockTime() + TimeDelta::FromSeconds(3),
+ &num_called));
vector<pair<EvalStatus, UpdateCheckParams>> calls;
Callback<void(EvalStatus, const UpdateCheckParams&)> callback =
diff --git a/update_manager/variable.h b/update_manager/variable.h
index 7109692..6c7d350 100644
--- a/update_manager/variable.h
+++ b/update_manager/variable.h
@@ -74,20 +74,14 @@
}
// Returns the variable name as a string.
- const std::string& GetName() const {
- return name_;
- }
+ const std::string& GetName() const { return name_; }
// Returns the variable mode.
- VariableMode GetMode() const {
- return mode_;
- }
+ VariableMode GetMode() const { return mode_; }
// For VariableModePoll variables, it returns the polling interval of this
// variable. In other case, it returns 0.
- base::TimeDelta GetPollInterval() const {
- return poll_interval_;
- }
+ base::TimeDelta GetPollInterval() const { return poll_interval_; }
// Adds and removes observers for value changes on the variable. This only
// works for kVariableAsync variables since the other modes don't track value
@@ -106,8 +100,8 @@
protected:
// Creates a BaseVariable using the default polling interval (5 minutes).
BaseVariable(const std::string& name, VariableMode mode)
- : BaseVariable(name, mode,
- base::TimeDelta::FromMinutes(kDefaultPollMinutes)) {}
+ : BaseVariable(
+ name, mode, base::TimeDelta::FromMinutes(kDefaultPollMinutes)) {}
// Creates a BaseVariable with mode kVariableModePoll and the provided
// polling interval.
@@ -116,8 +110,8 @@
// Reset the poll interval on a polling variable to the given one.
void SetPollInterval(base::TimeDelta poll_interval) {
- DCHECK_EQ(kVariableModePoll, mode_) << "Can't set the poll_interval on a "
- << mode_ << " variable";
+ DCHECK_EQ(kVariableModePoll, mode_)
+ << "Can't set the poll_interval on a " << mode_ << " variable";
poll_interval_ = poll_interval;
}
@@ -140,11 +134,13 @@
FRIEND_TEST(UmBaseVariableTest, NotifyValueChangedTest);
FRIEND_TEST(UmBaseVariableTest, NotifyValueRemovesObserversTest);
- BaseVariable(const std::string& name, VariableMode mode,
+ BaseVariable(const std::string& name,
+ VariableMode mode,
base::TimeDelta poll_interval)
- : name_(name), mode_(mode),
- poll_interval_(mode == kVariableModePoll ?
- poll_interval : base::TimeDelta()) {}
+ : name_(name),
+ mode_(mode),
+ poll_interval_(mode == kVariableModePoll ? poll_interval
+ : base::TimeDelta()) {}
void OnValueChangedNotification() {
// A ValueChanged() method can change the list of observers, for example
@@ -184,7 +180,7 @@
// Interface to an Update Manager variable of a given type. Implementation
// internals are hidden as protected members, since policies should not be
// using them directly.
-template<typename T>
+template <typename T>
class Variable : public BaseVariable {
public:
~Variable() override {}
diff --git a/update_manager/variable_unittest.cc b/update_manager/variable_unittest.cc
index 144002a..fe40ce5 100644
--- a/update_manager/variable_unittest.cc
+++ b/update_manager/variable_unittest.cc
@@ -42,8 +42,7 @@
~DefaultVariable() override {}
protected:
- const T* GetValue(TimeDelta /* timeout */,
- string* /* errmsg */) override {
+ const T* GetValue(TimeDelta /* timeout */, string* /* errmsg */) override {
return new T();
}
@@ -53,9 +52,7 @@
class UmBaseVariableTest : public ::testing::Test {
protected:
- void SetUp() override {
- loop_.SetAsCurrent();
- }
+ void SetUp() override { loop_.SetAsCurrent(); }
brillo::FakeMessageLoop loop_{nullptr};
};
@@ -87,9 +84,7 @@
class BaseVariableObserver : public BaseVariable::ObserverInterface {
public:
- void ValueChanged(BaseVariable* variable) {
- calls_.push_back(variable);
- }
+ void ValueChanged(BaseVariable* variable) { calls_.push_back(variable); }
// List of called functions.
vector<BaseVariable*> calls_;