Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: chrome/browser/api/prefs/pref_member.h

Issue 11293249: Remove PrefObserver usage, batch 3. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Make a couple of accessors public. Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « base/prefs/public/pref_change_registrar.cc ('k') | chrome/browser/chromeos/preferences.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 29 matching lines...) Expand all
40 class PrefServiceBase; 40 class PrefServiceBase;
41 41
42 namespace subtle { 42 namespace subtle {
43 43
44 class PrefMemberBase : public PrefObserver { 44 class PrefMemberBase : public PrefObserver {
45 public: 45 public:
46 // Type of callback you can register if you need to know the name of 46 // Type of callback you can register if you need to know the name of
47 // the pref that is changing. 47 // the pref that is changing.
48 typedef base::Callback<void(const std::string&)> NamedChangeCallback; 48 typedef base::Callback<void(const std::string&)> NamedChangeCallback;
49 49
50 const std::string& pref_name() const { return pref_name_; }
Mattias Nissler (ping if slow) 2012/11/13 15:47:03 Note that there already is a public GetPrefName in
Jói 2012/11/13 16:28:24 Right you are, sorry I didn't notice. Moved this
51 PrefServiceBase* prefs() { return prefs_; }
52 const PrefServiceBase* prefs() const { return prefs_; }
53
50 protected: 54 protected:
51 class Internal : public base::RefCountedThreadSafe<Internal> { 55 class Internal : public base::RefCountedThreadSafe<Internal> {
52 public: 56 public:
53 Internal(); 57 Internal();
54 58
55 // Update the value, either by calling |UpdateValueInternal| directly 59 // Update the value, either by calling |UpdateValueInternal| directly
56 // or by dispatching to the right thread. 60 // or by dispatching to the right thread.
57 // Takes ownership of |value|. 61 // Takes ownership of |value|.
58 void UpdateValue(base::Value* value, 62 void UpdateValue(base::Value* value,
59 bool is_managed, 63 bool is_managed,
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 121
118 // This method is used to do the actual sync with the preference. 122 // This method is used to do the actual sync with the preference.
119 // Note: it is logically const, because it doesn't modify the state 123 // Note: it is logically const, because it doesn't modify the state
120 // seen by the outside world. It is just doing a lazy load behind the scenes. 124 // seen by the outside world. It is just doing a lazy load behind the scenes.
121 void UpdateValueFromPref() const; 125 void UpdateValueFromPref() const;
122 126
123 // Verifies the preference name, and lazily loads the preference value if 127 // Verifies the preference name, and lazily loads the preference value if
124 // it hasn't been loaded yet. 128 // it hasn't been loaded yet.
125 void VerifyPref() const; 129 void VerifyPref() const;
126 130
127 const std::string& pref_name() const { return pref_name_; }
128 PrefServiceBase* prefs() { return prefs_; }
129 const PrefServiceBase* prefs() const { return prefs_; }
130
131 virtual Internal* internal() const = 0; 131 virtual Internal* internal() const = 0;
132 132
133 // Used to allow registering plain base::Closure callbacks. 133 // Used to allow registering plain base::Closure callbacks.
134 static void InvokeUnnamedCallback(const base::Closure& callback, 134 static void InvokeUnnamedCallback(const base::Closure& callback,
135 const std::string& pref_name); 135 const std::string& pref_name);
136 136
137 private: 137 private:
138 // Ordered the members to compact the class instance. 138 // Ordered the members to compact the class instance.
139 std::string pref_name_; 139 std::string pref_name_;
140 NamedChangeCallback observer_; 140 NamedChangeCallback observer_;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 290
291 typedef PrefMember<bool> BooleanPrefMember; 291 typedef PrefMember<bool> BooleanPrefMember;
292 typedef PrefMember<int> IntegerPrefMember; 292 typedef PrefMember<int> IntegerPrefMember;
293 typedef PrefMember<double> DoublePrefMember; 293 typedef PrefMember<double> DoublePrefMember;
294 typedef PrefMember<std::string> StringPrefMember; 294 typedef PrefMember<std::string> StringPrefMember;
295 typedef PrefMember<FilePath> FilePathPrefMember; 295 typedef PrefMember<FilePath> FilePathPrefMember;
296 // This preference member is expensive for large string arrays. 296 // This preference member is expensive for large string arrays.
297 typedef PrefMember<std::vector<std::string> > StringListPrefMember; 297 typedef PrefMember<std::vector<std::string> > StringListPrefMember;
298 298
299 #endif // CHROME_BROWSER_API_PREFS_PREF_MEMBER_H_ 299 #endif // CHROME_BROWSER_API_PREFS_PREF_MEMBER_H_
OLDNEW
« no previous file with comments | « base/prefs/public/pref_change_registrar.cc ('k') | chrome/browser/chromeos/preferences.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698