blob: e7cae944d0140fff99d9b2de7a39ae005db26174 [file] [log] [blame]
Alex Deymoaea4c1c2015-08-19 20:24:43 -07001//
2// Copyright (C) 2014 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
Gilad Arnold78a78112014-03-13 14:58:06 -070016
Gilad Arnold48415f12014-06-27 07:10:58 -070017#ifndef UPDATE_ENGINE_UPDATE_MANAGER_REAL_TIME_PROVIDER_H_
18#define UPDATE_ENGINE_UPDATE_MANAGER_REAL_TIME_PROVIDER_H_
Gilad Arnold78a78112014-03-13 14:58:06 -070019
Ben Chan02f7c1d2014-10-18 15:18:02 -070020#include <memory>
21
Alex Vakulenko75039d72014-03-25 12:36:28 -070022#include <base/time/time.h>
Gilad Arnold78a78112014-03-13 14:58:06 -070023
Alex Deymo39910dc2015-11-09 17:04:30 -080024#include "update_engine/common/clock_interface.h"
Alex Deymo63784a52014-05-28 10:46:14 -070025#include "update_engine/update_manager/time_provider.h"
Gilad Arnold78a78112014-03-13 14:58:06 -070026
Alex Deymo63784a52014-05-28 10:46:14 -070027namespace chromeos_update_manager {
Gilad Arnold78a78112014-03-13 14:58:06 -070028
29// TimeProvider concrete implementation.
30class RealTimeProvider : public TimeProvider {
31 public:
Alex Deymo1f012912014-04-24 19:08:04 -070032 explicit RealTimeProvider(chromeos_update_engine::ClockInterface* clock)
Gilad Arnold78a78112014-03-13 14:58:06 -070033 : clock_(clock) {}
34
Alex Deymo42c30c32014-04-24 18:41:18 -070035 // Initializes the provider and returns whether it succeeded.
36 bool Init();
37
Alex Vakulenko157fe302014-08-11 15:59:58 -070038 Variable<base::Time>* var_curr_date() override {
David Zeuthen21716e22014-04-23 15:42:05 -070039 return var_curr_date_.get();
40 }
41
Alex Vakulenko157fe302014-08-11 15:59:58 -070042 Variable<int>* var_curr_hour() override {
David Zeuthen21716e22014-04-23 15:42:05 -070043 return var_curr_hour_.get();
44 }
Gilad Arnold78a78112014-03-13 14:58:06 -070045
46 private:
David Zeuthen21716e22014-04-23 15:42:05 -070047 // A clock abstraction (fakeable).
Gilad Arnold78a78112014-03-13 14:58:06 -070048 chromeos_update_engine::ClockInterface* const clock_;
49
Ben Chan02f7c1d2014-10-18 15:18:02 -070050 std::unique_ptr<Variable<base::Time>> var_curr_date_;
51 std::unique_ptr<Variable<int>> var_curr_hour_;
David Zeuthen21716e22014-04-23 15:42:05 -070052
Gilad Arnold78a78112014-03-13 14:58:06 -070053 DISALLOW_COPY_AND_ASSIGN(RealTimeProvider);
54};
55
Alex Deymo63784a52014-05-28 10:46:14 -070056} // namespace chromeos_update_manager
Gilad Arnold78a78112014-03-13 14:58:06 -070057
Gilad Arnold48415f12014-06-27 07:10:58 -070058#endif // UPDATE_ENGINE_UPDATE_MANAGER_REAL_TIME_PROVIDER_H_