update_engine: Relocate inference and storage of P2P related properties.

This change moves the inference of P2P related properties from
OmahaRequestAction to OmahaResponseHandlerAction, and their storage from
OmahaRequestParams to PayloadState. This is needed in order for the
UpdateCanStart policy to be able to decide P2P properties, which only
happens after the Omaha response is received and processed, and prior to
applying the update.  Further, P2P properties do not affect the Omaha
request, and so there's no reason for them to reside in
OmahaRequestParams nor decided as early as OmahaRequestAction.

Additional cleanup includes swapping expected/actual arguments to EXPECT
macros where appropriate, and removing redundant .Times(1) expectation
qualifiers.

BUG=chromium:384087
TEST=Unit tests.

Change-Id: I6d5b4b44745d5dab7e350bdf019dbf804bf196a1
Reviewed-on: https://chromium-review.googlesource.com/223618
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
Tested-by: Gilad Arnold <garnold@chromium.org>
diff --git a/update_attempter.cc b/update_attempter.cc
index 2911540..200493d 100644
--- a/update_attempter.cc
+++ b/update_attempter.cc
@@ -352,8 +352,9 @@
     }
   }
 
-  omaha_request_params_->set_use_p2p_for_downloading(use_p2p_for_downloading);
-  omaha_request_params_->set_use_p2p_for_sharing(use_p2p_for_sharing);
+  PayloadStateInterface* const payload_state = system_state_->payload_state();
+  payload_state->SetUsingP2PForDownloading(use_p2p_for_downloading);
+  payload_state->SetUsingP2PForSharing(use_p2p_for_sharing);
 }
 
 bool UpdateAttempter::CalculateUpdateParams(const string& app_version,
@@ -363,6 +364,7 @@
                                             bool obey_proxies,
                                             bool interactive) {
   http_response_code_ = 0;
+  PayloadStateInterface* const payload_state = system_state_->payload_state();
 
   // Refresh the policy before computing all the update parameters.
   RefreshDevicePolicy();
@@ -374,15 +376,15 @@
   CalculateScatteringParams(interactive);
 
   CalculateP2PParams(interactive);
-  if (omaha_request_params_->use_p2p_for_downloading() ||
-      omaha_request_params_->use_p2p_for_sharing()) {
+  if (payload_state->GetUsingP2PForDownloading() ||
+      payload_state->GetUsingP2PForSharing()) {
     // OK, p2p is to be used - start it and perform housekeeping.
     if (!StartP2PAndPerformHousekeeping()) {
       // If this fails, disable p2p for this attempt
       LOG(INFO) << "Forcibly disabling use of p2p since starting p2p or "
                 << "performing housekeeping failed.";
-      omaha_request_params_->set_use_p2p_for_downloading(false);
-      omaha_request_params_->set_use_p2p_for_sharing(false);
+      payload_state->SetUsingP2PForDownloading(false);
+      payload_state->SetUsingP2PForSharing(false);
     }
   }
 
@@ -423,9 +425,9 @@
                omaha_request_params_->waiting_period().InSeconds());
 
   LOG(INFO) << "Use p2p For Downloading = "
-            << omaha_request_params_->use_p2p_for_downloading()
+            << payload_state->GetUsingP2PForDownloading()
             << ", Use p2p For Sharing = "
-            << omaha_request_params_->use_p2p_for_sharing();
+            << payload_state->GetUsingP2PForSharing();
 
   obeying_proxies_ = true;
   if (obey_proxies || proxy_manual_checks_ == 0) {