PolicyManager: Move the global variables to Provider members.
Per the Google C++ Style Guide, the global variables can't be
instances of a class and that includes smart pointers like
scoped_ptr. The alternative is to use plain pointers such as a
Variable<T>*. The disadvantage of this approach is that the memory
pointed by this global variable is managed by a singleton class
(a FooProvider) on production code and a different class during
testing (a FakeFooProvider). Also, these classes, fake and real
implementation, aren't forced to implement the same set of variables
since there's no common interface. Finally, the
construction/destruction of these variables also needs to handle the
global pointer, nulifying it after deletion.
This patch moves the global variable to a member of a base class that
hides the initialization of these variables to a subclass. This patch
includes a subclass with the real implementation.
BUG=chromium:338591
TEST=unittest passes.
Change-Id: I0aa43c51d72c65d97be280fd58307d085bb8577b
Reviewed-on: https://chromium-review.googlesource.com/184774
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/SConstruct b/SConstruct
index 0d121d5..4d4003a 100644
--- a/SConstruct
+++ b/SConstruct
@@ -282,8 +282,7 @@
p2p_manager.cc
payload_signer.cc
payload_state.cc
- policy_manager/random_provider.cc
- policy_manager/random_vars.cc
+ policy_manager/real_random_provider.cc
postinstall_runner_action.cc
prefs.cc
proxy_resolver.cc
@@ -333,7 +332,7 @@
payload_signer_unittest.cc
payload_state_unittest.cc
policy_manager/generic_variables_unittest.cc
- policy_manager/random_provider_unittest.cc
+ policy_manager/real_random_provider_unittest.cc
policy_manager/variable_unittest.cc
postinstall_runner_action_unittest.cc
prefs_unittest.cc