PolicyManager: New DevicePolicy provider.

This provider gives access to the members of the DevicePolicy
protobuf using the libpolicy to access it. The libpolicy doesn't
provide a way to get a notification when the policy was updated, but
that could be fixed on the future monitoring the file on disk. This
patch attempts to refresh the device policy every hour and updates
all the variables accordingly.

The variables exposed by this provider are only those used by the
update_engine code currently. If new variables need to be exposed
this can easily extended.

To achieve this, a new generic Variable class is introduce, named
AsyncCopyVariable, that allows you to Set or Unset the current value
of the variable and notify the subscribed observers while doing that.

BUG=chromium:358326
TEST=Unit tests added and pass.

Change-Id: Ieee6c9b33160f7dfe40c033db685a79d8fd57fe7
Reviewed-on: https://chromium-review.googlesource.com/194179
Reviewed-by: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/policy_manager/state_factory.cc b/policy_manager/state_factory.cc
index a5f0df9..b5bfb7f 100644
--- a/policy_manager/state_factory.cc
+++ b/policy_manager/state_factory.cc
@@ -7,6 +7,7 @@
 #include <base/logging.h>
 
 #include "update_engine/clock_interface.h"
+#include "update_engine/policy_manager/real_device_policy_provider.h"
 #include "update_engine/policy_manager/real_random_provider.h"
 #include "update_engine/policy_manager/real_shill_provider.h"
 #include "update_engine/policy_manager/real_system_provider.h"
@@ -15,9 +16,12 @@
 
 namespace chromeos_policy_manager {
 
-State* DefaultStateFactory(chromeos_update_engine::DBusWrapperInterface* dbus,
+State* DefaultStateFactory(policy::PolicyProvider* policy_provider,
+                           chromeos_update_engine::DBusWrapperInterface* dbus,
                            chromeos_update_engine::SystemState* system_state) {
   chromeos_update_engine::ClockInterface* const clock = system_state->clock();
+  scoped_ptr<RealDevicePolicyProvider> device_policy_provider(
+      new RealDevicePolicyProvider(policy_provider));
   scoped_ptr<RealRandomProvider> random_provider(new RealRandomProvider());
   scoped_ptr<RealShillProvider> shill_provider(
       new RealShillProvider(dbus, clock));
@@ -26,7 +30,8 @@
   scoped_ptr<RealUpdaterProvider> updater_provider(
       new RealUpdaterProvider(system_state));
 
-  if (!(random_provider->Init() &&
+  if (!(device_policy_provider->Init() &&
+        random_provider->Init() &&
         shill_provider->Init() &&
         system_provider->Init() &&
         time_provider->Init() &&
@@ -35,7 +40,8 @@
     return NULL;
   }
 
-  return new State(random_provider.release(),
+  return new State(device_policy_provider.release(),
+                   random_provider.release(),
                    shill_provider.release(),
                    system_provider.release(),
                    time_provider.release(),