Refactor daemon state and service async notification.

There are three supported IPC mechanism in this code: DBus, binder and
weave (over binder); which are mostly supported by all three platforms
Chrome OS, Brillo and Android. The exceptions are that Brillo and
Chrome OS still *require* DBus and support the others, while the new
Android daemon requires and supports only Binder.

This CL introduces two new interfaces: the ServiceObserverInterface and
the DaemonStateInterface.

The first one abstracts a service (or IPC service) into an interfcae
from the point of view of the daemon initialization and async
notifications of status changes. The second interface encapsulates the
state and main functionality of the update_engine daemon while leaving
the shared initialization in the main.cc and daemon.cc classes.

Bug: 25631949
TEST=`mmma system/update_engine` on edison-eng and aosp_arm-eng
TEST=FEATURES=test emerge-link update_engine

Change-Id: Ic15621031a153e14bdc4df8fcedbca1032e82c21
diff --git a/daemon.h b/daemon.h
index 32437cb..8323e56 100644
--- a/daemon.h
+++ b/daemon.h
@@ -30,18 +30,16 @@
 
 #if USE_BINDER
 #if defined(__BRILLO__) || defined(__CHROMEOS__)
-#include "update_engine/binder_service.h"
+#include "update_engine/binder_service_brillo.h"
 #else  // !(defined(__BRILLO__) || defined(__CHROMEOS__))
 #include "update_engine/binder_service_android.h"
 #endif  // defined(__BRILLO__) || defined(__CHROMEOS__)
 #endif  // USE_BINDER
 #include "update_engine/common/subprocess.h"
+#include "update_engine/daemon_state_interface.h"
 #if USE_DBUS
 #include "update_engine/dbus_service.h"
 #endif  // USE_DBUS
-#if defined(__BRILLO__) || defined(__CHROMEOS__)
-#include "update_engine/real_system_state.h"
-#endif  // defined(__BRILLO__) || defined(__CHROMEOS__)
 
 namespace chromeos_update_engine {
 
@@ -75,18 +73,15 @@
 
 #if USE_BINDER
 #if defined(__BRILLO__) || defined(__CHROMEOS__)
-  android::sp<BinderUpdateEngineService> service_;
+  android::sp<BinderUpdateEngineBrilloService> binder_service_;
 #else  // !(defined(__BRILLO__) || defined(__CHROMEOS__))
-  android::sp<BinderUpdateEngineAndroidService> service_;
+  android::sp<BinderUpdateEngineAndroidService> binder_service_;
 #endif  // defined(__BRILLO__) || defined(__CHROMEOS__)
 #endif  // USE_BINDER
 
-#if defined(__BRILLO__) || defined(__CHROMEOS__)
-  // The RealSystemState uses the previous classes so it should be defined last.
-  std::unique_ptr<RealSystemState> real_system_state_;
-#else  // !(defined(__BRILLO__) || defined(__CHROMEOS__))
-  //TODO(deymo): Define non-Brillo state.
-#endif  // defined(__BRILLO__) || defined(__CHROMEOS__)
+  // The daemon state with all the required daemon classes for the configured
+  // platform.
+  std::unique_ptr<DaemonStateInterface> daemon_state_;
 
   DISALLOW_COPY_AND_ASSIGN(UpdateEngineDaemon);
 };