PM: Move the getters/variables on provider base classes to abstract methods.
Also make all DoInit() overrides in subclasses private, not protected
and ensure that all the abstract Provider interface classes has
virtual destructors.
Additionally, remove inlining of virtual methods in derived classes
since it won't matter much in our application. This is because we'll
call these methods only indirectly e.g. through a vtable dispatch via
a method call on the interface class.
BUG=chromium:364763
TEST=Unit tests pass.
Change-Id: I7f6a10d9c0b01c4f5c035125755ef132738e72aa
Reviewed-on: https://chromium-review.googlesource.com/196656
Reviewed-by: David Zeuthen <zeuthen@chromium.org>
Tested-by: David Zeuthen <zeuthen@chromium.org>
Commit-Queue: David Zeuthen <zeuthen@chromium.org>
diff --git a/policy_manager/fake_system_provider.h b/policy_manager/fake_system_provider.h
index 8e6b92a..fbdff49 100644
--- a/policy_manager/fake_system_provider.h
+++ b/policy_manager/fake_system_provider.h
@@ -15,16 +15,22 @@
public:
FakeSystemProvider() {}
- protected:
- virtual bool DoInit() {
- set_var_is_normal_boot_mode(
- new FakeVariable<bool>("is_normal_boot_mode", kVariableModeConst));
- set_var_is_official_build(
- new FakeVariable<bool>("is_official_build", kVariableModeConst));
- return true;
+ virtual FakeVariable<bool>* var_is_normal_boot_mode() override {
+ return &var_is_normal_boot_mode_;
+ }
+
+ virtual FakeVariable<bool>* var_is_official_build() override {
+ return &var_is_official_build_;
}
private:
+ virtual bool DoInit() override { return true; }
+
+ FakeVariable<bool> var_is_normal_boot_mode_{
+ "is_normal_boot_mode", kVariableModeConst};
+ FakeVariable<bool> var_is_official_build_{
+ "is_official_build", kVariableModeConst};
+
DISALLOW_COPY_AND_ASSIGN(FakeSystemProvider);
};