blob: fef5c3577eb318bdc86e02bd5208b6a5bae3bb0a [file] [log] [blame]
Alex Deymoca0aaa62014-01-06 10:39:58 -08001// 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_RANDOM_PROVIDER_H_
6#define UPDATE_ENGINE_UPDATE_MANAGER_RANDOM_PROVIDER_H_
Alex Deymoca0aaa62014-01-06 10:39:58 -08007
Alex Deymo63784a52014-05-28 10:46:14 -07008#include "update_engine/update_manager/provider.h"
9#include "update_engine/update_manager/variable.h"
Alex Deymoca0aaa62014-01-06 10:39:58 -080010
Alex Deymo63784a52014-05-28 10:46:14 -070011namespace chromeos_update_manager {
Alex Deymoca0aaa62014-01-06 10:39:58 -080012
13// Provider of random values.
Gilad Arnoldb33e1982014-01-27 14:46:27 -080014class RandomProvider : public Provider {
Alex Deymoca0aaa62014-01-06 10:39:58 -080015 public:
David Zeuthen21716e22014-04-23 15:42:05 -070016 virtual ~RandomProvider() {}
17
Alex Deymobb019fe2014-02-03 20:12:17 -080018 // Return a random number every time it is requested. Note that values
19 // returned by the variables are cached by the EvaluationContext, so the
20 // returned value will be the same during the same policy request. If more
21 // random values are needed use a PRNG seeded with this value.
David Zeuthen21716e22014-04-23 15:42:05 -070022 virtual Variable<uint64_t>* var_seed() = 0;
Alex Deymoca0aaa62014-01-06 10:39:58 -080023
Gilad Arnoldb33e1982014-01-27 14:46:27 -080024 protected:
Alex Deymobb019fe2014-02-03 20:12:17 -080025 RandomProvider() {}
26
Alex Deymoca0aaa62014-01-06 10:39:58 -080027 private:
Alex Deymoca0aaa62014-01-06 10:39:58 -080028 DISALLOW_COPY_AND_ASSIGN(RandomProvider);
29};
30
Alex Deymo63784a52014-05-28 10:46:14 -070031} // namespace chromeos_update_manager
Alex Deymoca0aaa62014-01-06 10:39:58 -080032
Gilad Arnold48415f12014-06-27 07:10:58 -070033#endif // UPDATE_ENGINE_UPDATE_MANAGER_RANDOM_PROVIDER_H_