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_H |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_H |
| 7 | |
| 8 | #include "update_engine/policy_manager/evaluation_context.h" |
Alex Deymo | 2de23f5 | 2014-02-26 14:30:13 -0800 | [diff] [blame] | 9 | #include "update_engine/policy_manager/state.h" |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 10 | |
| 11 | namespace chromeos_policy_manager { |
| 12 | |
| 13 | // The three different results of a policy request. |
| 14 | enum EvalStatus { |
| 15 | EvalStatusFailed, |
| 16 | EvalStatusSucceeded, |
| 17 | EvalStatusAskMeAgainLater, |
| 18 | }; |
| 19 | |
| 20 | // The Policy class is an interface to the ensemble of policy requests that the |
| 21 | // client can make. A derived class includes the policy implementations of |
| 22 | // these. |
| 23 | // |
| 24 | // When compile-time selection of the policy is required due to missing or extra |
| 25 | // parts in a given platform, a different Policy subclass can be used. |
| 26 | class Policy { |
| 27 | public: |
| 28 | virtual ~Policy() {} |
| 29 | |
| 30 | // List of policy requests. A policy request takes an EvaluationContext as the |
Alex Deymo | 2de23f5 | 2014-02-26 14:30:13 -0800 | [diff] [blame] | 31 | // first argument, a State instance, a returned error message, a returned |
| 32 | // value and optionally followed by one or more arbitrary constant arguments. |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 33 | // |
| 34 | // When the implementation fails, the method returns EvalStatusFailed and sets |
| 35 | // the |error| string. |
| 36 | |
| 37 | // UpdateCheckAllowed returns whether it is allowed to request an update check |
| 38 | // to Omaha. |
Alex Deymo | 2de23f5 | 2014-02-26 14:30:13 -0800 | [diff] [blame] | 39 | virtual EvalStatus UpdateCheckAllowed(EvaluationContext* ec, State* state, |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 40 | std::string* error, |
| 41 | bool* result) const = 0; |
| 42 | |
| 43 | protected: |
| 44 | Policy() {} |
| 45 | |
| 46 | private: |
| 47 | DISALLOW_COPY_AND_ASSIGN(Policy); |
| 48 | }; |
| 49 | |
| 50 | } // namespace chromeos_policy_manager |
| 51 | |
| 52 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_H |