Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 1 | // 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 | |
| 10 | namespace chromeos_policy_manager { |
| 11 | |
| 12 | // Provider of random values. |
| 13 | template<typename T, typename R, typename... Args> |
| 14 | EvalStatus 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 Deymo | 2de23f5 | 2014-02-26 14:30:13 -0800 | [diff] [blame^] | 20 | EvalStatus status = (policy_.get()->*policy_method)(&ec, state_.get(), &error, |
| 21 | result, args...); |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 22 | |
| 23 | if (status == EvalStatusFailed) { |
| 24 | LOG(WARNING) << "PolicyRequest() failed with error: " << error; |
| 25 | error.clear(); |
Alex Deymo | 2de23f5 | 2014-02-26 14:30:13 -0800 | [diff] [blame^] | 26 | status = (default_policy_.*policy_method)(&ec, state_.get(), &error, |
| 27 | result, args...); |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 28 | |
| 29 | if (status == EvalStatusFailed) { |
| 30 | 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 |