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/fake_state.cc b/policy_manager/fake_state.cc
index 0f0b5f1..2af8de0 100644
--- a/policy_manager/fake_state.cc
+++ b/policy_manager/fake_state.cc
@@ -8,7 +8,8 @@
namespace chromeos_policy_manager {
-FakeState::FakeState() : State(new FakeRandomProvider(),
+FakeState::FakeState() : State(new FakeDevicePolicyProvider(),
+ new FakeRandomProvider(),
new FakeShillProvider(),
new FakeSystemProvider(),
new FakeTimeProvider(),
@@ -17,7 +18,8 @@
FakeState* FakeState::Construct() {
scoped_ptr<FakeState> fake_state(new FakeState());
- if (!(fake_state->random_provider()->Init() &&
+ if (!(fake_state->device_policy_provider()->Init() &&
+ fake_state->random_provider()->Init() &&
fake_state->shill_provider()->Init() &&
fake_state->system_provider()->Init() &&
fake_state->time_provider()->Init() &&