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