PolicyManager: Remove unnecessary Init() methods.
The PolicyManager::Init() method always return true as it can't
really fail. This patch removes it and simplifies the interface
on the FakePolicyManager to make it easier to use it on Policy
unit testing exposing the FakeState there.
BUG=chromium:358269
TEST=Build and unittests.
Change-Id: Ib27dd41a483b10f164810e18585a8e4b4cb92f5a
Reviewed-on: https://chromium-review.googlesource.com/196968
Tested-by: Alex Deymo <deymo@chromium.org>
Reviewed-by: Gilad Arnold <garnold@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
diff --git a/policy_manager/policy_manager.h b/policy_manager/policy_manager.h
index 75e6082..99ca26b 100644
--- a/policy_manager/policy_manager.h
+++ b/policy_manager/policy_manager.h
@@ -19,13 +19,12 @@
// The main Policy Manager singleton class.
class PolicyManager {
public:
- explicit PolicyManager(chromeos_update_engine::ClockInterface* clock)
- : clock_(clock) {}
+ // Creates the PolicyManager instance, assuming ownership on the provided
+ // |state|.
+ PolicyManager(chromeos_update_engine::ClockInterface* clock,
+ State* state);
- // Initializes the PolicyManager instance, assuming ownership on the provided
- // |state|, which is assumed to be pre-initialized. Returns whether the
- // initialization succeeded.
- bool Init(State* state);
+ virtual ~PolicyManager() {}
// PolicyRequest() evaluates the given policy with the provided arguments and
// returns the result. The |policy_method| is the pointer-to-method of the
@@ -76,6 +75,9 @@
policy_.reset(policy);
}
+ // State getter used for testing.
+ State* state() { return state_.get(); }
+
private:
FRIEND_TEST(PmPolicyManagerTest, PolicyRequestCallsPolicy);
FRIEND_TEST(PmPolicyManagerTest, PolicyRequestCallsDefaultOnError);