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

Side by Side Diff: chrome/browser/prefs/pref_model_associator.cc

Issue 24930003: Migrate startup URLs pref. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add rather than update previously unseen migrated prefs. Created 7 years, 2 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) 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/prefs/pref_model_associator.h" 5 #include "chrome/browser/prefs/pref_model_associator.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/json/json_reader.h" 8 #include "base/json/json_reader.h"
9 #include "base/json/json_string_value_serializer.h" 9 #include "base/json/json_string_value_serializer.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 30 matching lines...) Expand all
41 sync_pb::EntitySpecifics* specifics) { 41 sync_pb::EntitySpecifics* specifics) {
42 if (type == syncer::PRIORITY_PREFERENCES) { 42 if (type == syncer::PRIORITY_PREFERENCES) {
43 DCHECK(!specifics->has_preference()); 43 DCHECK(!specifics->has_preference());
44 return specifics->mutable_priority_preference()->mutable_preference(); 44 return specifics->mutable_priority_preference()->mutable_preference();
45 } else { 45 } else {
46 DCHECK(!specifics->has_priority_preference()); 46 DCHECK(!specifics->has_priority_preference());
47 return specifics->mutable_preference(); 47 return specifics->mutable_preference();
48 } 48 }
49 } 49 }
50 50
51 // List of migrated preference name pairs. If a preference is migrated
52 // (meaning renamed) adding the old and new preference names here will ensure
53 // that the sync engine knows how to deal with the synced values coming in
54 // with the old name. Preference migration itself doesn't happen here. It may
55 // happen in session_startup_pref.cc.
56 const struct MigratedPreferences {
57 const char* const old_name;
58 const char* const new_name;
59 } kMigratedPreferences[] = {
60 { prefs::kURLsToRestoreOnStartupOld, prefs::kURLsToRestoreOnStartup },
61 };
62
63 std::string GetOldMigratedPreferenceName(const char* preference_name) {
64 for (size_t i = 0; i < arraysize(kMigratedPreferences); ++i) {
65 if (!strcmp(kMigratedPreferences[i].new_name, preference_name))
66 return kMigratedPreferences[i].old_name;
67 }
68 return std::string();
69 }
70
71 std::string GetNewMigratedPreferenceName(const char* old_preference_name) {
72 for (size_t i = 0; i < arraysize(kMigratedPreferences); ++i) {
73 if (!strcmp(kMigratedPreferences[i].old_name, old_preference_name))
74 return kMigratedPreferences[i].new_name;
75 }
76 return std::string();
77 }
78
79 bool IsMigratedPreference(const char* preference_name) {
80 return !GetOldMigratedPreferenceName(preference_name).empty();
81 }
82
83 bool IsOldMigratedPreference(const char* old_preference_name) {
84 return !GetNewMigratedPreferenceName(old_preference_name).empty();
85 }
86
51 } // namespace 87 } // namespace
52 88
53 PrefModelAssociator::PrefModelAssociator(syncer::ModelType type) 89 PrefModelAssociator::PrefModelAssociator(syncer::ModelType type)
54 : models_associated_(false), 90 : models_associated_(false),
55 processing_syncer_changes_(false), 91 processing_syncer_changes_(false),
56 pref_service_(NULL), 92 pref_service_(NULL),
57 type_(type) { 93 type_(type) {
58 DCHECK(CalledOnValidThread()); 94 DCHECK(CalledOnValidThread());
59 DCHECK(type_ == PREFERENCES || type_ == PRIORITY_PREFERENCES); 95 DCHECK(type_ == PREFERENCES || type_ == PRIORITY_PREFERENCES);
60 } 96 }
61 97
62 PrefModelAssociator::~PrefModelAssociator() { 98 PrefModelAssociator::~PrefModelAssociator() {
63 DCHECK(CalledOnValidThread()); 99 DCHECK(CalledOnValidThread());
64 pref_service_ = NULL; 100 pref_service_ = NULL;
65 101
66 STLDeleteContainerPairSecondPointers(synced_pref_observers_.begin(), 102 STLDeleteContainerPairSecondPointers(synced_pref_observers_.begin(),
67 synced_pref_observers_.end()); 103 synced_pref_observers_.end());
68 synced_pref_observers_.clear(); 104 synced_pref_observers_.clear();
69 } 105 }
70 106
71 void PrefModelAssociator::InitPrefAndAssociate( 107 void PrefModelAssociator::InitPrefAndAssociate(
72 const syncer::SyncData& sync_pref, 108 const syncer::SyncData& sync_pref,
73 const std::string& pref_name, 109 const std::string& pref_name,
74 syncer::SyncChangeList* sync_changes) { 110 syncer::SyncChangeList* sync_changes,
111 SyncDataPrefList* migrated_preference_list) {
75 const Value* user_pref_value = pref_service_->GetUserPrefValue( 112 const Value* user_pref_value = pref_service_->GetUserPrefValue(
76 pref_name.c_str()); 113 pref_name.c_str());
77 VLOG(1) << "Associating preference " << pref_name; 114 VLOG(1) << "Associating preference " << pref_name;
78 115
79 if (sync_pref.IsValid()) { 116 if (sync_pref.IsValid()) {
80 const sync_pb::PreferenceSpecifics& preference = GetSpecifics(sync_pref); 117 const sync_pb::PreferenceSpecifics& preference = GetSpecifics(sync_pref);
81 DCHECK_EQ(pref_name, preference.name()); 118 DCHECK(pref_name == preference.name() ||
82 119 (IsMigratedPreference(pref_name.c_str()) &&
120 preference.name() ==
121 GetOldMigratedPreferenceName(pref_name.c_str())));
83 base::JSONReader reader; 122 base::JSONReader reader;
84 scoped_ptr<Value> sync_value(reader.ReadToValue(preference.value())); 123 scoped_ptr<Value> sync_value(reader.ReadToValue(preference.value()));
85 if (!sync_value.get()) { 124 if (!sync_value.get()) {
86 LOG(ERROR) << "Failed to deserialize preference value: " 125 LOG(ERROR) << "Failed to deserialize preference value: "
87 << reader.GetErrorMessage(); 126 << reader.GetErrorMessage();
88 return; 127 return;
89 } 128 }
90 129
91 if (user_pref_value) { 130 if (user_pref_value) {
92 // We have both server and local values. Merge them. 131 // We have both server and local values. Merge them.
(...skipping 19 matching lines...) Expand all
112 if (!sync_value->Equals(new_value.get())) { 151 if (!sync_value->Equals(new_value.get())) {
113 syncer::SyncData sync_data; 152 syncer::SyncData sync_data;
114 if (!CreatePrefSyncData(pref_name, *new_value, &sync_data)) { 153 if (!CreatePrefSyncData(pref_name, *new_value, &sync_data)) {
115 LOG(ERROR) << "Failed to update preference."; 154 LOG(ERROR) << "Failed to update preference.";
116 return; 155 return;
117 } 156 }
118 sync_changes->push_back( 157 sync_changes->push_back(
119 syncer::SyncChange(FROM_HERE, 158 syncer::SyncChange(FROM_HERE,
120 syncer::SyncChange::ACTION_UPDATE, 159 syncer::SyncChange::ACTION_UPDATE,
121 sync_data)); 160 sync_data));
161 // This preference has been migrated from an old version that must be
162 // kept in sync on older versions of Chrome.
163 if (IsMigratedPreference(pref_name.c_str()) &&
164 migrated_preference_list) {
165 if (!CreatePrefSyncData(
166 GetOldMigratedPreferenceName(pref_name.c_str()),
167 *new_value,
168 &sync_data)) {
169 LOG(ERROR) << "Failed to update preference.";
170 return;
171 }
172
173 migrated_preference_list->push_back(
174 std::make_pair(GetOldMigratedPreferenceName(pref_name.c_str()),
175 sync_data));
176 }
122 } 177 }
123 } else if (!sync_value->IsType(Value::TYPE_NULL)) { 178 } else if (!sync_value->IsType(Value::TYPE_NULL)) {
124 // Only a server value exists. Just set the local user value. 179 // Only a server value exists. Just set the local user value.
125 pref_service_->Set(pref_name.c_str(), *sync_value); 180 pref_service_->Set(pref_name.c_str(), *sync_value);
126 } else { 181 } else {
127 LOG(WARNING) << "Sync has null value for pref " << pref_name.c_str(); 182 LOG(WARNING) << "Sync has null value for pref " << pref_name.c_str();
128 } 183 }
129 } else if (user_pref_value) { 184 } else if (user_pref_value) {
130 // The server does not know about this preference and should be added 185 // The server does not know about this preference and should be added
131 // to the syncer's database. 186 // to the syncer's database.
132 syncer::SyncData sync_data; 187 syncer::SyncData sync_data;
133 if (!CreatePrefSyncData(pref_name, *user_pref_value, &sync_data)) { 188 if (!CreatePrefSyncData(pref_name, *user_pref_value, &sync_data)) {
134 LOG(ERROR) << "Failed to update preference."; 189 LOG(ERROR) << "Failed to update preference.";
135 return; 190 return;
136 } 191 }
137 sync_changes->push_back( 192 sync_changes->push_back(
138 syncer::SyncChange(FROM_HERE, 193 syncer::SyncChange(FROM_HERE,
139 syncer::SyncChange::ACTION_ADD, 194 syncer::SyncChange::ACTION_ADD,
140 sync_data)); 195 sync_data));
141 } else { 196 } else {
142 // This pref does not have a sync value but also does not have a user 197 // This pref does not have a sync value but also does not have a user
143 // controlled value (either it's a default value or it's policy controlled, 198 // controlled value (either it's a default value or it's policy controlled,
144 // either way it's not interesting). We can ignore it. Once it gets changed, 199 // either way it's not interesting). We can ignore it. Once it gets changed,
145 // we'll send the new user controlled value to the syncer. 200 // we'll send the new user controlled value to the syncer.
146 return; 201 return;
147 } 202 }
148 203
149 // Make sure we add it to our list of synced preferences so we know what 204 // Make sure we add it to our list of synced preferences so we know what
150 // the server is aware of. 205 // the server is aware of.
151 synced_preferences_.insert(pref_name); 206 synced_preferences_.insert(pref_name);
Nicolas Zea 2013/10/10 17:44:14 I don't think this will ever add the old pref name
robertshield 2013/10/10 20:06:21 Ah true, the pref will still get synced but subseq
Nicolas Zea 2013/10/10 20:35:09 Basically, if the preference sync is passing to th
robertshield 2013/10/11 18:29:31 Done.
152 return; 207 return;
153 } 208 }
154 209
155 syncer::SyncMergeResult PrefModelAssociator::MergeDataAndStartSyncing( 210 syncer::SyncMergeResult PrefModelAssociator::MergeDataAndStartSyncing(
156 syncer::ModelType type, 211 syncer::ModelType type,
157 const syncer::SyncDataList& initial_sync_data, 212 const syncer::SyncDataList& initial_sync_data,
158 scoped_ptr<syncer::SyncChangeProcessor> sync_processor, 213 scoped_ptr<syncer::SyncChangeProcessor> sync_processor,
159 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) { 214 scoped_ptr<syncer::SyncErrorFactory> sync_error_factory) {
160 DCHECK_EQ(type_, type); 215 DCHECK_EQ(type_, type);
161 DCHECK(CalledOnValidThread()); 216 DCHECK(CalledOnValidThread());
162 DCHECK(pref_service_); 217 DCHECK(pref_service_);
163 DCHECK(!sync_processor_.get()); 218 DCHECK(!sync_processor_.get());
164 DCHECK(sync_processor.get()); 219 DCHECK(sync_processor.get());
165 DCHECK(sync_error_factory.get()); 220 DCHECK(sync_error_factory.get());
166 syncer::SyncMergeResult merge_result(type); 221 syncer::SyncMergeResult merge_result(type);
167 sync_processor_ = sync_processor.Pass(); 222 sync_processor_ = sync_processor.Pass();
168 sync_error_factory_ = sync_error_factory.Pass(); 223 sync_error_factory_ = sync_error_factory.Pass();
169 224
170 syncer::SyncChangeList new_changes; 225 syncer::SyncChangeList new_changes;
171 std::set<std::string> remaining_preferences = registered_preferences_; 226 std::set<std::string> remaining_preferences = registered_preferences_;
172 227
228 // Maintains a list of old migrated preference names that we wish to sync.
229 // Keep track of these in a list such that when the preference iteration
230 // loops below are complete we can go back and determine whether
231 SyncDataPrefList migrated_preference_list;
232
173 // Go through and check for all preferences we care about that sync already 233 // Go through and check for all preferences we care about that sync already
174 // knows about. 234 // knows about.
175 for (syncer::SyncDataList::const_iterator sync_iter = 235 for (syncer::SyncDataList::const_iterator sync_iter =
176 initial_sync_data.begin(); 236 initial_sync_data.begin();
177 sync_iter != initial_sync_data.end(); 237 sync_iter != initial_sync_data.end();
178 ++sync_iter) { 238 ++sync_iter) {
179 DCHECK_EQ(type_, sync_iter->GetDataType()); 239 DCHECK_EQ(type_, sync_iter->GetDataType());
180 240
181 const sync_pb::PreferenceSpecifics& preference = GetSpecifics(*sync_iter); 241 const sync_pb::PreferenceSpecifics& preference = GetSpecifics(*sync_iter);
182 const std::string& sync_pref_name = preference.name(); 242 std::string sync_pref_name = preference.name();
183 243
184 if (remaining_preferences.count(sync_pref_name) == 0) { 244 if (remaining_preferences.count(sync_pref_name) == 0) {
185 // We're not syncing this preference locally, ignore the sync data. 245 if (IsOldMigratedPreference(sync_pref_name.c_str())) {
186 // TODO(zea): Eventually we want to be able to have the syncable service 246 // This old pref name is not syncable locally anymore but we accept
187 // reconstruct all sync data for it's datatype (therefore having 247 // changes from other Chrome installs of previous versions and migrate
188 // GetAllSyncData be a complete representation). We should store this data 248 // them to the new name. Note that we will be merging any differences
189 // somewhere, even if we don't use it. 249 // between the new and old values and sync'ing them back.
190 continue; 250 sync_pref_name = GetNewMigratedPreferenceName(sync_pref_name.c_str());
251 } else {
252 // We're not syncing this preference locally, ignore the sync data.
253 // TODO(zea): Eventually we want to be able to have the syncable service
254 // reconstruct all sync data for its datatype (therefore having
255 // GetAllSyncData be a complete representation). We should store this
256 // data somewhere, even if we don't use it.
257 continue;
258 }
259 } else {
260 remaining_preferences.erase(sync_pref_name);
191 } 261 }
192 262 InitPrefAndAssociate(*sync_iter, sync_pref_name, &new_changes,
193 remaining_preferences.erase(sync_pref_name); 263 &migrated_preference_list);
194 InitPrefAndAssociate(*sync_iter, sync_pref_name, &new_changes);
195 } 264 }
196 265
197 // Go through and build sync data for any remaining preferences. 266 // Go through and build sync data for any remaining preferences.
198 for (std::set<std::string>::iterator pref_name_iter = 267 for (std::set<std::string>::iterator pref_name_iter =
199 remaining_preferences.begin(); 268 remaining_preferences.begin();
200 pref_name_iter != remaining_preferences.end(); 269 pref_name_iter != remaining_preferences.end();
201 ++pref_name_iter) { 270 ++pref_name_iter) {
202 InitPrefAndAssociate(syncer::SyncData(), *pref_name_iter, &new_changes); 271 InitPrefAndAssociate(syncer::SyncData(), *pref_name_iter, &new_changes,
272 &migrated_preference_list);
273 }
274
275 // Now go over any migrated preference names and build sync data for them too.
276 for (SyncDataPrefList::const_iterator migrated_pref_iter =
277 migrated_preference_list.begin();
278 migrated_pref_iter != migrated_preference_list.end();
279 ++migrated_pref_iter) {
280 syncer::SyncChange::SyncChangeType change_type =
281 (synced_preferences_.count(migrated_pref_iter->first) == 0) ?
282 syncer::SyncChange::ACTION_ADD :
283 syncer::SyncChange::ACTION_UPDATE;
284 new_changes.push_back(
285 syncer::SyncChange(FROM_HERE, change_type, migrated_pref_iter->second));
203 } 286 }
204 287
205 // Push updates to sync. 288 // Push updates to sync.
206 merge_result.set_error( 289 merge_result.set_error(
207 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes)); 290 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes));
208 if (merge_result.error().IsSet()) 291 if (merge_result.error().IsSet())
209 return merge_result; 292 return merge_result;
210 293
211 models_associated_ = true; 294 models_associated_ = true;
212 pref_service_->OnIsSyncingChanged(); 295 pref_service_->OnIsSyncingChanged();
213 return merge_result; 296 return merge_result;
214 } 297 }
215 298
216 void PrefModelAssociator::StopSyncing(syncer::ModelType type) { 299 void PrefModelAssociator::StopSyncing(syncer::ModelType type) {
217 DCHECK_EQ(type_, type); 300 DCHECK_EQ(type_, type);
218 models_associated_ = false; 301 models_associated_ = false;
219 sync_processor_.reset(); 302 sync_processor_.reset();
220 sync_error_factory_.reset(); 303 sync_error_factory_.reset();
221 pref_service_->OnIsSyncingChanged(); 304 pref_service_->OnIsSyncingChanged();
222 } 305 }
223 306
224 scoped_ptr<Value> PrefModelAssociator::MergePreference( 307 scoped_ptr<Value> PrefModelAssociator::MergePreference(
225 const std::string& name, 308 const std::string& name,
226 const Value& local_value, 309 const Value& local_value,
227 const Value& server_value) { 310 const Value& server_value) {
228 if (name == prefs::kURLsToRestoreOnStartup) { 311 // This function special cases preferences individually, so don't attempt
312 // to merge for all migrated values.
313 if (name == prefs::kURLsToRestoreOnStartup ||
314 name == prefs::kURLsToRestoreOnStartupOld) {
229 return scoped_ptr<Value>(MergeListValues(local_value, server_value)).Pass(); 315 return scoped_ptr<Value>(MergeListValues(local_value, server_value)).Pass();
230 } 316 }
231 317
232 if (name == prefs::kContentSettingsPatternPairs) { 318 if (name == prefs::kContentSettingsPatternPairs) {
233 return scoped_ptr<Value>( 319 return scoped_ptr<Value>(
234 MergeDictionaryValues(local_value, server_value)).Pass(); 320 MergeDictionaryValues(local_value, server_value)).Pass();
235 } 321 }
236 322
237 // If this is not a specially handled preference, server wins. 323 // If this is not a specially handled preference, server wins.
238 return scoped_ptr<Value>(server_value.DeepCopy()).Pass(); 324 return scoped_ptr<Value>(server_value.DeepCopy()).Pass();
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // TODO(zea): consider taking some further action such as erasing the bad 467 // TODO(zea): consider taking some further action such as erasing the bad
382 // data. 468 // data.
383 if (!value.get()) 469 if (!value.get())
384 continue; 470 continue;
385 471
386 // It is possible that we may receive a change to a preference we do not 472 // It is possible that we may receive a change to a preference we do not
387 // want to sync. For example if the user is syncing a Mac client and a 473 // want to sync. For example if the user is syncing a Mac client and a
388 // Windows client, the Windows client does not support 474 // Windows client, the Windows client does not support
389 // kConfirmToQuitEnabled. Ignore updates from these preferences. 475 // kConfirmToQuitEnabled. Ignore updates from these preferences.
390 const char* pref_name = name.c_str(); 476 const char* pref_name = name.c_str();
477 std::string new_name;
478 // We migrated this preference name, so do as if the name had not changed.
479 if (IsOldMigratedPreference(pref_name)) {
480 new_name = GetNewMigratedPreferenceName(pref_name);
481 pref_name = new_name.c_str();
482 }
483
391 if (!IsPrefRegistered(pref_name)) 484 if (!IsPrefRegistered(pref_name))
392 continue; 485 continue;
393 486
394 const PrefService::Preference* pref = 487 const PrefService::Preference* pref =
395 pref_service_->FindPreference(pref_name); 488 pref_service_->FindPreference(pref_name);
396 DCHECK(pref); 489 DCHECK(pref);
397 490
398 // This will only modify the user controlled value store, which takes 491 // This will only modify the user controlled value store, which takes
399 // priority over the default value but is ignored if the preference is 492 // priority over the default value but is ignored if the preference is
400 // policy controlled. 493 // policy controlled.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } 582 }
490 583
491 base::AutoReset<bool> processing_changes(&processing_syncer_changes_, true); 584 base::AutoReset<bool> processing_changes(&processing_syncer_changes_, true);
492 585
493 NotifySyncedPrefObservers(name, false /*from_sync*/); 586 NotifySyncedPrefObservers(name, false /*from_sync*/);
494 587
495 if (synced_preferences_.count(name) == 0) { 588 if (synced_preferences_.count(name) == 0) {
496 // Not in synced_preferences_ means no synced data. InitPrefAndAssociate(..) 589 // Not in synced_preferences_ means no synced data. InitPrefAndAssociate(..)
497 // will determine if we care about its data (e.g. if it has a default value 590 // will determine if we care about its data (e.g. if it has a default value
498 // and hasn't been changed yet we don't) and take care syncing any new data. 591 // and hasn't been changed yet we don't) and take care syncing any new data.
499 InitPrefAndAssociate(syncer::SyncData(), name, &changes); 592 InitPrefAndAssociate(syncer::SyncData(), name, &changes, NULL);
500 } else { 593 } else {
501 // We are already syncing this preference, just update it's sync node. 594 // We are already syncing this preference, just update it's sync node.
502 syncer::SyncData sync_data; 595 syncer::SyncData sync_data;
503 if (!CreatePrefSyncData(name, *preference->GetValue(), &sync_data)) { 596 if (!CreatePrefSyncData(name, *preference->GetValue(), &sync_data)) {
504 LOG(ERROR) << "Failed to update preference."; 597 LOG(ERROR) << "Failed to update preference.";
505 return; 598 return;
506 } 599 }
507 changes.push_back( 600 changes.push_back(
508 syncer::SyncChange(FROM_HERE, 601 syncer::SyncChange(FROM_HERE,
509 syncer::SyncChange::ACTION_UPDATE, 602 syncer::SyncChange::ACTION_UPDATE,
510 sync_data)); 603 sync_data));
604 // This preference has been migrated from an old version that must be kept
605 // in sync on older versions of Chrome.
606 if (IsMigratedPreference(name.c_str())) {
607 std::string old_pref_name = GetOldMigratedPreferenceName(name.c_str());
608 if (!CreatePrefSyncData(old_pref_name,
609 *preference->GetValue(),
610 &sync_data)) {
611 LOG(ERROR) << "Failed to update preference.";
612 return;
613 }
614
615 syncer::SyncChange::SyncChangeType change_type =
616 (synced_preferences_.count(name) == 0) ?
617 syncer::SyncChange::ACTION_ADD :
618 syncer::SyncChange::ACTION_UPDATE;
619 changes.push_back(
620 syncer::SyncChange(FROM_HERE, change_type, sync_data));
621 }
511 } 622 }
512 623
513 syncer::SyncError error = 624 syncer::SyncError error =
514 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); 625 sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
515 } 626 }
516 627
517 void PrefModelAssociator::SetPrefService(PrefServiceSyncable* pref_service) { 628 void PrefModelAssociator::SetPrefService(PrefServiceSyncable* pref_service) {
518 DCHECK(pref_service_ == NULL); 629 DCHECK(pref_service_ == NULL);
519 pref_service_ = pref_service; 630 pref_service_ = pref_service;
520 } 631 }
521 632
522 void PrefModelAssociator::NotifySyncedPrefObservers(const std::string& path, 633 void PrefModelAssociator::NotifySyncedPrefObservers(const std::string& path,
523 bool from_sync) const { 634 bool from_sync) const {
524 SyncedPrefObserverMap::const_iterator observer_iter = 635 SyncedPrefObserverMap::const_iterator observer_iter =
525 synced_pref_observers_.find(path); 636 synced_pref_observers_.find(path);
526 if (observer_iter == synced_pref_observers_.end()) 637 if (observer_iter == synced_pref_observers_.end())
527 return; 638 return;
528 SyncedPrefObserverList* observers = observer_iter->second; 639 SyncedPrefObserverList* observers = observer_iter->second;
529 FOR_EACH_OBSERVER(SyncedPrefObserver, *observers, 640 FOR_EACH_OBSERVER(SyncedPrefObserver, *observers,
530 OnSyncedPrefChanged(path, from_sync)); 641 OnSyncedPrefChanged(path, from_sync));
531 } 642 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698