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