update_engine: UM: Change policy argument from const ref to value.

It turns out that passing an argument by reference to UpdateCanStart via
UpdateManager::AsyncPolicyRequest is a pain. Furthermore, given that the
policy is async by definition, it makes little sense to hand it a const
reference argument. This changes the said argument to be passed by
value.

BUG=chromium:396148
TEST=Unit tests.

Change-Id: I45a8141b389c173347f3a6b7dc03ffe46cb32228
Reviewed-on: https://chromium-review.googlesource.com/219694
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/chromeos_policy.cc b/update_manager/chromeos_policy.cc
index 9afc00d..a3d6495 100644
--- a/update_manager/chromeos_policy.cc
+++ b/update_manager/chromeos_policy.cc
@@ -267,7 +267,7 @@
     State* state,
     string* error,
     UpdateDownloadParams* result,
-    const UpdateState& update_state) const {
+    const UpdateState update_state) const {
   // Set the default return values. Note that we set persisted values (backoff,
   // scattering) to the same values presented in the update state. The reason is
   // that preemptive returns, such as the case where an update check is due,
diff --git a/update_manager/chromeos_policy.h b/update_manager/chromeos_policy.h
index 8b858a2..17f2c29 100644
--- a/update_manager/chromeos_policy.h
+++ b/update_manager/chromeos_policy.h
@@ -52,7 +52,7 @@
       State* state,
       std::string* error,
       UpdateDownloadParams* result,
-      const UpdateState& update_state) const override;
+      UpdateState update_state) const override;
 
   EvalStatus UpdateDownloadAllowed(
       EvaluationContext* ec,
diff --git a/update_manager/default_policy.cc b/update_manager/default_policy.cc
index 5a07900..13de5bd 100644
--- a/update_manager/default_policy.cc
+++ b/update_manager/default_policy.cc
@@ -46,7 +46,7 @@
     State* state,
     std::string* error,
     UpdateDownloadParams* result,
-    const UpdateState& update_state) const {
+    const UpdateState update_state) const {
   result->update_can_start = true;
   result->cannot_start_reason = UpdateCannotStartReason::kUndefined;
   result->download_url_idx = 0;
diff --git a/update_manager/default_policy.h b/update_manager/default_policy.h
index f3f663c..6c1848f 100644
--- a/update_manager/default_policy.h
+++ b/update_manager/default_policy.h
@@ -59,7 +59,7 @@
   EvalStatus UpdateCanStart(
       EvaluationContext* ec, State* state, std::string* error,
       UpdateDownloadParams* result,
-      const UpdateState& update_state) const override;
+      UpdateState update_state) const override;
 
   EvalStatus UpdateDownloadAllowed(
       EvaluationContext* ec, State* state, std::string* error,
diff --git a/update_manager/mock_policy.h b/update_manager/mock_policy.h
index 4fff97e..af0c9e7 100644
--- a/update_manager/mock_policy.h
+++ b/update_manager/mock_policy.h
@@ -27,9 +27,9 @@
   MOCK_CONST_METHOD5(UpdateCanStart,
                      EvalStatus(EvaluationContext*, State*, std::string*,
                                 UpdateDownloadParams*,
-                                const UpdateState&));
+                                UpdateState));
 
-  MOCK_CONST_METHOD4(UpdateCanStart,
+  MOCK_CONST_METHOD4(UpdateDownloadAllowed,
                      EvalStatus(EvaluationContext*, State*, std::string*,
                                 bool*));
 
diff --git a/update_manager/policy.h b/update_manager/policy.h
index 40586c3..a009c68 100644
--- a/update_manager/policy.h
+++ b/update_manager/policy.h
@@ -219,7 +219,7 @@
       State* state,
       std::string* error,
       UpdateDownloadParams* result,
-      const UpdateState& update_state) const = 0;
+      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