blob: 60df62da2e1de1e587d63638ece0aa5ad950bd07 [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//
Alex Deymoca0aaa62014-01-06 10:39:58 -080016
Gilad Arnold48415f12014-06-27 07:10:58 -070017#ifndef UPDATE_ENGINE_UPDATE_MANAGER_RANDOM_PROVIDER_H_
18#define UPDATE_ENGINE_UPDATE_MANAGER_RANDOM_PROVIDER_H_
Alex Deymoca0aaa62014-01-06 10:39:58 -080019
Alex Deymo63784a52014-05-28 10:46:14 -070020#include "update_engine/update_manager/provider.h"
21#include "update_engine/update_manager/variable.h"
Alex Deymoca0aaa62014-01-06 10:39:58 -080022
Alex Deymo63784a52014-05-28 10:46:14 -070023namespace chromeos_update_manager {
Alex Deymoca0aaa62014-01-06 10:39:58 -080024
25// Provider of random values.
Gilad Arnoldb33e1982014-01-27 14:46:27 -080026class RandomProvider : public Provider {
Alex Deymoca0aaa62014-01-06 10:39:58 -080027 public:
Alex Deymo610277e2014-11-11 21:18:11 -080028 ~RandomProvider() override {}
David Zeuthen21716e22014-04-23 15:42:05 -070029
Alex Deymobb019fe2014-02-03 20:12:17 -080030 // Return a random number every time it is requested. Note that values
31 // returned by the variables are cached by the EvaluationContext, so the
32 // returned value will be the same during the same policy request. If more
33 // random values are needed use a PRNG seeded with this value.
David Zeuthen21716e22014-04-23 15:42:05 -070034 virtual Variable<uint64_t>* var_seed() = 0;
Alex Deymoca0aaa62014-01-06 10:39:58 -080035
Gilad Arnoldb33e1982014-01-27 14:46:27 -080036 protected:
Alex Deymobb019fe2014-02-03 20:12:17 -080037 RandomProvider() {}
38
Alex Deymoca0aaa62014-01-06 10:39:58 -080039 private:
Alex Deymoca0aaa62014-01-06 10:39:58 -080040 DISALLOW_COPY_AND_ASSIGN(RandomProvider);
41};
42
Alex Deymo63784a52014-05-28 10:46:14 -070043} // namespace chromeos_update_manager
Alex Deymoca0aaa62014-01-06 10:39:58 -080044
Gilad Arnold48415f12014-06-27 07:10:58 -070045#endif // UPDATE_ENGINE_UPDATE_MANAGER_RANDOM_PROVIDER_H_