p2p: Use p2p for updates
This is the main patch for enabling use of p2p for consuming and/or
sharing updates via p2p. Refer to the ddoc and other documentation for
how this works.
BUG=chromium:260426,chromium:273110
TEST=New unit tests + unit tests pass + manual testing
Change-Id: I6bc3bddae1e041ccc176969a651396e8e89cb3f0
Reviewed-on: https://chromium-review.googlesource.com/64829
Reviewed-by: David Zeuthen <[email protected]>
Commit-Queue: David Zeuthen <[email protected]>
Tested-by: David Zeuthen <[email protected]>
diff --git a/utils.cc b/utils.cc
index 8b4bffe..8f04134 100644
--- a/utils.cc
+++ b/utils.cc
@@ -1026,6 +1026,11 @@
return true;
}
+bool IsP2PAllowedForInteractiveChecks() {
+ struct stat statbuf;
+ return stat(kP2PAllowInteractiveMarkerFile, &statbuf) == 0;
+}
+
Time TimeFromStructTimespec(struct timespec *ts) {
int64 us = static_cast<int64>(ts->tv_sec) * Time::kMicrosecondsPerSecond +
static_cast<int64>(ts->tv_nsec) / Time::kNanosecondsPerMicrosecond;
@@ -1056,6 +1061,16 @@
return str;
}
+string CalculateP2PFileId(const string& payload_hash, size_t payload_size) {
+ string encoded_hash;
+ OmahaHashCalculator::Base64Encode(payload_hash.c_str(),
+ payload_hash.size(),
+ &encoded_hash);
+ return StringPrintf("cros_update_size_%zu_hash_%s",
+ payload_size,
+ encoded_hash.c_str());
+}
+
} // namespace utils
} // namespace chromeos_update_engine