PolicyManager: New System provider.
The system provider exposes information about the device from
crossystem and the kernel boot command line options.
BUG=chromium:338587
TEST=Unit tests.
Change-Id: I2837a97740b63562155717cfe6a12fad69fd8cea
Reviewed-on: https://chromium-review.googlesource.com/191121
Reviewed-by: Alex Deymo <[email protected]>
Tested-by: Alex Deymo <[email protected]>
Commit-Queue: Alex Deymo <[email protected]>
diff --git a/policy_manager/generic_variables.h b/policy_manager/generic_variables.h
index f874b3b..2f9b996 100644
--- a/policy_manager/generic_variables.h
+++ b/policy_manager/generic_variables.h
@@ -59,6 +59,32 @@
const T& ref_;
};
+// Variable class returning a constant value that is cached on the variable when
+// it is created.
+template<typename T>
+class ConstCopyVariable : public Variable<T> {
+ public:
+ // Creates the variable returning copies of the passed |obj|. The value passed
+ // is copied in this variable, and new copies of it will be returned by
+ // GetValue().
+ ConstCopyVariable(const std::string& name, const T& obj)
+ : Variable<T>(name, kVariableModeConst), obj_(obj) {}
+
+ protected:
+ friend class PmConstCopyVariableTest;
+ FRIEND_TEST(PmConstCopyVariableTest, SimpleTest);
+
+ // Variable override.
+ virtual const T* GetValue(base::TimeDelta /* timeout */,
+ std::string* /* errmsg */) {
+ return new T(obj_);
+ }
+
+ private:
+ // Value to be copied by GetValue().
+ const T obj_;
+};
+
} // namespace chromeos_policy_manager
#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_GENERIC_VARIABLES_H_