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/policy_manager/evaluation_context.h b/policy_manager/evaluation_context.h
index 3cbd614..ebbaa0f 100644
--- a/policy_manager/evaluation_context.h
+++ b/policy_manager/evaluation_context.h
@@ -7,6 +7,8 @@
#include <map>
+#include <base/memory/ref_counted.h>
+
#include "update_engine/policy_manager/variable.h"
#include "update_engine/policy_manager/boxed_value.h"
@@ -15,7 +17,7 @@
// The EvaluationContext class is the interface between a policy implementation
// and the state. The EvaluationContext tracks the variables used by a policy
// request and caches the returned values, owning those cached values.
-class EvaluationContext {
+class EvaluationContext : public base::RefCounted<EvaluationContext> {
public:
EvaluationContext() {}