blob: 798860fbbf4c400cd4834779d3853ca4ee38dfaa [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.
Alex Deymo2de23f52014-02-26 14:30:13 -080020 EvalStatus status = (policy_.get()->*policy_method)(&ec, state_.get(), &error,
21 result, args...);
Alex Deymoc705cc82014-02-19 11:15:00 -080022
Alex Deymoe636c3c2014-03-11 19:02:08 -070023 if (status == EvalStatus::kFailed) {
Alex Deymoc705cc82014-02-19 11:15:00 -080024 LOG(WARNING) << "PolicyRequest() failed with error: " << error;
25 error.clear();
Alex Deymo2de23f52014-02-26 14:30:13 -080026 status = (default_policy_.*policy_method)(&ec, state_.get(), &error,
27 result, args...);
Alex Deymoc705cc82014-02-19 11:15:00 -080028
Alex Deymoe636c3c2014-03-11 19:02:08 -070029 if (status == EvalStatus::kFailed) {
Alex Deymoc705cc82014-02-19 11:15:00 -080030 LOG(WARNING) << "Request to DefaultPolicy also failed, passing error.";
31 }
32 }
33 // TODO(deymo): Log the actual state used from the EvaluationContext.
34 return status;
35}
36
37} // namespace chromeos_policy_manager
38
39#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_MANAGER_INL_H