blob: 762b9a5ecde035eddd524548579f3664458d5b3d [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_H
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_POLICY_H
7
8#include "update_engine/policy_manager/evaluation_context.h"
Alex Deymo2de23f52014-02-26 14:30:13 -08009#include "update_engine/policy_manager/state.h"
Alex Deymoc705cc82014-02-19 11:15:00 -080010
11namespace chromeos_policy_manager {
12
13// The three different results of a policy request.
Alex Deymoe636c3c2014-03-11 19:02:08 -070014enum class EvalStatus {
15 kFailed,
16 kSucceeded,
17 kAskMeAgainLater,
Alex Deymoc705cc82014-02-19 11:15:00 -080018};
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.
26class Policy {
27 public:
28 virtual ~Policy() {}
29
30 // List of policy requests. A policy request takes an EvaluationContext as the
Alex Deymo2de23f52014-02-26 14:30:13 -080031 // first argument, a State instance, a returned error message, a returned
32 // value and optionally followed by one or more arbitrary constant arguments.
Alex Deymoc705cc82014-02-19 11:15:00 -080033 //
Alex Deymoe636c3c2014-03-11 19:02:08 -070034 // When the implementation fails, the method returns EvalStatus::kFailed and
35 // sets the |error| string.
Alex Deymoc705cc82014-02-19 11:15:00 -080036
37 // UpdateCheckAllowed returns whether it is allowed to request an update check
38 // to Omaha.
Alex Deymo2de23f52014-02-26 14:30:13 -080039 virtual EvalStatus UpdateCheckAllowed(EvaluationContext* ec, State* state,
Alex Deymoc705cc82014-02-19 11:15:00 -080040 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