blob: 9ee5e8ab1e68418cfb15e1072b3a5f665e6d0e7e [file] [log] [blame]
Gilad Arnoldb33e1982014-01-27 14:46:27 -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 Arnold2cbb3852014-03-07 12:40:50 -08005#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_PROVIDER_H_
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_PROVIDER_H_
Gilad Arnoldb33e1982014-01-27 14:46:27 -08007
8namespace chromeos_policy_manager {
9
10// Abstract base class for a policy provider.
11class 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 Arnold2cbb3852014-03-07 12:40:50 -080035#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_POLICY_MANAGER_PROVIDER_H_