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 <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
diff --git a/omaha_request_params.h b/omaha_request_params.h
index 19a1900..f644775 100644
--- a/omaha_request_params.h
+++ b/omaha_request_params.h
@@ -44,7 +44,9 @@
max_update_checks_allowed_(kDefaultMaxUpdateChecks),
is_powerwash_allowed_(false),
force_lock_down_(false),
- forced_lock_down_(false) {
+ forced_lock_down_(false),
+ use_p2p_for_downloading_(false),
+ use_p2p_for_sharing_(false) {
InitFromLsbValue();
}
@@ -64,7 +66,9 @@
bool in_interactive,
const std::string& in_update_url,
bool in_update_disabled,
- const std::string& in_target_version_prefix)
+ const std::string& in_target_version_prefix,
+ bool in_use_p2p_for_downloading,
+ bool in_use_p2p_for_sharing)
: system_state_(system_state),
os_platform_(in_os_platform),
os_version_(in_os_version),
@@ -90,7 +94,9 @@
max_update_checks_allowed_(kDefaultMaxUpdateChecks),
is_powerwash_allowed_(false),
force_lock_down_(false),
- forced_lock_down_(false) {}
+ forced_lock_down_(false),
+ use_p2p_for_downloading_(in_use_p2p_for_downloading),
+ use_p2p_for_sharing_(in_use_p2p_for_sharing) {}
// Setters and getters for the various properties.
inline std::string os_platform() const { return os_platform_; }
@@ -171,6 +177,27 @@
return max_update_checks_allowed_;
}
+ inline void set_use_p2p_for_downloading(bool value) {
+ use_p2p_for_downloading_ = value;
+ }
+ inline bool use_p2p_for_downloading() const {
+ return use_p2p_for_downloading_;
+ }
+
+ inline void set_use_p2p_for_sharing(bool value) {
+ use_p2p_for_sharing_ = value;
+ }
+ inline bool use_p2p_for_sharing() const {
+ return use_p2p_for_sharing_;
+ }
+
+ inline void set_p2p_url(const std::string& value) {
+ p2p_url_ = value;
+ }
+ inline std::string p2p_url() const {
+ return p2p_url_;
+ }
+
// True if we're trying to update to a more stable channel.
// i.e. index(target_channel) > index(current_channel).
bool to_more_stable_channel() const;
@@ -354,6 +381,18 @@
bool force_lock_down_;
bool forced_lock_down_;
+ // True if we may use p2p to download. This is based on owner
+ // preferences and policy.
+ bool use_p2p_for_downloading_;
+
+ // True if we may use p2p to share. This is based on owner
+ // preferences and policy.
+ bool use_p2p_for_sharing_;
+
+ // An URL to a local peer serving the requested payload or "" if no
+ // such peer is available.
+ std::string p2p_url_;
+
// TODO(jaysri): Uncomment this after fixing unit tests, as part of
// chromium-os:39752
// DISALLOW_COPY_AND_ASSIGN(OmahaRequestParams);