p2p: Add accounting for p2p usage to PayloadStateInterface

This machinery is needed in order to stop using p2p if the device has
failed to update itself using p2p in a timely manner.

BUG=chromium:260426
TEST=New unit tests + unit tests pass
Change-Id: I9f33309368f8cd5399b9d67c9072a1f78385abc0
Reviewed-on: https://chromium-review.googlesource.com/64827
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
diff --git a/constants.h b/constants.h
index 66c12e7..ce80389 100644
--- a/constants.h
+++ b/constants.h
@@ -65,6 +65,8 @@
 extern const char kPrefsUpdateTimestampStart[];
 extern const char kPrefsUrlSwitchCount[];
 extern const char kPrefsWallClockWaitPeriod[];
+extern const char kPrefsP2PNumAttempts[];
+extern const char kPrefsP2PFirstAttemptTimestamp[];
 
 // A download source is any combination of protocol and server (that's of
 // interest to us when looking at UMA metrics) using which we may download
@@ -90,6 +92,13 @@
   kNumPayloadTypes
 } PayloadType;
 
+// Maximum number of attempts using p2p.
+const int kMaxP2PAttempts = 10;
+
+// Maximum wallclock time we allow attempting to update using p2p -
+// two days.
+const int kMaxP2PAttemptTimeSeconds = 2*24*60*60;
+
 // The default number of UMA buckets for metrics.
 const int kNumDefaultUmaBuckets = 50;