blob: ff5598eb4b7053caba9c68526bb46b756423d6f0 [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
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"
Alex Deymo63784a52014-05-28 10:46:14 -070012#include "update_engine/update_manager/time_provider.h"
Gilad Arnold78a78112014-03-13 14:58:06 -070013
Alex Deymo63784a52014-05-28 10:46:14 -070014namespace chromeos_update_manager {
Gilad Arnold78a78112014-03-13 14:58:06 -070015
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
Alex Vakulenko157fe302014-08-11 15:59:58 -070025 Variable<base::Time>* var_curr_date() override {
David Zeuthen21716e22014-04-23 15:42:05 -070026 return var_curr_date_.get();
27 }
28
Alex Vakulenko157fe302014-08-11 15:59:58 -070029 Variable<int>* var_curr_hour() override {
David Zeuthen21716e22014-04-23 15:42:05 -070030 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
Alex Deymo63784a52014-05-28 10:46:14 -070043} // namespace chromeos_update_manager
Gilad Arnold78a78112014-03-13 14:58:06 -070044
Gilad Arnold48415f12014-06-27 07:10:58 -070045#endif // UPDATE_ENGINE_UPDATE_MANAGER_REAL_TIME_PROVIDER_H_