update_engine: Policy determines P2P enabled status. This switches the P2P Manager to use the newly introduced Update Manger policy requests in determining whether P2P is enabled on the system. There is a policy request for the initial state (P2PEnabled, sync) and for tracking changes (P2PEnabledChanged, async), with the latest known value being cached by the P2P Manager. This also reverses a recent change that moved P2P prefs setting into the P2PManager. In the absence of any additional logic (now cleared) there was no point in having a dedicated method just for that, and so dbus_service writes the prefs value directly. This affords us removing the prefs argument when initializing the P2PManager. BUG=chromium:425233 TEST=Unit tests. Change-Id: I53280f05da8fe532b6502c175a8cc9ddc1e15a87 Reviewed-on: https://chromium-review.googlesource.com/226937 Tested-by: Gilad Arnold <[email protected]> Reviewed-by: David Zeuthen <[email protected]> Commit-Queue: Gilad Arnold <[email protected]>
diff --git a/p2p_manager.h b/p2p_manager.h index 4c6e508..fb07c2e 100644 --- a/p2p_manager.h +++ b/p2p_manager.h
@@ -17,6 +17,7 @@ #include "update_engine/clock_interface.h" #include "update_engine/prefs_interface.h" +#include "update_engine/update_manager/update_manager.h" namespace chromeos_update_engine { @@ -53,9 +54,8 @@ // null, then no device policy is used. virtual void SetDevicePolicy(const policy::DevicePolicy* device_policy) = 0; - // Returns true if - and only if - P2P should be used on this - // device. This value is derived from a variety of sources including - // enterprise policy. + // Returns true iff P2P is currently allowed for use on this device. This + // value is determined and maintained by the Update Manager. virtual bool IsP2PEnabled() = 0; // Ensures that the p2p subsystem is running (e.g. starts it if it's @@ -150,12 +150,6 @@ // occurred. virtual int CountSharedFiles() = 0; - // Updates the preference setting for enabling P2P. If P2P is disabled as a - // result, attempts to ensure that the service is not running. Returns true if - // the setting was updated successfully (even through stopping the service may - // have failed). - virtual bool SetP2PEnabledPref(bool enabled) = 0; - // Creates a suitable P2PManager instance and initializes the object // so it's ready for use. The |file_extension| parameter is used to // identify your application, use e.g. "cros_au". If @@ -168,12 +162,13 @@ // method) - pass zero to allow infinitely many files. The // |max_file_age| parameter specifies the maximum file age after // performing housekeeping (pass zero to allow files of any age). - static P2PManager* Construct(Configuration *configuration, - PrefsInterface *prefs, - ClockInterface *clock, - const std::string& file_extension, - const int num_files_to_keep, - const base::TimeDelta& max_file_age); + static P2PManager* Construct( + Configuration *configuration, + ClockInterface *clock, + chromeos_update_manager::UpdateManager* update_manager, + const std::string& file_extension, + const int num_files_to_keep, + const base::TimeDelta& max_file_age); }; } // namespace chromeos_update_engine