| 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 // A helper class that stays in sync with a preference (bool, int, real, | 5 // A helper class that stays in sync with a preference (bool, int, real, |
| 6 // string or filepath). For example: | 6 // string or filepath). For example: |
| 7 // | 7 // |
| 8 // class MyClass { | 8 // class MyClass { |
| 9 // public: | 9 // public: |
| 10 // MyClass(PrefService* prefs) { | 10 // MyClass(PrefService* prefs) { |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 109 | 109 |
| 110 virtual void CreateInternal() const = 0; | 110 virtual void CreateInternal() const = 0; |
| 111 | 111 |
| 112 // See PrefMember<> for description. | 112 // See PrefMember<> for description. |
| 113 void Destroy(); | 113 void Destroy(); |
| 114 | 114 |
| 115 void MoveToThread( | 115 void MoveToThread( |
| 116 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); | 116 const scoped_refptr<base::SingleThreadTaskRunner>& task_runner); |
| 117 | 117 |
| 118 // PrefObserver | 118 // PrefObserver |
| 119 virtual void OnPreferenceChanged(PrefService* service, | 119 void OnPreferenceChanged(PrefService* service, |
| 120 const std::string& pref_name) override; | 120 const std::string& pref_name) override; |
| 121 | 121 |
| 122 void VerifyValuePrefName() const { | 122 void VerifyValuePrefName() const { |
| 123 DCHECK(!pref_name_.empty()); | 123 DCHECK(!pref_name_.empty()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 // This method is used to do the actual sync with the preference. | 126 // This method is used to do the actual sync with the preference. |
| 127 // Note: it is logically const, because it doesn't modify the state | 127 // Note: it is logically const, because it doesn't modify the state |
| 128 // seen by the outside world. It is just doing a lazy load behind the scenes. | 128 // seen by the outside world. It is just doing a lazy load behind the scenes. |
| 129 void UpdateValueFromPref(const base::Closure& callback) const; | 129 void UpdateValueFromPref(const base::Closure& callback) const; |
| 130 | 130 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 345 |
| 346 typedef PrefMember<bool> BooleanPrefMember; | 346 typedef PrefMember<bool> BooleanPrefMember; |
| 347 typedef PrefMember<int> IntegerPrefMember; | 347 typedef PrefMember<int> IntegerPrefMember; |
| 348 typedef PrefMember<double> DoublePrefMember; | 348 typedef PrefMember<double> DoublePrefMember; |
| 349 typedef PrefMember<std::string> StringPrefMember; | 349 typedef PrefMember<std::string> StringPrefMember; |
| 350 typedef PrefMember<base::FilePath> FilePathPrefMember; | 350 typedef PrefMember<base::FilePath> FilePathPrefMember; |
| 351 // This preference member is expensive for large string arrays. | 351 // This preference member is expensive for large string arrays. |
| 352 typedef PrefMember<std::vector<std::string> > StringListPrefMember; | 352 typedef PrefMember<std::vector<std::string> > StringListPrefMember; |
| 353 | 353 |
| 354 #endif // BASE_PREFS_PREF_MEMBER_H_ | 354 #endif // BASE_PREFS_PREF_MEMBER_H_ |
| OLD | NEW |