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

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

Issue 11316163: Remove the last usages of PrefObserver outside of Prefs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments. Created 8 years 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) 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 #include "chrome/browser/api/prefs/pref_member.h" 5 #include "chrome/browser/api/prefs/pref_member.h"
6 6
7 #include "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "base/prefs/public/pref_service_base.h" 10 #include "base/prefs/public/pref_service_base.h"
11 #include "base/value_conversions.h" 11 #include "base/value_conversions.h"
12 12
13 using base::MessageLoopProxy; 13 using base::MessageLoopProxy;
14 14
15 namespace subtle { 15 namespace subtle {
16 16
17 PrefMemberBase::PrefMemberBase() 17 PrefMemberBase::PrefMemberBase()
18 : prefs_(NULL), 18 : prefs_(NULL),
19 setting_value_(false) { 19 setting_value_(false) {
20 } 20 }
21 21
22 PrefMemberBase::~PrefMemberBase() { 22 PrefMemberBase::~PrefMemberBase() {
23 Destroy(); 23 Destroy();
24 } 24 }
25 25
26 void PrefMemberBase::Init(const char* pref_name, 26 void PrefMemberBase::Init(const char* pref_name,
27 PrefServiceBase* prefs, 27 PrefServiceBase* prefs,
28 const NamedChangeCallback& observer) { 28 const NamedChangeCallback& observer) {
29 observer_ = observer;
30 Init(pref_name, prefs);
31 }
32
33 void PrefMemberBase::Init(const char* pref_name,
34 PrefServiceBase* prefs) {
29 DCHECK(pref_name); 35 DCHECK(pref_name);
30 DCHECK(prefs); 36 DCHECK(prefs);
31 DCHECK(pref_name_.empty()); // Check that Init is only called once. 37 DCHECK(pref_name_.empty()); // Check that Init is only called once.
32 prefs_ = prefs; 38 prefs_ = prefs;
33 pref_name_ = pref_name; 39 pref_name_ = pref_name;
34 observer_ = observer;
35 // Check that the preference is registered. 40 // Check that the preference is registered.
36 DCHECK(prefs_->FindPreference(pref_name_.c_str())) 41 DCHECK(prefs_->FindPreference(pref_name_.c_str()))
37 << pref_name << " not registered."; 42 << pref_name << " not registered.";
38 43
39 // Add ourselves as a pref observer so we can keep our local value in sync. 44 // Add ourselves as a pref observer so we can keep our local value in sync.
40 prefs_->AddPrefObserver(pref_name, this); 45 prefs_->AddPrefObserver(pref_name, this);
41 } 46 }
42 47
43 void PrefMemberBase::Destroy() { 48 void PrefMemberBase::Destroy() {
44 if (prefs_ && !pref_name_.empty()) { 49 if (prefs_ && !pref_name_.empty()) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 ListValue list_value; 211 ListValue list_value;
207 list_value.AppendStrings(value); 212 list_value.AppendStrings(value);
208 prefs()->Set(pref_name().c_str(), list_value); 213 prefs()->Set(pref_name().c_str(), list_value);
209 } 214 }
210 215
211 template <> 216 template <>
212 bool PrefMember<std::vector<std::string> >::Internal::UpdateValueInternal( 217 bool PrefMember<std::vector<std::string> >::Internal::UpdateValueInternal(
213 const Value& value) const { 218 const Value& value) const {
214 return subtle::PrefMemberVectorStringUpdate(value, &value_); 219 return subtle::PrefMemberVectorStringUpdate(value, &value_);
215 } 220 }
OLDNEW
« no previous file with comments | « chrome/browser/api/prefs/pref_member.h ('k') | chrome/browser/api/prefs/pref_member_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698