update_manager: Make Prefs Variable async.

The update_engine prefs, while stored in disk, are private daemon
values changed by the daemon only. There was a 5 minutes delay between
changing this value and the update policy checking it again, and there
was a log spam every 5 minutes due to policy re-evaluations.

This patch makes these Prefs-based variables async by implementing an
observer pattern in the PrefsInterface and makes these variables async.

Bug: chromium:367333
Test: Added uniittest. No more log spam every 5 minutes.

Change-Id: I8b3f7072cc87515972c9f5b1ddcc54b865ffe238
diff --git a/mock_prefs.h b/mock_prefs.h
index fafe39a..d1a97e8 100644
--- a/mock_prefs.h
+++ b/mock_prefs.h
@@ -28,17 +28,22 @@
 
 class MockPrefs : public PrefsInterface {
  public:
-  MOCK_METHOD2(GetString, bool(const std::string& key, std::string* value));
+  MOCK_CONST_METHOD2(GetString,
+                     bool(const std::string& key, std::string* value));
   MOCK_METHOD2(SetString, bool(const std::string& key,
                                const std::string& value));
-  MOCK_METHOD2(GetInt64, bool(const std::string& key, int64_t* value));
+  MOCK_CONST_METHOD2(GetInt64, bool(const std::string& key, int64_t* value));
   MOCK_METHOD2(SetInt64, bool(const std::string& key, const int64_t value));
 
-  MOCK_METHOD2(GetBoolean, bool(const std::string& key, bool* value));
+  MOCK_CONST_METHOD2(GetBoolean, bool(const std::string& key, bool* value));
   MOCK_METHOD2(SetBoolean, bool(const std::string& key, const bool value));
 
-  MOCK_METHOD1(Exists, bool(const std::string& key));
+  MOCK_CONST_METHOD1(Exists, bool(const std::string& key));
   MOCK_METHOD1(Delete, bool(const std::string& key));
+
+  MOCK_METHOD2(AddObserver, void(const std::string& key, ObserverInterface*));
+  MOCK_METHOD2(RemoveObserver,
+               void(const std::string& key, ObserverInterface*));
 };
 
 }  // namespace chromeos_update_engine