PolicyManager: Specify the full Policy method type on the PM interface.

This patch replaces the template parameter "typename T" used to pass
the policy_method with its actual type, which can be inferred from
the remaining types, removing this template parameter.

This makes the C++ error messages more meaningful when the wrong
parameters are passed to a policy request.

BUG=None
TEST=Build. Manual test passing the wrong type for "result" and getting a meaningful error message.

Change-Id: I98cda8782a0db8642f1e6636af286a97a2df56a3
Reviewed-on: https://chromium-review.googlesource.com/193675
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
diff --git a/policy_manager/policy_manager-inl.h b/policy_manager/policy_manager-inl.h
index f0d4937..f19df55 100644
--- a/policy_manager/policy_manager-inl.h
+++ b/policy_manager/policy_manager-inl.h
@@ -14,10 +14,15 @@
 
 namespace chromeos_policy_manager {
 
-template<typename T, typename R, typename... Args>
-EvalStatus PolicyManager::EvaluatePolicy(EvaluationContext* ec,
-                                         T policy_method, R* result,
-                                         Args... args) {
+template<typename R, typename... Args>
+EvalStatus PolicyManager::EvaluatePolicy(
+    EvaluationContext* ec,
+    EvalStatus (Policy::*policy_method)(EvaluationContext* ec,
+                                        State* state,
+                                        std::string* error,
+                                        R* result,
+                                        Args... args) const,
+    R* result, Args... args) {
   std::string error;
 
   // First try calling the actual policy.
@@ -38,11 +43,16 @@
   return status;
 }
 
-template<typename T, typename R, typename... Args>
+template<typename R, typename... Args>
 void PolicyManager::OnPolicyReadyToEvaluate(
     scoped_refptr<EvaluationContext> ec,
     base::Callback<void(EvalStatus status, const R& result)> callback,
-    T policy_method, Args... args) {
+    EvalStatus (Policy::*policy_method)(EvaluationContext* ec,
+                                        State* state,
+                                        std::string* error,
+                                        R* result,
+                                        Args... args) const,
+    Args... args) {
   R result;
   EvalStatus status = EvaluatePolicy(ec, policy_method, &result, args...);
 
@@ -53,7 +63,7 @@
   }
   // Re-schedule the policy request based on used variables.
   base::Closure closure = base::Bind(
-      &PolicyManager::OnPolicyReadyToEvaluate<T, R, Args...>,
+      &PolicyManager::OnPolicyReadyToEvaluate<R, Args...>,
       base::Unretained(this), ec, callback, policy_method, args...);
 
   if (!ec->RunOnValueChangeOrTimeout(closure)) {
@@ -67,23 +77,32 @@
   }
 }
 
-template<typename T, typename R, typename... Args>
-EvalStatus PolicyManager::PolicyRequest(T policy_method, R* result,
-                                        Args... args) {
+template<typename R, typename... Args>
+EvalStatus PolicyManager::PolicyRequest(
+    EvalStatus (Policy::*policy_method)(EvaluationContext* ec,
+                                        State* state,
+                                        std::string* error,
+                                        R* result,
+                                        Args... args) const,
+    R* result, Args... args) {
   scoped_refptr<EvaluationContext> ec(new EvaluationContext);
   // A PolicyRequest allways consists on a single evaluation on a new
   // EvaluationContext.
   return EvaluatePolicy(ec, policy_method, result, args...);
 }
 
-template<typename T, typename R, typename... Args>
+template<typename R, typename... Args>
 void PolicyManager::AsyncPolicyRequest(
     base::Callback<void(EvalStatus, const R& result)> callback,
-    T policy_method, Args... args) {
-
+    EvalStatus (Policy::*policy_method)(EvaluationContext* ec,
+                                        State* state,
+                                        std::string* error,
+                                        R* result,
+                                        Args... args) const,
+    Args... args) {
   scoped_refptr<EvaluationContext> ec = new EvaluationContext;
   base::Closure closure = base::Bind(
-      &PolicyManager::OnPolicyReadyToEvaluate<T, R, Args...>,
+      &PolicyManager::OnPolicyReadyToEvaluate<R, Args...>,
       base::Unretained(this), ec, callback, policy_method, args...);
   RunFromMainLoop(closure);
 }