| 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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 virtual BASE_PREFS_EXPORT bool UpdateValueInternal( | 264 virtual BASE_PREFS_EXPORT bool UpdateValueInternal( |
| 265 const base::Value& value) const OVERRIDE; | 265 const base::Value& value) const OVERRIDE; |
| 266 | 266 |
| 267 // We cache the value of the pref so we don't have to keep walking the pref | 267 // We cache the value of the pref so we don't have to keep walking the pref |
| 268 // tree. | 268 // tree. |
| 269 mutable ValueType value_; | 269 mutable ValueType value_; |
| 270 | 270 |
| 271 DISALLOW_COPY_AND_ASSIGN(Internal); | 271 DISALLOW_COPY_AND_ASSIGN(Internal); |
| 272 }; | 272 }; |
| 273 | 273 |
| 274 virtual Internal* internal() const OVERRIDE { return internal_; } | 274 virtual Internal* internal() const OVERRIDE { return internal_.get(); } |
| 275 virtual void CreateInternal() const OVERRIDE { | 275 virtual void CreateInternal() const OVERRIDE { internal_ = new Internal(); } |
| 276 internal_ = new Internal(); | |
| 277 } | |
| 278 | 276 |
| 279 // This method is used to do the actual sync with pref of the specified type. | 277 // This method is used to do the actual sync with pref of the specified type. |
| 280 void BASE_PREFS_EXPORT UpdatePref(const ValueType& value); | 278 void BASE_PREFS_EXPORT UpdatePref(const ValueType& value); |
| 281 | 279 |
| 282 mutable scoped_refptr<Internal> internal_; | 280 mutable scoped_refptr<Internal> internal_; |
| 283 | 281 |
| 284 DISALLOW_COPY_AND_ASSIGN(PrefMember); | 282 DISALLOW_COPY_AND_ASSIGN(PrefMember); |
| 285 }; | 283 }; |
| 286 | 284 |
| 287 // Declaration of template specialization need to be repeated here | 285 // Declaration of template specialization need to be repeated here |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 343 |
| 346 typedef PrefMember<bool> BooleanPrefMember; | 344 typedef PrefMember<bool> BooleanPrefMember; |
| 347 typedef PrefMember<int> IntegerPrefMember; | 345 typedef PrefMember<int> IntegerPrefMember; |
| 348 typedef PrefMember<double> DoublePrefMember; | 346 typedef PrefMember<double> DoublePrefMember; |
| 349 typedef PrefMember<std::string> StringPrefMember; | 347 typedef PrefMember<std::string> StringPrefMember; |
| 350 typedef PrefMember<base::FilePath> FilePathPrefMember; | 348 typedef PrefMember<base::FilePath> FilePathPrefMember; |
| 351 // This preference member is expensive for large string arrays. | 349 // This preference member is expensive for large string arrays. |
| 352 typedef PrefMember<std::vector<std::string> > StringListPrefMember; | 350 typedef PrefMember<std::vector<std::string> > StringListPrefMember; |
| 353 | 351 |
| 354 #endif // BASE_PREFS_PREF_MEMBER_H_ | 352 #endif // BASE_PREFS_PREF_MEMBER_H_ |
| OLD | NEW |