blob: d6d11775e302b22a6700b3cca8d63e1f14a5421f [file] [log] [blame]
Gilad Arnold78a78112014-03-13 14:58:06 -07001// Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_REAL_TIME_PROVIDER_H_
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_REAL_TIME_PROVIDER_H_
7
Alex Deymo1f012912014-04-24 19:08:04 -07008#include <base/memory/scoped_ptr.h>
Alex Vakulenko75039d72014-03-25 12:36:28 -07009#include <base/time/time.h>
Gilad Arnold78a78112014-03-13 14:58:06 -070010
11#include "update_engine/clock_interface.h"
12#include "update_engine/policy_manager/time_provider.h"
13
14namespace chromeos_policy_manager {
15
16// TimeProvider concrete implementation.
17class RealTimeProvider : public TimeProvider {
18 public:
Alex Deymo1f012912014-04-24 19:08:04 -070019 explicit RealTimeProvider(chromeos_update_engine::ClockInterface* clock)
Gilad Arnold78a78112014-03-13 14:58:06 -070020 : clock_(clock) {}
21
Alex Deymo42c30c32014-04-24 18:41:18 -070022 // Initializes the provider and returns whether it succeeded.
23 bool Init();
24
David Zeuthen21716e22014-04-23 15:42:05 -070025 virtual Variable<base::Time>* var_curr_date() override {
26 return var_curr_date_.get();
27 }
28
29 virtual Variable<int>* var_curr_hour() override {
30 return var_curr_hour_.get();
31 }
Gilad Arnold78a78112014-03-13 14:58:06 -070032
33 private:
David Zeuthen21716e22014-04-23 15:42:05 -070034 // A clock abstraction (fakeable).
Gilad Arnold78a78112014-03-13 14:58:06 -070035 chromeos_update_engine::ClockInterface* const clock_;
36
David Zeuthen21716e22014-04-23 15:42:05 -070037 scoped_ptr<Variable<base::Time>> var_curr_date_;
38 scoped_ptr<Variable<int>> var_curr_hour_;
39
Gilad Arnold78a78112014-03-13 14:58:06 -070040 DISALLOW_COPY_AND_ASSIGN(RealTimeProvider);
41};
42
43} // namespace chromeos_policy_manager
44
45#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_REAL_TIME_PROVIDER_H_