blob: 60d7b2c6d0fc858dc7fdbc9ce833bfca6dc8108e [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 Arnold2d2ee5f2014-02-02 20:49:12 -08005#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_RANDOM_PROVIDER_H
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_RANDOM_PROVIDER_H
Alex Deymoca0aaa62014-01-06 10:39:58 -08007
Alex Deymobb019fe2014-02-03 20:12:17 -08008#include <base/memory/scoped_ptr.h>
9
Gilad Arnoldb33e1982014-01-27 14:46:27 -080010#include "policy_manager/provider.h"
Alex Deymobb019fe2014-02-03 20:12:17 -080011#include "policy_manager/variable.h"
Alex Deymoca0aaa62014-01-06 10:39:58 -080012
13namespace chromeos_policy_manager {
14
15// Provider of random values.
Gilad Arnoldb33e1982014-01-27 14:46:27 -080016class RandomProvider : public Provider {
Alex Deymoca0aaa62014-01-06 10:39:58 -080017 public:
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.
22 Variable<uint64_t>* seed() const { return seed_.get(); }
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
27 // The seed() scoped variable.
28 scoped_ptr<Variable<uint64_t> > seed_;
Alex Deymoca0aaa62014-01-06 10:39:58 -080029
30 private:
Alex Deymoca0aaa62014-01-06 10:39:58 -080031 DISALLOW_COPY_AND_ASSIGN(RandomProvider);
32};
33
34} // namespace chromeos_policy_manager
35
Gilad Arnold2d2ee5f2014-02-02 20:49:12 -080036#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_RANDOM_PROVIDER_H