blob: 6c99be232445ac5220683e2fe2cc6d67a1081ce6 [file] [log] [blame]
Alex Deymoc705cc82014-02-19 11:15:00 -08001// Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_MANAGER_INL_H
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_MANAGER_INL_H
7
8#include "update_engine/policy_manager/evaluation_context.h"
9
10namespace chromeos_policy_manager {
11
12// Provider of random values.
13template<typename T, typename R, typename... Args>
14EvalStatus PolicyManager::PolicyRequest(T policy_method, R* result,
15 Args... args) {
16 EvaluationContext ec;
17 std::string error;
18
19 // First try calling the actual policy.
20 EvalStatus status = (policy_.get()->*policy_method)(&ec, &error, result,
21 args...);
22
23 if (status == EvalStatusFailed) {
24 LOG(WARNING) << "PolicyRequest() failed with error: " << error;
25 error.clear();
26 status = (default_policy_.*policy_method)(&ec, &error, result, args...);
27
28 if (status == EvalStatusFailed) {
29 LOG(WARNING) << "Request to DefaultPolicy also failed, passing error.";
30 }
31 }
32 // TODO(deymo): Log the actual state used from the EvaluationContext.
33 return status;
34}
35
36} // namespace chromeos_policy_manager
37
38#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_MANAGER_INL_H