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 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 protected: | 266 protected: |
267 virtual ~Internal() {} | 267 virtual ~Internal() {} |
268 | 268 |
269 virtual BASE_PREFS_EXPORT bool UpdateValueInternal( | 269 virtual 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 DISALLOW_COPY_AND_ASSIGN(Internal); | 277 DISALLOW_COPY_AND_ASSIGN(Internal); |
277 }; | 278 }; |
278 | 279 |
279 virtual Internal* internal() const override { return internal_.get(); } | 280 virtual Internal* internal() const override { return internal_.get(); } |
280 virtual void CreateInternal() const override { internal_ = new Internal(); } | 281 virtual void CreateInternal() const override { internal_ = new Internal(); } |
281 | 282 |
282 // 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. |
283 void BASE_PREFS_EXPORT UpdatePref(const ValueType& value); | 284 void BASE_PREFS_EXPORT UpdatePref(const ValueType& value); |
284 | 285 |
285 mutable scoped_refptr<Internal> internal_; | 286 mutable scoped_refptr<Internal> internal_; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 349 |
349 typedef PrefMember<bool> BooleanPrefMember; | 350 typedef PrefMember<bool> BooleanPrefMember; |
350 typedef PrefMember<int> IntegerPrefMember; | 351 typedef PrefMember<int> IntegerPrefMember; |
351 typedef PrefMember<double> DoublePrefMember; | 352 typedef PrefMember<double> DoublePrefMember; |
352 typedef PrefMember<std::string> StringPrefMember; | 353 typedef PrefMember<std::string> StringPrefMember; |
353 typedef PrefMember<base::FilePath> FilePathPrefMember; | 354 typedef PrefMember<base::FilePath> FilePathPrefMember; |
354 // This preference member is expensive for large string arrays. | 355 // This preference member is expensive for large string arrays. |
355 typedef PrefMember<std::vector<std::string> > StringListPrefMember; | 356 typedef PrefMember<std::vector<std::string> > StringListPrefMember; |
356 | 357 |
357 #endif // BASE_PREFS_PREF_MEMBER_H_ | 358 #endif // BASE_PREFS_PREF_MEMBER_H_ |
OLD | NEW |