blob: 6acd31fac5758e27ddf58a9621b45837ddedc0be [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
15// Interface to a Policy Manager variable to be implemented by the providers.
16template<typename T>
17class Variable {
18 public:
19 virtual ~Variable() {}
20
21 protected:
Alex Deymoca0aaa62014-01-06 10:39:58 -080022 friend class PMRandomProviderTest;
23 FRIEND_TEST(PMRandomProviderTest, GetRandomValues);
24
Alex Deymo8c499142014-01-02 19:33:34 -080025 // Gets the current value of the variable. The current value is copied to a
26 // new object and returned. The caller of this method owns the object and
27 // should delete it.
28 //
29 // In case of and error getting the current value or the |timeout| timeout is
30 // exceeded, a NULL value is returned and the |errmsg| is set.
31 //
32 // The caller can pass a NULL value for |errmsg|, in which case the error
33 // message won't be set.
34 virtual const T* GetValue(base::TimeDelta timeout, std::string* errmsg) = 0;
35};
36
37} // namespace chromeos_policy_manager
38
39#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_VARIABLE_H