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/payload_state_interface.h b/payload_state_interface.h
index c706e98..1825a40 100644
--- a/payload_state_interface.h
+++ b/payload_state_interface.h
@@ -74,11 +74,14 @@
   virtual void ExpectRebootInNewVersion(
       const std::string& target_version_uid) = 0;
 
-  // Sets whether p2p is being used to download the update payload. This
-  // is used to keep track download sources being used and should be called
+  // Sets whether P2P is being used to download the update payload. This
+  // is used to keep track of download sources being used and should be called
   // before the transfer begins.
   virtual void SetUsingP2PForDownloading(bool value) = 0;
 
+  // Sets whether P2P is being used for sharing the update payloads.
+  virtual void SetUsingP2PForSharing(bool value) = 0;
+
   // Returns true if we should backoff the current download attempt.
   // False otherwise.
   virtual bool ShouldBackoffDownload() = 0;
@@ -161,14 +164,20 @@
   // as when the first attempt was.
   virtual bool P2PAttemptAllowed() = 0;
 
-  // Gets the value previously set with SetUsingP2PForDownloading().
-  virtual bool GetUsingP2PForDownloading() = 0;
+  // Gets the values previously set with SetUsingP2PForDownloading() and
+  // SetUsingP2PForSharing().
+  virtual bool GetUsingP2PForDownloading() const = 0;
+  virtual bool GetUsingP2PForSharing() const = 0;
 
   // Returns the current (persisted) scattering wallclock-based wait period.
   virtual base::TimeDelta GetScatteringWaitPeriod() = 0;
 
   // Sets and persists the scattering wallclock-based wait period.
   virtual void SetScatteringWaitPeriod(base::TimeDelta wait_period) = 0;
+
+  // Sets/gets the P2P download URL, if one is to be used.
+  virtual void SetP2PUrl(const std::string& url) = 0;
+  virtual std::string GetP2PUrl() const = 0;
 };
 
 }  // namespace chromeos_update_engine