PolicyManager: Schedule re-evaluations based on variable usage.

This patch makes the EvaluationContext re-schedule a policy request
based on the variables used by that method, waiting for the Async
variables and polling the Poll variables on the suggested interval.

In order to use the main loop functions from the EvaluationContext
they were moved to its own file called event_loop.h.

BUG=chromium:340871
TEST=Unit tests added.

Change-Id: Ibfc52e4dfd12c5e1ef87b5ad9cc318f9821dcfdd
Reviewed-on: https://chromium-review.googlesource.com/190424
Reviewed-by: Gilad Arnold <[email protected]>
Commit-Queue: Alex Deymo <[email protected]>
Tested-by: Alex Deymo <[email protected]>
diff --git a/policy_manager/fake_variable.h b/policy_manager/fake_variable.h
index bd113a3..36c3848 100644
--- a/policy_manager/fake_variable.h
+++ b/policy_manager/fake_variable.h
@@ -5,6 +5,8 @@
 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_FAKE_VARIABLE_H_
 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_FAKE_VARIABLE_H_
 
+#include <string>
+
 #include <base/memory/scoped_ptr.h>
 
 #include "update_engine/policy_manager/variable.h"
@@ -16,8 +18,10 @@
 template<typename T>
 class FakeVariable : public Variable<T> {
  public:
-  explicit FakeVariable(const std::string& name, VariableMode mode)
+  FakeVariable(const std::string& name, VariableMode mode)
       : Variable<T>(name, mode) {}
+  FakeVariable(const std::string& name, base::TimeDelta poll_interval)
+      : Variable<T>(name, poll_interval) {}
   virtual ~FakeVariable() {}
 
   // Sets the next value of this variable to the passed |p_value| pointer. Once
@@ -27,6 +31,11 @@
     ptr_.reset(p_value);
   }
 
+  // Make the NotifyValueChanged() public for FakeVariables.
+  void NotifyValueChanged() {
+    Variable<T>::NotifyValueChanged();
+  }
+
  protected:
   // Variable<T> overrides.
   // Returns the pointer set with reset(). The ownership of the object is passed