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

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

Issue 6520008: Device policy infrastructure (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix nits Created 9 years, 10 months 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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, NULL /* no observer */); 11 // my_string_.Init(prefs::kHomePage, prefs, NULL /* no observer */);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
185 } 185 }
186 186
187 // Set the value of the member variable if it is not managed. 187 // Set the value of the member variable if it is not managed.
188 // This method should only be called on the UI thread. 188 // This method should only be called on the UI thread.
189 void SetValueIfNotManaged(const ValueType& value) { 189 void SetValueIfNotManaged(const ValueType& value) {
190 if (!IsManaged()) { 190 if (!IsManaged()) {
191 SetValue(value); 191 SetValue(value);
192 } 192 }
193 } 193 }
194 194
195 // Returns the pref name.
196 const std::string& GetPrefName() const {
197 return pref_name();
198 }
199
195 private: 200 private:
196 class Internal : public subtle::PrefMemberBase::Internal { 201 class Internal : public subtle::PrefMemberBase::Internal {
197 public: 202 public:
198 Internal() : value_(ValueType()) {} 203 Internal() : value_(ValueType()) {}
199 204
200 ValueType value() { 205 ValueType value() {
201 CheckOnCorrectThread(); 206 CheckOnCorrectThread();
202 return value_; 207 return value_;
203 } 208 }
204 209
(...skipping 22 matching lines...) Expand all
227 DISALLOW_COPY_AND_ASSIGN(PrefMember); 232 DISALLOW_COPY_AND_ASSIGN(PrefMember);
228 }; 233 };
229 234
230 typedef PrefMember<bool> BooleanPrefMember; 235 typedef PrefMember<bool> BooleanPrefMember;
231 typedef PrefMember<int> IntegerPrefMember; 236 typedef PrefMember<int> IntegerPrefMember;
232 typedef PrefMember<double> DoublePrefMember; 237 typedef PrefMember<double> DoublePrefMember;
233 typedef PrefMember<std::string> StringPrefMember; 238 typedef PrefMember<std::string> StringPrefMember;
234 typedef PrefMember<FilePath> FilePathPrefMember; 239 typedef PrefMember<FilePath> FilePathPrefMember;
235 240
236 #endif // CHROME_BROWSER_PREFS_PREF_MEMBER_H_ 241 #endif // CHROME_BROWSER_PREFS_PREF_MEMBER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698