update_engine: Move P2P enabled pref handling into P2PManager.

This makes the P2PManager own the manipulation of the P2P enabled
setting, which positions us better toward moving the decision about
whether P2P is enabled from P2PManager and into the UpdateManager. Also
increases encapsulation and makes it a bit more resilient.

BUG=chromium:425233
TEST=Unit tests.

Change-Id: Ic91872df84920ae80c5ef973aee99cc46cac264c
Reviewed-on: https://chromium-review.googlesource.com/225681
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Gaurav Shah <gauravsh@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/fake_p2p_manager.h b/fake_p2p_manager.h
index a00b91f..9ec0812 100644
--- a/fake_p2p_manager.h
+++ b/fake_p2p_manager.h
@@ -19,7 +19,8 @@
     ensure_p2p_running_result_(false),
     ensure_p2p_not_running_result_(false),
     perform_housekeeping_result_(false),
-    count_shared_files_result_(0) {}
+    count_shared_files_result_(0),
+    set_p2p_enabled_pref_result_(true) {}
 
   virtual ~FakeP2PManager() {}
 
@@ -79,6 +80,10 @@
     return count_shared_files_result_;
   }
 
+  bool SetP2PEnabledPref(bool /* enabled */) override {
+    return set_p2p_enabled_pref_result_;
+  }
+
   // Methods for controlling what the fake returns and how it acts.
   void SetP2PEnabled(bool is_p2p_enabled) {
     is_p2p_enabled_ = is_p2p_enabled;
@@ -100,6 +105,10 @@
     count_shared_files_result_ = count_shared_files_result;
   }
 
+  void SetSetP2PEnabledPrefResult(bool set_p2p_enabled_pref_result) {
+    set_p2p_enabled_pref_result_ = set_p2p_enabled_pref_result;
+  }
+
   void SetLookupUrlForFileResult(const std::string& url) {
     lookup_url_for_file_result_ = url;
   }
@@ -110,6 +119,7 @@
   bool ensure_p2p_not_running_result_;
   bool perform_housekeeping_result_;
   int count_shared_files_result_;
+  bool set_p2p_enabled_pref_result_;
   std::string lookup_url_for_file_result_;
 
   DISALLOW_COPY_AND_ASSIGN(FakeP2PManager);