PM: Macro for streamlining declaration of variable closers.

BUG=None
TEST=Builds and passes unit tests.

Change-Id: I1c41597cee689489fe611eb1f15f48a95462b07e
Reviewed-on: https://chromium-review.googlesource.com/184433
Tested-by: Gilad Arnold <garnold@chromium.org>
Reviewed-by: Alex Deymo <deymo@chromium.org>
Commit-Queue: Gilad Arnold <garnold@chromium.org>
diff --git a/policy_manager/provider_utils.h b/policy_manager/provider_utils.h
index 8786c90..5284ab2 100644
--- a/policy_manager/provider_utils.h
+++ b/policy_manager/provider_utils.h
@@ -5,6 +5,16 @@
 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_PROVIDER_UTILS_H
 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_PROVIDER_UTILS_H
 
+// Convenience macro for declaring policy variable closers.
+//
+// TODO(garnold) If/when we switch to C++11, this can already initialize the
+// closer with the variable's address and save us further work in the ctor.
+//
+// TODO(garnold) This is likely unnecessary once we introduce a non-template
+// variable base class.
+#define DECLARE_VAR_CLOSER(closer_name, var_name) \
+    ScopedPtrVarCloser<typeof(var_name)> closer_name
+
 namespace chromeos_policy_manager {
 
 // Scoped closer for a pointer variable. It is initialized with a reference to
diff --git a/policy_manager/random_provider.h b/policy_manager/random_provider.h
index ae27301..f0c1477 100644
--- a/policy_manager/random_provider.h
+++ b/policy_manager/random_provider.h
@@ -20,7 +20,7 @@
   virtual bool DoInit();
 
  private:
-  ScopedPtrVarCloser<typeof(var_random_seed)> seed_closer_;
+  DECLARE_VAR_CLOSER(seed_closer_, var_random_seed);
 
   DISALLOW_COPY_AND_ASSIGN(RandomProvider);
 };