OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_CRONET_ANDROID_CRONET_IN_MEMORY_PREF_STORE_H_ | |
6 #define COMPONENTS_CRONET_ANDROID_CRONET_IN_MEMORY_PREF_STORE_H_ | |
7 | |
8 #include <stdint.h> | |
9 | |
10 #include <memory> | |
11 #include <string> | |
12 | |
13 #include "base/compiler_specific.h" | |
14 #include "base/macros.h" | |
15 #include "base/observer_list.h" | |
16 #include "components/prefs/persistent_pref_store.h" | |
17 #include "components/prefs/pref_value_map.h" | |
18 | |
19 namespace base { | |
20 class DictionaryValue; | |
21 class Value; | |
22 } | |
23 | |
24 // A light-weight prefstore implementation that keeps preferences | |
25 // in a memory backed store. This is not a persistent prefstore. | |
26 // TODO(bengr): Move to components/prefs or some other shared location. | |
27 class CronetInMemoryPrefStore : public PersistentPrefStore { | |
28 public: | |
29 CronetInMemoryPrefStore(); | |
30 | |
31 // PrefStore overrides: | |
32 bool GetValue(const std::string& key, | |
33 const base::Value** result) const override; | |
34 std::unique_ptr<base::DictionaryValue> GetValues() const override; | |
35 void AddObserver(PrefStore::Observer* observer) override; | |
36 void RemoveObserver(PrefStore::Observer* observer) override; | |
37 bool HasObservers() const override; | |
38 bool IsInitializationComplete() const override; | |
39 | |
40 // PersistentPrefStore overrides: | |
41 bool GetMutableValue(const std::string& key, base::Value** result) override; | |
42 void ReportValueChanged(const std::string& key, uint32_t flags) override; | |
43 void SetValue(const std::string& key, | |
44 std::unique_ptr<base::Value> value, | |
45 uint32_t flags) override; | |
46 void SetValueSilently(const std::string& key, | |
47 std::unique_ptr<base::Value> value, | |
48 uint32_t flags) override; | |
49 void RemoveValue(const std::string& key, uint32_t flags) override; | |
50 bool ReadOnly() const override; | |
51 PrefReadError GetReadError() const override; | |
52 PersistentPrefStore::PrefReadError ReadPrefs() override; | |
53 void ReadPrefsAsync(ReadErrorDelegate* error_delegate) override; | |
54 void CommitPendingWrite() override {} | |
55 void SchedulePendingLossyWrites() override {} | |
56 void ClearMutableValues() override {} | |
57 | |
58 private: | |
59 ~CronetInMemoryPrefStore() override; | |
60 | |
61 // Stores the preference values. | |
62 PrefValueMap prefs_; | |
63 | |
64 base::ObserverList<PrefStore::Observer, true> observers_; | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(CronetInMemoryPrefStore); | |
67 }; | |
68 | |
69 #endif // COMPONENTS_CRONET_ANDROID_CRONET_IN_MEMORY_PREF_STORE_H_ | |
OLD | NEW |