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/omaha_response_handler_action.cc b/omaha_response_handler_action.cc
index 4846a00..fcb312a 100644
--- a/omaha_response_handler_action.cc
+++ b/omaha_response_handler_action.cc
@@ -64,15 +64,17 @@
   install_plan_.download_url = current_url;
   install_plan_.version = response.version;
 
-  OmahaRequestParams* params = system_state_->request_params();
+  OmahaRequestParams* const params = system_state_->request_params();
+  PayloadStateInterface* const payload_state = system_state_->payload_state();
 
   // If we're using p2p to download and there is a local peer, use it.
-  if (params->use_p2p_for_downloading() && !params->p2p_url().empty()) {
+  if (payload_state->GetUsingP2PForDownloading() &&
+      !payload_state->GetP2PUrl().empty()) {
     LOG(INFO) << "Replacing URL " << install_plan_.download_url
-              << " with local URL " << params->p2p_url()
+              << " with local URL " << payload_state->GetP2PUrl()
               << " since p2p is enabled.";
-    install_plan_.download_url = params->p2p_url();
-    system_state_->payload_state()->SetUsingP2PForDownloading(true);
+    install_plan_.download_url = payload_state->GetP2PUrl();
+    payload_state->SetUsingP2PForDownloading(true);
   }
 
   // Fill up the other properties based on the response.
@@ -85,9 +87,9 @@
   install_plan_.is_resume =
       DeltaPerformer::CanResumeUpdate(system_state_->prefs(), response.hash);
   if (install_plan_.is_resume) {
-    system_state_->payload_state()->UpdateResumed();
+    payload_state->UpdateResumed();
   } else {
-    system_state_->payload_state()->UpdateRestarted();
+    payload_state->UpdateRestarted();
     LOG_IF(WARNING, !DeltaPerformer::ResetUpdateProgress(
         system_state_->prefs(), false))
         << "Unable to reset the update progress.";