update_engine: UM: Separate global P2P usage from payload-specific attributes.
This change is needed for two reasons: (a) The decision regarding the
global P2P enabled state and those pertaining to whether individual
payloads may be downloaded and/or shared via P2P have distinct and not
necessarily nested lifespans. (b) Some parts of the update engine are
concerned with the former and some with the latter, and so we need
separate entry points in the Update Manager to accommodate that.
This also introduces two Omaha-derived values, denoting whether P2P
downloading and/or sharing should be disabled for the current payload,
into the UpdateCanStart policy.
BUG=chromium:425233
TEST=Unit tests.
Change-Id: I0ba0090bd4c5ceb0c812ea218b070945083abd95
Reviewed-on: https://chromium-review.googlesource.com/225150
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/update_manager/default_policy.cc b/update_manager/default_policy.cc
index 1300e14..d49591a 100644
--- a/update_manager/default_policy.cc
+++ b/update_manager/default_policy.cc
@@ -70,4 +70,26 @@
return EvalStatus::kSucceeded;
}
+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 {
+ // 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.
+ *result = false;
+ return EvalStatus::kSucceeded;
+}
+
} // namespace chromeos_update_manager