Chromium Code Reviews

Side by Side Diff: chrome/browser/sync/glue/preference_change_processor.cc

Issue 3304015: Use PrefChangeRegistrar everywhere (Closed)
Patch Set: final version for commit Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/sync/glue/preference_change_processor.h" 5 #include "chrome/browser/sync/glue/preference_change_processor.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 177 matching lines...)
188 error_handler()->OnUnrecoverableError(FROM_HERE, err); 188 error_handler()->OnUnrecoverableError(FROM_HERE, err);
189 return NULL; 189 return NULL;
190 } 190 }
191 *name = preference.name(); 191 *name = preference.name();
192 return value.release(); 192 return value.release();
193 } 193 }
194 194
195 void PreferenceChangeProcessor::StartImpl(Profile* profile) { 195 void PreferenceChangeProcessor::StartImpl(Profile* profile) {
196 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 196 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
197 pref_service_ = profile->GetPrefs(); 197 pref_service_ = profile->GetPrefs();
198 registrar_.Init(pref_service_);
198 StartObserving(); 199 StartObserving();
199 } 200 }
200 201
201 void PreferenceChangeProcessor::StopImpl() { 202 void PreferenceChangeProcessor::StopImpl() {
202 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI)); 203 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
203 StopObserving(); 204 StopObserving();
204 pref_service_ = NULL; 205 pref_service_ = NULL;
205 } 206 }
206 207
207 208
208 void PreferenceChangeProcessor::StartObserving() { 209 void PreferenceChangeProcessor::StartObserving() {
209 DCHECK(pref_service_); 210 DCHECK(pref_service_);
210 for (std::set<std::string>::const_iterator it = 211 for (std::set<std::string>::const_iterator it =
211 model_associator_->synced_preferences().begin(); 212 model_associator_->synced_preferences().begin();
212 it != model_associator_->synced_preferences().end(); ++it) { 213 it != model_associator_->synced_preferences().end(); ++it) {
213 pref_service_->AddPrefObserver((*it).c_str(), this); 214 registrar_.Add((*it).c_str(), this);
214 } 215 }
215 } 216 }
216 217
217 void PreferenceChangeProcessor::StopObserving() { 218 void PreferenceChangeProcessor::StopObserving() {
218 DCHECK(pref_service_); 219 DCHECK(pref_service_);
219 for (std::set<std::string>::const_iterator it = 220 for (std::set<std::string>::const_iterator it =
220 model_associator_->synced_preferences().begin(); 221 model_associator_->synced_preferences().begin();
221 it != model_associator_->synced_preferences().end(); ++it) { 222 it != model_associator_->synced_preferences().end(); ++it) {
222 pref_service_->RemovePrefObserver((*it).c_str(), this); 223 registrar_.Remove((*it).c_str(), this);
223 } 224 }
224 } 225 }
225 226
226 } // namespace browser_sync 227 } // namespace browser_sync
OLDNEW
« no previous file with comments | « chrome/browser/sync/glue/preference_change_processor.h ('k') | chrome/browser/tab_contents/tab_contents.h » ('j') | no next file with comments »

Powered by Google App Engine