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