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 <garnold@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
diff --git a/test_utils.h b/test_utils.h
index 0ca4639..43ff339 100644
--- a/test_utils.h
+++ b/test_utils.h
@@ -13,6 +13,7 @@
 #include <string>
 #include <vector>
 
+#include <base/callback.h>
 #include <base/memory/scoped_ptr.h>
 #include <glib-object.h>
 #include <gtest/gtest.h>
@@ -274,6 +275,12 @@
   scoped_ptr<ScopedFilesystemUnmounter> unmounter_;
 };
 
+// Runs the default GLib main loop for at most |timeout_msec| or until the
+// function |terminate| returns true, whichever happens first. The function
+// |terminate| is called before every GLib main loop iteration and its value is
+// checked.
+void RunGMainLoopUntil(int timeout_msec, base::Callback<bool()> terminate);
+
 // Runs the default GLib main loop at most |iterations| times. This
 // dispatches all the events that are already waiting in the main loop and
 // those that get scheduled as a result of these events being attended.