| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_IN_MEMORY_PREF_STORE_H_ | 5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_IN_MEMORY_PREF_STORE_H_ |
| 6 #define COMPONENTS_CRONET_ANDROID_CRONET_IN_MEMORY_PREF_STORE_H_ | 6 #define COMPONENTS_CRONET_ANDROID_CRONET_IN_MEMORY_PREF_STORE_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| 11 #include <string> | 11 #include <string> |
| 12 | 12 |
| 13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
| 14 #include "base/macros.h" | 14 #include "base/macros.h" |
| 15 #include "base/observer_list.h" | 15 #include "base/observer_list.h" |
| 16 #include "components/prefs/persistent_pref_store.h" | 16 #include "components/prefs/persistent_pref_store.h" |
| 17 #include "components/prefs/pref_value_map.h" | 17 #include "components/prefs/pref_value_map.h" |
| 18 | 18 |
| 19 namespace base { | 19 namespace base { |
| 20 class DictionaryValue; |
| 20 class Value; | 21 class Value; |
| 21 } | 22 } |
| 22 | 23 |
| 23 // A light-weight prefstore implementation that keeps preferences | 24 // A light-weight prefstore implementation that keeps preferences |
| 24 // in a memory backed store. This is not a persistent prefstore. | 25 // in a memory backed store. This is not a persistent prefstore. |
| 25 // TODO(bengr): Move to components/prefs or some other shared location. | 26 // TODO(bengr): Move to components/prefs or some other shared location. |
| 26 class CronetInMemoryPrefStore : public PersistentPrefStore { | 27 class CronetInMemoryPrefStore : public PersistentPrefStore { |
| 27 public: | 28 public: |
| 28 CronetInMemoryPrefStore(); | 29 CronetInMemoryPrefStore(); |
| 29 | 30 |
| 30 // PrefStore overrides: | 31 // PrefStore overrides: |
| 31 bool GetValue(const std::string& key, | 32 bool GetValue(const std::string& key, |
| 32 const base::Value** result) const override; | 33 const base::Value** result) const override; |
| 34 std::unique_ptr<base::DictionaryValue> GetValues() const override; |
| 33 void AddObserver(PrefStore::Observer* observer) override; | 35 void AddObserver(PrefStore::Observer* observer) override; |
| 34 void RemoveObserver(PrefStore::Observer* observer) override; | 36 void RemoveObserver(PrefStore::Observer* observer) override; |
| 35 bool HasObservers() const override; | 37 bool HasObservers() const override; |
| 36 bool IsInitializationComplete() const override; | 38 bool IsInitializationComplete() const override; |
| 37 | 39 |
| 38 // PersistentPrefStore overrides: | 40 // PersistentPrefStore overrides: |
| 39 bool GetMutableValue(const std::string& key, base::Value** result) override; | 41 bool GetMutableValue(const std::string& key, base::Value** result) override; |
| 40 void ReportValueChanged(const std::string& key, uint32_t flags) override; | 42 void ReportValueChanged(const std::string& key, uint32_t flags) override; |
| 41 void SetValue(const std::string& key, | 43 void SetValue(const std::string& key, |
| 42 std::unique_ptr<base::Value> value, | 44 std::unique_ptr<base::Value> value, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 58 | 60 |
| 59 // Stores the preference values. | 61 // Stores the preference values. |
| 60 PrefValueMap prefs_; | 62 PrefValueMap prefs_; |
| 61 | 63 |
| 62 base::ObserverList<PrefStore::Observer, true> observers_; | 64 base::ObserverList<PrefStore::Observer, true> observers_; |
| 63 | 65 |
| 64 DISALLOW_COPY_AND_ASSIGN(CronetInMemoryPrefStore); | 66 DISALLOW_COPY_AND_ASSIGN(CronetInMemoryPrefStore); |
| 65 }; | 67 }; |
| 66 | 68 |
| 67 #endif // COMPONENTS_CRONET_ANDROID_CRONET_IN_MEMORY_PREF_STORE_H_ | 69 #endif // COMPONENTS_CRONET_ANDROID_CRONET_IN_MEMORY_PREF_STORE_H_ |
| OLD | NEW |