PolicyManager: Initial support of async PolicyRequests.
This patch adds the new method PolicyManager::AsyncPolicyRequest
that takes a callback to be called once the policy request finishes.
If the given policy request returns kAskMeAgainLater, its evaluation
will be re-scheduled until it returns a given value. On this initial
patch, the evaluation is re-scheduled to happen after a fixed amount
of time instead of using the information collected on the
EvaluationContext.
BUG=chromium:340871
TEST=Unittest added.
Change-Id: If0e2888f26c379b806d811d52c4c3d4a8a6d8efb
Reviewed-on: https://chromium-review.googlesource.com/189636
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/test_utils.cc b/test_utils.cc
index e73146c..e46b399 100644
--- a/test_utils.cc
+++ b/test_utils.cc
@@ -310,4 +310,13 @@
unmounter_.reset(new ScopedFilesystemUnmounter(*mnt_path));
}
+int RunGMainLoopMaxIterations(int iterations) {
+ int result;
+ GMainContext* context = g_main_context_default();
+ for (result = 0;
+ result < iterations && g_main_context_iteration(context, FALSE);
+ result++) {}
+ return result;
+}
+
} // namespace chromeos_update_engine