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/policy_manager.h b/policy_manager/policy_manager.h
index 33bb89c..4e4cc68 100644
--- a/policy_manager/policy_manager.h
+++ b/policy_manager/policy_manager.h
@@ -5,8 +5,6 @@
#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_MANAGER_H_
#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_MANAGER_H_
-#include <glib.h>
-
#include <base/callback.h>
#include <base/memory/ref_counted.h>
#include <base/memory/scoped_ptr.h>
@@ -51,7 +49,9 @@
//
// If the policy implementation should block, returning a
// EvalStatus::kAskMeAgainLater status the policy manager will re-evaluate the
- // policy until another status is returned.
+ // policy until another status is returned. If the policy implementation based
+ // its return value solely on const variables, the callback will be called
+ // with the EvalStatus::kAskMeAgainLater status.
template<typename T, typename R, typename... Args>
void AsyncPolicyRequest(
base::Callback<void(EvalStatus, const R& result)> callback,
@@ -64,18 +64,6 @@
FRIEND_TEST(PmPolicyManagerTest, PolicyRequestDoesntBlock);
FRIEND_TEST(PmPolicyManagerTest, AsyncPolicyRequestDelaysEvaluation);
- // Schedules the passed |callback| to run from the GLib's main loop after a
- // timeout if it is given.
- static void RunFromMainLoop(const base::Closure& callback);
- static void RunFromMainLoopAfterTimeout(const base::Closure& callback,
- base::TimeDelta timeout);
-
- // Called by the GLib's main loop when is time to call the callback scheduled
- // with RunFromMainLopp() and similar functions. The pointer to the callback
- // passed when scheduling it is passed to this functions as a gpointer on
- // |user_data|.
- static gboolean OnRanFromMainLoop(gpointer user_data);
-
// EvaluatePolicy() evaluates the passed |policy_method| method on the current
// policy with the given |args| arguments. If the method fails, the default
// policy is used instead.