update_engine: UM: Incorporate backoff logic in UpdateCanStart.

This change adds backoff computation logic to UpdateCanStart. For the
most part, it is extending a private policy call (UpdateDownloadUrl) to
account for previously enacted backoff periods and to compute new ones
when an update failure is identified (accordingly, it is now called
UpdateBackoffAndDownloadUrl).

To conform with the pure nature of policy implementations, yet
minimizing the amount of "state" that needs to be managed and persisted
by the updater, we now consider download errors in bulks defined by the
most recent update failure (namely, the point in time when all URLs
where tried and failed). The updater is expected to keep track of the
update failure count, setting it to zero when a new update is seen, and
incrementing it (and recording the time it was incremented) when told to
do so by the policy. We therefore make some adjustments to the policy
API and its usage semantics.

BUG=chromium:396148
TEST=Unit tests.

Change-Id: If8787b8c41055779945f9b41368ec08ac5e6fcca
Reviewed-on: https://chromium-review.googlesource.com/210702
Reviewed-by: Alex Vakulenko <avakulenko@chromium.org>
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.h b/update_manager/default_policy.h
index 526476c..f3f663c 100644
--- a/update_manager/default_policy.h
+++ b/update_manager/default_policy.h
@@ -57,30 +57,13 @@
       UpdateCheckParams* result) const override;
 
   EvalStatus UpdateCanStart(
-      EvaluationContext* ec,
-      State* state,
-      std::string* error,
+      EvaluationContext* ec, State* state, std::string* error,
       UpdateDownloadParams* result,
-      const bool interactive,
-      const UpdateState& update_state) const override {
-    result->update_can_start = true;
-    result->p2p_allowed = false;
-    result->download_url_idx = 0;
-    result->download_url_num_failures = 0;
-    result->cannot_start_reason = UpdateCannotStartReason::kUndefined;
-    result->scatter_wait_period = base::TimeDelta();
-    result->scatter_check_threshold = 0;
-    return EvalStatus::kSucceeded;
-  }
+      const UpdateState& update_state) const override;
 
   EvalStatus UpdateDownloadAllowed(
-      EvaluationContext* ec,
-      State* state,
-      std::string* error,
-      bool* result) const override {
-    *result = true;
-    return EvalStatus::kSucceeded;
-  }
+      EvaluationContext* ec, State* state, std::string* error,
+      bool* result) const override;
 
  protected:
   // Policy override.