| Alex Deymo | aea4c1c | 2015-08-19 20:24:43 -0700 | [diff] [blame] | 1 | // | 
|  | 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 Deymo | ca0aaa6 | 2014-01-06 10:39:58 -0800 | [diff] [blame] | 16 |  | 
| Gilad Arnold | 48415f1 | 2014-06-27 07:10:58 -0700 | [diff] [blame] | 17 | #ifndef UPDATE_ENGINE_UPDATE_MANAGER_RANDOM_PROVIDER_H_ | 
|  | 18 | #define UPDATE_ENGINE_UPDATE_MANAGER_RANDOM_PROVIDER_H_ | 
| Alex Deymo | ca0aaa6 | 2014-01-06 10:39:58 -0800 | [diff] [blame] | 19 |  | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 20 | #include "update_engine/update_manager/provider.h" | 
|  | 21 | #include "update_engine/update_manager/variable.h" | 
| Alex Deymo | ca0aaa6 | 2014-01-06 10:39:58 -0800 | [diff] [blame] | 22 |  | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 23 | namespace chromeos_update_manager { | 
| Alex Deymo | ca0aaa6 | 2014-01-06 10:39:58 -0800 | [diff] [blame] | 24 |  | 
|  | 25 | // Provider of random values. | 
| Gilad Arnold | b33e198 | 2014-01-27 14:46:27 -0800 | [diff] [blame] | 26 | class RandomProvider : public Provider { | 
| Alex Deymo | ca0aaa6 | 2014-01-06 10:39:58 -0800 | [diff] [blame] | 27 | public: | 
| Alex Deymo | 610277e | 2014-11-11 21:18:11 -0800 | [diff] [blame] | 28 | ~RandomProvider() override {} | 
| David Zeuthen | 21716e2 | 2014-04-23 15:42:05 -0700 | [diff] [blame] | 29 |  | 
| Alex Deymo | bb019fe | 2014-02-03 20:12:17 -0800 | [diff] [blame] | 30 | // 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 Zeuthen | 21716e2 | 2014-04-23 15:42:05 -0700 | [diff] [blame] | 34 | virtual Variable<uint64_t>* var_seed() = 0; | 
| Alex Deymo | ca0aaa6 | 2014-01-06 10:39:58 -0800 | [diff] [blame] | 35 |  | 
| Gilad Arnold | b33e198 | 2014-01-27 14:46:27 -0800 | [diff] [blame] | 36 | protected: | 
| Alex Deymo | bb019fe | 2014-02-03 20:12:17 -0800 | [diff] [blame] | 37 | RandomProvider() {} | 
|  | 38 |  | 
| Alex Deymo | ca0aaa6 | 2014-01-06 10:39:58 -0800 | [diff] [blame] | 39 | private: | 
| Alex Deymo | ca0aaa6 | 2014-01-06 10:39:58 -0800 | [diff] [blame] | 40 | DISALLOW_COPY_AND_ASSIGN(RandomProvider); | 
|  | 41 | }; | 
|  | 42 |  | 
| Alex Deymo | 63784a5 | 2014-05-28 10:46:14 -0700 | [diff] [blame] | 43 | }  // namespace chromeos_update_manager | 
| Alex Deymo | ca0aaa6 | 2014-01-06 10:39:58 -0800 | [diff] [blame] | 44 |  | 
| Gilad Arnold | 48415f1 | 2014-06-27 07:10:58 -0700 | [diff] [blame] | 45 | #endif  // UPDATE_ENGINE_UPDATE_MANAGER_RANDOM_PROVIDER_H_ |