| Gilad Arnold | b33e198 | 2014-01-27 14:46:27 -0800 | [diff] [blame] | 1 | // 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 Arnold | 2cbb385 | 2014-03-07 12:40:50 -0800 | [diff] [blame] | 5 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_PROVIDER_H_ | 
|  | 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_PROVIDER_H_ | 
| Gilad Arnold | b33e198 | 2014-01-27 14:46:27 -0800 | [diff] [blame] | 7 |  | 
|  | 8 | namespace chromeos_policy_manager { | 
|  | 9 |  | 
|  | 10 | // Abstract base class for a policy provider. | 
|  | 11 | class Provider { | 
|  | 12 | public: | 
|  | 13 | Provider() : is_initialized_(false) {} | 
|  | 14 | virtual ~Provider() {} | 
|  | 15 |  | 
|  | 16 | // Initializes the provider at most once.  Returns true on success. | 
|  | 17 | bool Init() { | 
|  | 18 | return is_initialized_ || (is_initialized_ = DoInit()); | 
|  | 19 | } | 
|  | 20 |  | 
|  | 21 | protected: | 
|  | 22 | // Performs the actual initialization. To be implemented by concrete | 
|  | 23 | // subclasses. | 
|  | 24 | virtual bool DoInit() = 0; | 
|  | 25 |  | 
|  | 26 | private: | 
|  | 27 | // Whether the provider was already initialized. | 
|  | 28 | bool is_initialized_; | 
|  | 29 |  | 
|  | 30 | DISALLOW_COPY_AND_ASSIGN(Provider); | 
|  | 31 | }; | 
|  | 32 |  | 
|  | 33 | }  // namespace chromeos_policy_manager | 
|  | 34 |  | 
| Gilad Arnold | 2cbb385 | 2014-03-07 12:40:50 -0800 | [diff] [blame] | 35 | #endif  // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_PROVIDER_H_ |