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) { |
11 // my_string_.Init(prefs::kHomePage, prefs); | 11 // my_string_.Init(prefs::kHomePage, prefs); |
12 // } | 12 // } |
13 // private: | 13 // private: |
14 // StringPrefMember my_string_; | 14 // StringPrefMember my_string_; |
15 // }; | 15 // }; |
16 // | 16 // |
17 // my_string_ should stay in sync with the prefs::kHomePage pref and will | 17 // my_string_ should stay in sync with the prefs::kHomePage pref and will |
18 // update if either the pref changes or if my_string_.SetValue is called. | 18 // update if either the pref changes or if my_string_.SetValue is called. |
19 // | 19 // |
20 // An optional observer can be passed into the Init method which can be used to | 20 // An optional observer can be passed into the Init method which can be used to |
21 // notify MyClass of changes. Note that if you use SetValue(), the observer | 21 // notify MyClass of changes. Note that if you use SetValue(), the observer |
22 // will not be notified. | 22 // will not be notified. |
23 | 23 |
24 #ifndef BASE_PREFS_PREF_MEMBER_H_ | 24 #ifndef BASE_PREFS_PREF_MEMBER_H_ |
25 #define BASE_PREFS_PREF_MEMBER_H_ | 25 #define BASE_PREFS_PREF_MEMBER_H_ |
26 | 26 |
27 #include <string> | 27 #include <string> |
28 #include <vector> | 28 #include <vector> |
29 | 29 |
30 #include "base/basictypes.h" | |
31 #include "base/bind.h" | 30 #include "base/bind.h" |
32 #include "base/callback_forward.h" | 31 #include "base/callback_forward.h" |
33 #include "base/files/file_path.h" | 32 #include "base/files/file_path.h" |
34 #include "base/logging.h" | 33 #include "base/logging.h" |
| 34 #include "base/macros.h" |
35 #include "base/memory/ref_counted.h" | 35 #include "base/memory/ref_counted.h" |
36 #include "base/prefs/base_prefs_export.h" | 36 #include "base/prefs/base_prefs_export.h" |
37 #include "base/prefs/pref_observer.h" | 37 #include "base/prefs/pref_observer.h" |
38 #include "base/single_thread_task_runner.h" | 38 #include "base/single_thread_task_runner.h" |
39 #include "base/values.h" | 39 #include "base/values.h" |
40 | 40 |
41 class PrefService; | 41 class PrefService; |
42 | 42 |
43 namespace subtle { | 43 namespace subtle { |
44 | 44 |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
346 | 346 |
347 typedef PrefMember<bool> BooleanPrefMember; | 347 typedef PrefMember<bool> BooleanPrefMember; |
348 typedef PrefMember<int> IntegerPrefMember; | 348 typedef PrefMember<int> IntegerPrefMember; |
349 typedef PrefMember<double> DoublePrefMember; | 349 typedef PrefMember<double> DoublePrefMember; |
350 typedef PrefMember<std::string> StringPrefMember; | 350 typedef PrefMember<std::string> StringPrefMember; |
351 typedef PrefMember<base::FilePath> FilePathPrefMember; | 351 typedef PrefMember<base::FilePath> FilePathPrefMember; |
352 // This preference member is expensive for large string arrays. | 352 // This preference member is expensive for large string arrays. |
353 typedef PrefMember<std::vector<std::string> > StringListPrefMember; | 353 typedef PrefMember<std::vector<std::string> > StringListPrefMember; |
354 | 354 |
355 #endif // BASE_PREFS_PREF_MEMBER_H_ | 355 #endif // BASE_PREFS_PREF_MEMBER_H_ |
OLD | NEW |