Alex Deymo | 8c49914 | 2014-01-02 19:33:34 -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_VARIABLE_H |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_VARIABLE_H |
| 7 | |
| 8 | #include <string> |
| 9 | |
| 10 | #include <base/time.h> |
Alex Deymo | ca0aaa6 | 2014-01-06 10:39:58 -0800 | [diff] [blame] | 11 | #include <gtest/gtest_prod.h> // for FRIEND_TEST |
Alex Deymo | 8c49914 | 2014-01-02 19:33:34 -0800 | [diff] [blame] | 12 | |
| 13 | namespace chromeos_policy_manager { |
| 14 | |
| 15 | // Interface to a Policy Manager variable to be implemented by the providers. |
| 16 | template<typename T> |
| 17 | class Variable { |
| 18 | public: |
| 19 | virtual ~Variable() {} |
| 20 | |
| 21 | protected: |
Alex Deymo | ca0aaa6 | 2014-01-06 10:39:58 -0800 | [diff] [blame] | 22 | friend class PMRandomProviderTest; |
| 23 | FRIEND_TEST(PMRandomProviderTest, GetRandomValues); |
| 24 | |
Alex Deymo | 8c49914 | 2014-01-02 19:33:34 -0800 | [diff] [blame] | 25 | // 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 |