OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_PREFS_WRITEABLE_PREF_STORE_H_ | 5 #ifndef COMPONENTS_PREFS_WRITEABLE_PREF_STORE_H_ |
6 #define COMPONENTS_PREFS_WRITEABLE_PREF_STORE_H_ | 6 #define COMPONENTS_PREFS_WRITEABLE_PREF_STORE_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
| 11 #include <set> |
11 #include <string> | 12 #include <string> |
| 13 #include <vector> |
12 | 14 |
13 #include "base/macros.h" | 15 #include "base/macros.h" |
14 #include "components/prefs/pref_store.h" | 16 #include "components/prefs/pref_store.h" |
15 | 17 |
16 namespace base { | 18 namespace base { |
17 class Value; | 19 class Value; |
18 } | 20 } |
19 | 21 |
20 // A pref store that can be written to as well as read from. | 22 // A pref store that can be written to as well as read from. |
21 class COMPONENTS_PREFS_EXPORT WriteablePrefStore : public PrefStore { | 23 class COMPONENTS_PREFS_EXPORT WriteablePrefStore : public PrefStore { |
(...skipping 17 matching lines...) Expand all Loading... |
39 std::unique_ptr<base::Value> value, | 41 std::unique_ptr<base::Value> value, |
40 uint32_t flags) = 0; | 42 uint32_t flags) = 0; |
41 | 43 |
42 // Removes the value for |key|. | 44 // Removes the value for |key|. |
43 virtual void RemoveValue(const std::string& key, uint32_t flags) = 0; | 45 virtual void RemoveValue(const std::string& key, uint32_t flags) = 0; |
44 | 46 |
45 // Equivalent to PrefStore::GetValue but returns a mutable value. | 47 // Equivalent to PrefStore::GetValue but returns a mutable value. |
46 virtual bool GetMutableValue(const std::string& key, | 48 virtual bool GetMutableValue(const std::string& key, |
47 base::Value** result) = 0; | 49 base::Value** result) = 0; |
48 | 50 |
49 // Triggers a value changed notification. This function needs to be called | 51 // Triggers a value changed notification. This function or |
50 // if one retrieves a list or dictionary with GetMutableValue and change its | 52 // ReportSubValuesChanged needs to be called if one retrieves a list or |
51 // value. SetValue takes care of notifications itself. Note that | 53 // dictionary with GetMutableValue and change its value. SetValue takes care |
52 // ReportValueChanged will trigger notifications even if nothing has changed. | 54 // of notifications itself. Note that ReportValueChanged will trigger |
53 // |flags| is a bitmask of PrefWriteFlags. | 55 // notifications even if nothing has changed. |flags| is a bitmask of |
| 56 // PrefWriteFlags. |
54 virtual void ReportValueChanged(const std::string& key, uint32_t flags) = 0; | 57 virtual void ReportValueChanged(const std::string& key, uint32_t flags) = 0; |
55 | 58 |
| 59 // Triggers a value changed notification for |path_components| in the |key| |
| 60 // pref. This function or ReportValueChanged needs to be called if one |
| 61 // retrieves a list or dictionary with GetMutableValue and change its value. |
| 62 // SetValue takes care of notifications itself. Note that |
| 63 // ReportSubValuesChanged will trigger notifications even if nothing has |
| 64 // changed. |flags| is a bitmask of PrefWriteFlags. |
| 65 virtual void ReportSubValuesChanged( |
| 66 const std::string& key, |
| 67 std::set<std::vector<std::string>> path_components, |
| 68 uint32_t flags); |
| 69 |
56 // Same as SetValue, but doesn't generate notifications. This is used by | 70 // Same as SetValue, but doesn't generate notifications. This is used by |
57 // PrefService::GetMutableUserPref() in order to put empty entries | 71 // PrefService::GetMutableUserPref() in order to put empty entries |
58 // into the user pref store. Using SetValue is not an option since existing | 72 // into the user pref store. Using SetValue is not an option since existing |
59 // tests rely on the number of notifications generated. |flags| is a bitmask | 73 // tests rely on the number of notifications generated. |flags| is a bitmask |
60 // of PrefWriteFlags. | 74 // of PrefWriteFlags. |
61 virtual void SetValueSilently(const std::string& key, | 75 virtual void SetValueSilently(const std::string& key, |
62 std::unique_ptr<base::Value> value, | 76 std::unique_ptr<base::Value> value, |
63 uint32_t flags) = 0; | 77 uint32_t flags) = 0; |
64 | 78 |
65 protected: | 79 protected: |
66 ~WriteablePrefStore() override {} | 80 ~WriteablePrefStore() override {} |
67 | 81 |
68 private: | 82 private: |
69 DISALLOW_COPY_AND_ASSIGN(WriteablePrefStore); | 83 DISALLOW_COPY_AND_ASSIGN(WriteablePrefStore); |
70 }; | 84 }; |
71 | 85 |
72 #endif // COMPONENTS_PREFS_WRITEABLE_PREF_STORE_H_ | 86 #endif // COMPONENTS_PREFS_WRITEABLE_PREF_STORE_H_ |
OLD | NEW |