update_engine: UM: Properly handle update download deterrents.
The UpdateCanStart policy request needs to satisfy two related
requirements:
* It must allow the caller to proceed with the update even if some forms
of download are not allowed (for example, HTTP/HTTPS download blocked
due to scattering) but other are allowed (for example, P2P).
* It needs to assess all the input provided and, upon returning
successfully, convey any new values that pertain to downloading of the
update payload and that need to be persisted (such as the download
URL, backoff and scattering values, and so on). The caller in turn is
assured that, having successfully returned, the policy has indeed
considered all state and it is safe to clear parts of it (such as the
download error history).
This change ensures that the policy suppresses scattering and backoff
decisions if P2P download is allowed. This only suppresses the final
decision, but otherwise still returns whatever URL index and error count
that were inferred. It further adjusts the way in which various download
deterrents (check due, scattering, backoff) are handled, deferring
responses to the very end of the evaluation and thus returning
a complete result.
BUG=chromium:384087
TEST=Unit tests.
Change-Id: Ie95976295c0cd635e2a10912308b8756a677682f
Reviewed-on: https://chromium-review.googlesource.com/222263
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/update_manager/default_policy.cc b/update_manager/default_policy.cc
index 3de9755..1300e14 100644
--- a/update_manager/default_policy.cc
+++ b/update_manager/default_policy.cc
@@ -50,6 +50,7 @@
result->update_can_start = true;
result->cannot_start_reason = UpdateCannotStartReason::kUndefined;
result->download_url_idx = 0;
+ result->download_url_allowed = true;
result->download_url_num_errors = 0;
result->p2p_downloading_allowed = false;
result->p2p_sharing_allowed = false;