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 | |
Gilad Arnold | 2cbb385 | 2014-03-07 12:40:50 -0800 | [diff] [blame] | 5 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_H_ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_H_ |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 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. |
Alex Deymo | e636c3c | 2014-03-11 19:02:08 -0700 | [diff] [blame] | 14 | enum class EvalStatus { |
| 15 | kFailed, |
| 16 | kSucceeded, |
| 17 | kAskMeAgainLater, |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 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 | // |
Alex Deymo | e636c3c | 2014-03-11 19:02:08 -0700 | [diff] [blame] | 34 | // When the implementation fails, the method returns EvalStatus::kFailed and |
| 35 | // sets the |error| string. |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 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 | |
Gilad Arnold | af2f6ae | 2014-04-28 14:14:52 -0700 | [diff] [blame^] | 43 | // Returns whether an update can be downloaded/applied. |
| 44 | virtual EvalStatus UpdateDownloadAndApplyAllowed(EvaluationContext* ec, |
| 45 | State* state, |
| 46 | std::string* error, |
| 47 | bool* result) const = 0; |
| 48 | |
Alex Deymo | c705cc8 | 2014-02-19 11:15:00 -0800 | [diff] [blame] | 49 | protected: |
| 50 | Policy() {} |
| 51 | |
| 52 | private: |
| 53 | DISALLOW_COPY_AND_ASSIGN(Policy); |
| 54 | }; |
| 55 | |
| 56 | } // namespace chromeos_policy_manager |
| 57 | |
Gilad Arnold | 2cbb385 | 2014-03-07 12:40:50 -0800 | [diff] [blame] | 58 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_H_ |