blob: 22039c06e32cc879d332a47a15c29ddc7a2d8e8c [file] [log] [blame]
Alex Deymo8c499142014-01-02 19:33:34 -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_VARIABLE_H
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_VARIABLE_H
7
8#include <string>
9
10#include <base/time.h>
Alex Deymoca0aaa62014-01-06 10:39:58 -080011#include <gtest/gtest_prod.h> // for FRIEND_TEST
Alex Deymo8c499142014-01-02 19:33:34 -080012
13namespace chromeos_policy_manager {
14
Gilad Arnold63e726a2014-01-28 22:28:19 -080015// Interface to a Policy Manager variable. Implementation internals are hidden
16// as protected members, since policies should not be using them directly.
Alex Deymo8c499142014-01-02 19:33:34 -080017template<typename T>
18class Variable {
19 public:
20 virtual ~Variable() {}
21
22 protected:
Gilad Arnoldb33e1982014-01-27 14:46:27 -080023 friend class PmRandomProviderTest;
24 FRIEND_TEST(PmRandomProviderTest, GetRandomValues);
Alex Deymoca0aaa62014-01-06 10:39:58 -080025
Alex Deymo8c499142014-01-02 19:33:34 -080026 // Gets the current value of the variable. The current value is copied to a
27 // new object and returned. The caller of this method owns the object and
28 // should delete it.
29 //
30 // In case of and error getting the current value or the |timeout| timeout is
31 // exceeded, a NULL value is returned and the |errmsg| is set.
32 //
33 // The caller can pass a NULL value for |errmsg|, in which case the error
34 // message won't be set.
35 virtual const T* GetValue(base::TimeDelta timeout, std::string* errmsg) = 0;
36};
37
38} // namespace chromeos_policy_manager
39
40#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_VARIABLE_H