OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 BASE_PREFS_PREF_REGISTRY_H_ | 5 #ifndef BASE_PREFS_PREF_REGISTRY_H_ |
6 #define BASE_PREFS_PREF_REGISTRY_H_ | 6 #define BASE_PREFS_PREF_REGISTRY_H_ |
7 | 7 |
8 #include "base/containers/hash_tables.h" | 8 #include "base/containers/hash_tables.h" |
9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
10 #include "base/prefs/base_prefs_export.h" | 10 #include "base/prefs/base_prefs_export.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // construction parameter to PrefService. | 25 // construction parameter to PrefService. |
26 // | 26 // |
27 // Currently, registrations after constructing the PrefService will | 27 // Currently, registrations after constructing the PrefService will |
28 // also work, but this is being deprecated. | 28 // also work, but this is being deprecated. |
29 class BASE_PREFS_EXPORT PrefRegistry : public base::RefCounted<PrefRegistry> { | 29 class BASE_PREFS_EXPORT PrefRegistry : public base::RefCounted<PrefRegistry> { |
30 public: | 30 public: |
31 // Registration flags that can be specified which impact how the pref will | 31 // Registration flags that can be specified which impact how the pref will |
32 // behave or be stored. This will be passed in a bitmask when the pref is | 32 // behave or be stored. This will be passed in a bitmask when the pref is |
33 // registered. Subclasses of PrefRegistry can specify their own flags. Care | 33 // registered. Subclasses of PrefRegistry can specify their own flags. Care |
34 // must be taken to ensure none of these overlap with the flags below. | 34 // must be taken to ensure none of these overlap with the flags below. |
35 enum PrefRegistrationFlags { | 35 enum PrefRegistrationFlags : uint32 { |
36 // No flags are specified. | 36 // No flags are specified. |
37 NO_REGISTRATION_FLAGS = 0, | 37 NO_REGISTRATION_FLAGS = 0, |
38 | 38 |
39 // The first 8 bits are reserved for subclasses of PrefRegistry to use. | 39 // The first 8 bits are reserved for subclasses of PrefRegistry to use. |
| 40 |
| 41 // This marks the pref as "lossy". There is no strict time guarantee on when |
| 42 // a lossy pref will be persisted to permanent storage when it is modified. |
| 43 LOSSY_PREF = 1 << 8, |
40 }; | 44 }; |
41 | 45 |
42 typedef PrefValueMap::const_iterator const_iterator; | 46 typedef PrefValueMap::const_iterator const_iterator; |
43 typedef base::hash_map<std::string, uint32> PrefRegistrationFlagsMap; | 47 typedef base::hash_map<std::string, uint32> PrefRegistrationFlagsMap; |
44 | 48 |
45 PrefRegistry(); | 49 PrefRegistry(); |
46 | 50 |
47 // Retrieve the set of registration flags for the given preference. The return | 51 // Retrieve the set of registration flags for the given preference. The return |
48 // value is a bitmask of PrefRegistrationFlags. | 52 // value is a bitmask of PrefRegistrationFlags. |
49 uint32 GetRegistrationFlags(const std::string& pref_name) const; | 53 uint32 GetRegistrationFlags(const std::string& pref_name) const; |
(...skipping 23 matching lines...) Expand all Loading... |
73 scoped_refptr<DefaultPrefStore> defaults_; | 77 scoped_refptr<DefaultPrefStore> defaults_; |
74 | 78 |
75 // A map of pref name to a bitmask of PrefRegistrationFlags. | 79 // A map of pref name to a bitmask of PrefRegistrationFlags. |
76 PrefRegistrationFlagsMap registration_flags_; | 80 PrefRegistrationFlagsMap registration_flags_; |
77 | 81 |
78 private: | 82 private: |
79 DISALLOW_COPY_AND_ASSIGN(PrefRegistry); | 83 DISALLOW_COPY_AND_ASSIGN(PrefRegistry); |
80 }; | 84 }; |
81 | 85 |
82 #endif // BASE_PREFS_PREF_REGISTRY_H_ | 86 #endif // BASE_PREFS_PREF_REGISTRY_H_ |
OLD | NEW |