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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 DCHECK(IsOnCorrectThread()); | 85 DCHECK(IsOnCorrectThread()); |
86 } | 86 } |
87 | 87 |
88 private: | 88 private: |
89 // This method actually updates the value. It should only be called from | 89 // This method actually updates the value. It should only be called from |
90 // the thread the PrefMember is on. | 90 // the thread the PrefMember is on. |
91 virtual bool UpdateValueInternal(const base::Value& value) const = 0; | 91 virtual bool UpdateValueInternal(const base::Value& value) const = 0; |
92 | 92 |
93 bool IsOnCorrectThread() const; | 93 bool IsOnCorrectThread() const; |
94 | 94 |
95 scoped_refptr<base::SingleThreadTaskRunner> thread_loop_; | 95 scoped_refptr<base::SingleThreadTaskRunner> thread_task_runner_; |
96 mutable bool is_managed_; | 96 mutable bool is_managed_; |
97 mutable bool is_user_modifiable_; | 97 mutable bool is_user_modifiable_; |
98 | 98 |
99 DISALLOW_COPY_AND_ASSIGN(Internal); | 99 DISALLOW_COPY_AND_ASSIGN(Internal); |
100 }; | 100 }; |
101 | 101 |
102 PrefMemberBase(); | 102 PrefMemberBase(); |
103 virtual ~PrefMemberBase(); | 103 virtual ~PrefMemberBase(); |
104 | 104 |
105 // See PrefMember<> for description. | 105 // See PrefMember<> for description. |
(...skipping 243 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 |