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/time_provider.h b/policy_manager/time_provider.h
index 7b8bbd9..8349c01 100644
--- a/policy_manager/time_provider.h
+++ b/policy_manager/time_provider.h
@@ -16,16 +16,14 @@
// Provider for time related information.
class TimeProvider : public Provider {
public:
+ virtual ~TimeProvider() {}
+
// Returns the current date. The time of day component will be zero.
- Variable<base::Time>* var_curr_date() const {
- return var_curr_date_.get();
- }
+ virtual Variable<base::Time>* var_curr_date() = 0;
// Returns the current hour (0 to 23) in local time. The type is int to keep
// consistent with base::Time.
- Variable<int>* var_curr_hour() const {
- return var_curr_hour_.get();
- }
+ virtual Variable<int>* var_curr_hour() = 0;
// TODO(garnold) Implement a method/variable for querying whether a given
// point in time was reached.
@@ -33,18 +31,7 @@
protected:
TimeProvider() {}
- void set_var_curr_date(Variable<base::Time>* var_curr_date) {
- var_curr_date_.reset(var_curr_date);
- }
-
- void set_var_curr_hour(Variable<int>* var_curr_hour) {
- var_curr_hour_.reset(var_curr_hour);
- }
-
private:
- scoped_ptr<Variable<base::Time>> var_curr_date_;
- scoped_ptr<Variable<int>> var_curr_hour_;
-
DISALLOW_COPY_AND_ASSIGN(TimeProvider);
};