OLD | NEW |
(Empty) | |
| 1 // Copyright 2017 The Chromium 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 SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_ADAPTER_H_ |
| 6 #define SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_ADAPTER_H_ |
| 7 |
| 8 #include <memory> |
| 9 |
| 10 #include "base/macros.h" |
| 11 #include "base/values.h" |
| 12 #include "components/prefs/pref_store.h" |
| 13 #include "services/preferences/public/cpp/pref_store_impl.h" |
| 14 |
| 15 namespace prefs { |
| 16 |
| 17 // Ties the life time of a |PrefStoreImpl| to a |PrefStore|. Otherwise acts as a |
| 18 // |PrefStore|, forwarding all calls to the wrapped |PrefStore|. |
| 19 class PrefStoreAdapter : public PrefStore { |
| 20 public: |
| 21 PrefStoreAdapter(scoped_refptr<PrefStore> pref_store, |
| 22 std::unique_ptr<PrefStoreImpl> impl); |
| 23 |
| 24 // PrefStore: |
| 25 void AddObserver(PrefStore::Observer* observer) override; |
| 26 void RemoveObserver(PrefStore::Observer* observer) override; |
| 27 bool HasObservers() const override; |
| 28 bool IsInitializationComplete() const override; |
| 29 bool GetValue(const std::string& key, |
| 30 const base::Value** result) const override; |
| 31 std::unique_ptr<base::DictionaryValue> GetValues() const override; |
| 32 |
| 33 private: |
| 34 ~PrefStoreAdapter() override; |
| 35 |
| 36 scoped_refptr<PrefStore> pref_store_; |
| 37 std::unique_ptr<PrefStoreImpl> impl_; |
| 38 |
| 39 DISALLOW_COPY_AND_ASSIGN(PrefStoreAdapter); |
| 40 }; |
| 41 |
| 42 } // namespace prefs |
| 43 |
| 44 #endif // SERVICES_PREFERENCES_PUBLIC_CPP_PREF_STORE_ADAPTER_H_ |
OLD | NEW |