blob: 0081c0d8f1d8b29170f85048d1769722019fb7d7 [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
5#ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_PM_PROVIDER_H
6#define CHROMEOS_PLATFORM_UPDATE_ENGINE_PM_PROVIDER_H
7
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
35#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_PM_PROVIDER_H