blob: 63fc116d54101416d096abce63e84deabe5c003c [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
Gilad Arnold48415f12014-06-27 07:10:58 -07005#ifndef UPDATE_ENGINE_UPDATE_MANAGER_REAL_TIME_PROVIDER_H_
6#define UPDATE_ENGINE_UPDATE_MANAGER_REAL_TIME_PROVIDER_H_
Gilad Arnold78a78112014-03-13 14:58:06 -07007
Ben Chan02f7c1d2014-10-18 15:18:02 -07008#include <memory>
9
Alex Vakulenko75039d72014-03-25 12:36:28 -070010#include <base/time/time.h>
Gilad Arnold78a78112014-03-13 14:58:06 -070011
12#include "update_engine/clock_interface.h"
Alex Deymo63784a52014-05-28 10:46:14 -070013#include "update_engine/update_manager/time_provider.h"
Gilad Arnold78a78112014-03-13 14:58:06 -070014
Alex Deymo63784a52014-05-28 10:46:14 -070015namespace chromeos_update_manager {
Gilad Arnold78a78112014-03-13 14:58:06 -070016
17// TimeProvider concrete implementation.
18class RealTimeProvider : public TimeProvider {
19 public:
Alex Deymo1f012912014-04-24 19:08:04 -070020 explicit RealTimeProvider(chromeos_update_engine::ClockInterface* clock)
Gilad Arnold78a78112014-03-13 14:58:06 -070021 : clock_(clock) {}
22
Alex Deymo42c30c32014-04-24 18:41:18 -070023 // Initializes the provider and returns whether it succeeded.
24 bool Init();
25
Alex Vakulenko157fe302014-08-11 15:59:58 -070026 Variable<base::Time>* var_curr_date() override {
David Zeuthen21716e22014-04-23 15:42:05 -070027 return var_curr_date_.get();
28 }
29
Alex Vakulenko157fe302014-08-11 15:59:58 -070030 Variable<int>* var_curr_hour() override {
David Zeuthen21716e22014-04-23 15:42:05 -070031 return var_curr_hour_.get();
32 }
Gilad Arnold78a78112014-03-13 14:58:06 -070033
34 private:
David Zeuthen21716e22014-04-23 15:42:05 -070035 // A clock abstraction (fakeable).
Gilad Arnold78a78112014-03-13 14:58:06 -070036 chromeos_update_engine::ClockInterface* const clock_;
37
Ben Chan02f7c1d2014-10-18 15:18:02 -070038 std::unique_ptr<Variable<base::Time>> var_curr_date_;
39 std::unique_ptr<Variable<int>> var_curr_hour_;
David Zeuthen21716e22014-04-23 15:42:05 -070040
Gilad Arnold78a78112014-03-13 14:58:06 -070041 DISALLOW_COPY_AND_ASSIGN(RealTimeProvider);
42};
43
Alex Deymo63784a52014-05-28 10:46:14 -070044} // namespace chromeos_update_manager
Gilad Arnold78a78112014-03-13 14:58:06 -070045
Gilad Arnold48415f12014-06-27 07:10:58 -070046#endif // UPDATE_ENGINE_UPDATE_MANAGER_REAL_TIME_PROVIDER_H_