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

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: Nicolas' feedback. Add unit tests. 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
51 } // namespace 79 } // namespace
52 80
53 PrefModelAssociator::PrefModelAssociator(syncer::ModelType type) 81 PrefModelAssociator::PrefModelAssociator(syncer::ModelType type)
54 : models_associated_(false), 82 : models_associated_(false),
55 processing_syncer_changes_(false), 83 processing_syncer_changes_(false),
56 pref_service_(NULL), 84 pref_service_(NULL),
57 type_(type) { 85 type_(type) {
58 DCHECK(CalledOnValidThread()); 86 DCHECK(CalledOnValidThread());
59 DCHECK(type_ == PREFERENCES || type_ == PRIORITY_PREFERENCES); 87 DCHECK(type_ == PREFERENCES || type_ == PRIORITY_PREFERENCES);
60 } 88 }
61 89
62 PrefModelAssociator::~PrefModelAssociator() { 90 PrefModelAssociator::~PrefModelAssociator() {
63 DCHECK(CalledOnValidThread()); 91 DCHECK(CalledOnValidThread());
64 pref_service_ = NULL; 92 pref_service_ = NULL;
65 93
66 STLDeleteContainerPairSecondPointers(synced_pref_observers_.begin(), 94 STLDeleteContainerPairSecondPointers(synced_pref_observers_.begin(),
67 synced_pref_observers_.end()); 95 synced_pref_observers_.end());
68 synced_pref_observers_.clear(); 96 synced_pref_observers_.clear();
69 } 97 }
70 98
71 void PrefModelAssociator::InitPrefAndAssociate( 99 void PrefModelAssociator::InitPrefAndAssociate(
72 const syncer::SyncData& sync_pref, 100 const syncer::SyncData& sync_pref,
73 const std::string& pref_name, 101 const std::string& pref_name,
74 syncer::SyncChangeList* sync_changes) { 102 syncer::SyncChangeList* sync_changes,
103 SyncDataMap* migrated_preference_list) {
75 const Value* user_pref_value = pref_service_->GetUserPrefValue( 104 const Value* user_pref_value = pref_service_->GetUserPrefValue(
76 pref_name.c_str()); 105 pref_name.c_str());
77 VLOG(1) << "Associating preference " << pref_name; 106 VLOG(1) << "Associating preference " << pref_name;
78 107
79 if (sync_pref.IsValid()) { 108 if (sync_pref.IsValid()) {
80 const sync_pb::PreferenceSpecifics& preference = GetSpecifics(sync_pref); 109 const sync_pb::PreferenceSpecifics& preference = GetSpecifics(sync_pref);
81 DCHECK_EQ(pref_name, preference.name()); 110 DCHECK(pref_name == preference.name() ||
82 111 (IsMigratedPreference(pref_name.c_str()) &&
112 preference.name() ==
113 GetOldMigratedPreferenceName(pref_name.c_str())));
83 base::JSONReader reader; 114 base::JSONReader reader;
84 scoped_ptr<Value> sync_value(reader.ReadToValue(preference.value())); 115 scoped_ptr<Value> sync_value(reader.ReadToValue(preference.value()));
85 if (!sync_value.get()) { 116 if (!sync_value.get()) {
86 LOG(ERROR) << "Failed to deserialize preference value: " 117 LOG(ERROR) << "Failed to deserialize preference value: "
87 << reader.GetErrorMessage(); 118 << reader.GetErrorMessage();
88 return; 119 return;
89 } 120 }
90 121
91 if (user_pref_value) { 122 if (user_pref_value) {
92 // We have both server and local values. Merge them. 123 // We have both server and local values. Merge them.
(...skipping 15 matching lines...) Expand all
108 pref_service_->Set(pref_name.c_str(), *new_value); 139 pref_service_->Set(pref_name.c_str(), *new_value);
109 } 140 }
110 141
111 // If the merge resulted in an updated value, inform the syncer. 142 // If the merge resulted in an updated value, inform the syncer.
112 if (!sync_value->Equals(new_value.get())) { 143 if (!sync_value->Equals(new_value.get())) {
113 syncer::SyncData sync_data; 144 syncer::SyncData sync_data;
114 if (!CreatePrefSyncData(pref_name, *new_value, &sync_data)) { 145 if (!CreatePrefSyncData(pref_name, *new_value, &sync_data)) {
115 LOG(ERROR) << "Failed to update preference."; 146 LOG(ERROR) << "Failed to update preference.";
116 return; 147 return;
117 } 148 }
118 sync_changes->push_back( 149
150 if (IsMigratedPreference(pref_name.c_str())) {
151 // This preference has been migrated from an old version that must be
152 // kept in sync on older versions of Chrome.
153 std::string old_pref_name =
154 GetOldMigratedPreferenceName(pref_name.c_str());
155
156 if (preference.name() == old_pref_name && migrated_preference_list) {
Nicolas Zea 2013/10/11 19:58:54 I think it's invalid to call InitPrefAndAssociate
robertshield 2013/10/11 21:47:23 Afaict it should never happen and I'll add the DCH
157 // If the name the syncer has is the old pre-migration value, then
158 // it's possible the new migrated preference name hasn't been synced
159 // yet. In that case the SyncChange should be an ACTION_ADD rather
160 // than an ACTION_UPDATE. Defer the decision of whether to sync with
161 // ACTION_ADD or ACTION_UPDATE until the migrated_preferences phase.
162 (*migrated_preference_list)[pref_name] = sync_data;
163 } else {
164 DCHECK_EQ(preference.name(), pref_name);
165 sync_changes->push_back(
166 syncer::SyncChange(FROM_HERE,
167 syncer::SyncChange::ACTION_UPDATE,
168 sync_data));
169 }
170
171 syncer::SyncData old_sync_data;
172 if (!CreatePrefSyncData(old_pref_name, *new_value, &old_sync_data)) {
173 LOG(ERROR) << "Failed to update preference.";
174 return;
175 }
176 (*migrated_preference_list)[old_pref_name] = old_sync_data;
177
178 // Keep track of the name of the synced pref. This will be idempotent
179 // with the insertion of pref_name below when the migrated value has
180 // already been synced, not so when it has not.
181 synced_preferences_.insert(preference.name());
Nicolas Zea 2013/10/11 19:58:54 I think rather than having this here, you need to
robertshield 2013/10/11 21:47:23 preference.name() is only defined if sync_pref.IsV
182 } else {
183 sync_changes->push_back(
119 syncer::SyncChange(FROM_HERE, 184 syncer::SyncChange(FROM_HERE,
120 syncer::SyncChange::ACTION_UPDATE, 185 syncer::SyncChange::ACTION_UPDATE,
121 sync_data)); 186 sync_data));
187 }
122 } 188 }
123 } else if (!sync_value->IsType(Value::TYPE_NULL)) { 189 } else if (!sync_value->IsType(Value::TYPE_NULL)) {
124 // Only a server value exists. Just set the local user value. 190 // Only a server value exists. Just set the local user value.
125 pref_service_->Set(pref_name.c_str(), *sync_value); 191 pref_service_->Set(pref_name.c_str(), *sync_value);
126 } else { 192 } else {
127 LOG(WARNING) << "Sync has null value for pref " << pref_name.c_str(); 193 LOG(WARNING) << "Sync has null value for pref " << pref_name.c_str();
128 } 194 }
129 } else if (user_pref_value) { 195 } else if (user_pref_value) {
130 // The server does not know about this preference and should be added 196 // The server does not know about this preference and should be added
131 // to the syncer's database. 197 // to the syncer's database.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 DCHECK(!sync_processor_.get()); 229 DCHECK(!sync_processor_.get());
164 DCHECK(sync_processor.get()); 230 DCHECK(sync_processor.get());
165 DCHECK(sync_error_factory.get()); 231 DCHECK(sync_error_factory.get());
166 syncer::SyncMergeResult merge_result(type); 232 syncer::SyncMergeResult merge_result(type);
167 sync_processor_ = sync_processor.Pass(); 233 sync_processor_ = sync_processor.Pass();
168 sync_error_factory_ = sync_error_factory.Pass(); 234 sync_error_factory_ = sync_error_factory.Pass();
169 235
170 syncer::SyncChangeList new_changes; 236 syncer::SyncChangeList new_changes;
171 std::set<std::string> remaining_preferences = registered_preferences_; 237 std::set<std::string> remaining_preferences = registered_preferences_;
172 238
239 // Maintains a list of old migrated preference names that we wish to sync.
240 // Keep track of these in a list such that when the preference iteration
241 // loops below are complete we can go back and determine whether
242 SyncDataMap migrated_preference_list;
243
173 // Go through and check for all preferences we care about that sync already 244 // Go through and check for all preferences we care about that sync already
174 // knows about. 245 // knows about.
175 for (syncer::SyncDataList::const_iterator sync_iter = 246 for (syncer::SyncDataList::const_iterator sync_iter =
176 initial_sync_data.begin(); 247 initial_sync_data.begin();
177 sync_iter != initial_sync_data.end(); 248 sync_iter != initial_sync_data.end();
178 ++sync_iter) { 249 ++sync_iter) {
179 DCHECK_EQ(type_, sync_iter->GetDataType()); 250 DCHECK_EQ(type_, sync_iter->GetDataType());
180 251
181 const sync_pb::PreferenceSpecifics& preference = GetSpecifics(*sync_iter); 252 const sync_pb::PreferenceSpecifics& preference = GetSpecifics(*sync_iter);
182 const std::string& sync_pref_name = preference.name(); 253 std::string sync_pref_name = preference.name();
183 254
184 if (remaining_preferences.count(sync_pref_name) == 0) { 255 if (remaining_preferences.count(sync_pref_name) == 0) {
185 // We're not syncing this preference locally, ignore the sync data. 256 if (IsOldMigratedPreference(sync_pref_name.c_str())) {
186 // TODO(zea): Eventually we want to be able to have the syncable service 257 // This old pref name is not syncable locally anymore but we accept
187 // reconstruct all sync data for it's datatype (therefore having 258 // changes from other Chrome installs of previous versions and migrate
188 // GetAllSyncData be a complete representation). We should store this data 259 // them to the new name. Note that we will be merging any differences
189 // somewhere, even if we don't use it. 260 // between the new and old values and sync'ing them back.
190 continue; 261 sync_pref_name = GetNewMigratedPreferenceName(sync_pref_name.c_str());
262 } else {
263 // We're not syncing this preference locally, ignore the sync data.
264 // TODO(zea): Eventually we want to be able to have the syncable service
265 // reconstruct all sync data for its datatype (therefore having
266 // GetAllSyncData be a complete representation). We should store this
267 // data somewhere, even if we don't use it.
268 continue;
269 }
270 } else {
271 remaining_preferences.erase(sync_pref_name);
191 } 272 }
192 273 InitPrefAndAssociate(*sync_iter, sync_pref_name, &new_changes,
193 remaining_preferences.erase(sync_pref_name); 274 &migrated_preference_list);
194 InitPrefAndAssociate(*sync_iter, sync_pref_name, &new_changes);
195 } 275 }
196 276
197 // Go through and build sync data for any remaining preferences. 277 // Go through and build sync data for any remaining preferences.
198 for (std::set<std::string>::iterator pref_name_iter = 278 for (std::set<std::string>::iterator pref_name_iter =
199 remaining_preferences.begin(); 279 remaining_preferences.begin();
200 pref_name_iter != remaining_preferences.end(); 280 pref_name_iter != remaining_preferences.end();
201 ++pref_name_iter) { 281 ++pref_name_iter) {
202 InitPrefAndAssociate(syncer::SyncData(), *pref_name_iter, &new_changes); 282 InitPrefAndAssociate(syncer::SyncData(), *pref_name_iter, &new_changes,
283 &migrated_preference_list);
284 }
285
286 // Now go over any migrated preference names and build sync data for them too.
287 for (SyncDataMap::const_iterator migrated_pref_iter =
288 migrated_preference_list.begin();
289 migrated_pref_iter != migrated_preference_list.end();
290 ++migrated_pref_iter) {
291 syncer::SyncChange::SyncChangeType change_type =
292 (synced_preferences_.count(migrated_pref_iter->first) == 0) ?
293 syncer::SyncChange::ACTION_ADD :
294 syncer::SyncChange::ACTION_UPDATE;
295 new_changes.push_back(
296 syncer::SyncChange(FROM_HERE, change_type, migrated_pref_iter->second));
203 } 297 }
204 298
205 // Push updates to sync. 299 // Push updates to sync.
206 merge_result.set_error( 300 merge_result.set_error(
207 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes)); 301 sync_processor_->ProcessSyncChanges(FROM_HERE, new_changes));
208 if (merge_result.error().IsSet()) 302 if (merge_result.error().IsSet())
209 return merge_result; 303 return merge_result;
210 304
211 models_associated_ = true; 305 models_associated_ = true;
212 pref_service_->OnIsSyncingChanged(); 306 pref_service_->OnIsSyncingChanged();
213 return merge_result; 307 return merge_result;
214 } 308 }
215 309
216 void PrefModelAssociator::StopSyncing(syncer::ModelType type) { 310 void PrefModelAssociator::StopSyncing(syncer::ModelType type) {
217 DCHECK_EQ(type_, type); 311 DCHECK_EQ(type_, type);
218 models_associated_ = false; 312 models_associated_ = false;
219 sync_processor_.reset(); 313 sync_processor_.reset();
220 sync_error_factory_.reset(); 314 sync_error_factory_.reset();
221 pref_service_->OnIsSyncingChanged(); 315 pref_service_->OnIsSyncingChanged();
222 } 316 }
223 317
224 scoped_ptr<Value> PrefModelAssociator::MergePreference( 318 scoped_ptr<Value> PrefModelAssociator::MergePreference(
225 const std::string& name, 319 const std::string& name,
226 const Value& local_value, 320 const Value& local_value,
227 const Value& server_value) { 321 const Value& server_value) {
228 if (name == prefs::kURLsToRestoreOnStartup) { 322 // This function special cases preferences individually, so don't attempt
323 // to merge for all migrated values.
324 if (name == prefs::kURLsToRestoreOnStartup ||
325 name == prefs::kURLsToRestoreOnStartupOld) {
229 return scoped_ptr<Value>(MergeListValues(local_value, server_value)).Pass(); 326 return scoped_ptr<Value>(MergeListValues(local_value, server_value)).Pass();
230 } 327 }
231 328
232 if (name == prefs::kContentSettingsPatternPairs) { 329 if (name == prefs::kContentSettingsPatternPairs) {
233 return scoped_ptr<Value>( 330 return scoped_ptr<Value>(
234 MergeDictionaryValues(local_value, server_value)).Pass(); 331 MergeDictionaryValues(local_value, server_value)).Pass();
235 } 332 }
236 333
237 // If this is not a specially handled preference, server wins. 334 // If this is not a specially handled preference, server wins.
238 return scoped_ptr<Value>(server_value.DeepCopy()).Pass(); 335 return scoped_ptr<Value>(server_value.DeepCopy()).Pass();
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 } 411 }
315 // Note that for all other types we want to preserve the "to" 412 // Note that for all other types we want to preserve the "to"
316 // values so we do nothing here. 413 // values so we do nothing here.
317 } else { 414 } else {
318 result->SetWithoutPathExpansion(it.key(), from_value->DeepCopy()); 415 result->SetWithoutPathExpansion(it.key(), from_value->DeepCopy());
319 } 416 }
320 } 417 }
321 return result; 418 return result;
322 } 419 }
323 420
421 // static
422 bool PrefModelAssociator::IsMigratedPreference(const char* preference_name) {
423 return !GetOldMigratedPreferenceName(preference_name).empty();
424 }
425
426 // static
427 bool PrefModelAssociator::IsOldMigratedPreference(
428 const char* old_preference_name) {
429 return !GetNewMigratedPreferenceName(old_preference_name).empty();
430 }
431
324 // Note: This will build a model of all preferences registered as syncable 432 // Note: This will build a model of all preferences registered as syncable
325 // with user controlled data. We do not track any information for preferences 433 // with user controlled data. We do not track any information for preferences
326 // not registered locally as syncable and do not inform the syncer of 434 // not registered locally as syncable and do not inform the syncer of
327 // non-user controlled preferences. 435 // non-user controlled preferences.
328 syncer::SyncDataList PrefModelAssociator::GetAllSyncData( 436 syncer::SyncDataList PrefModelAssociator::GetAllSyncData(
329 syncer::ModelType type) 437 syncer::ModelType type)
330 const { 438 const {
331 DCHECK_EQ(type_, type); 439 DCHECK_EQ(type_, type);
332 syncer::SyncDataList current_data; 440 syncer::SyncDataList current_data;
333 for (PreferenceSet::const_iterator iter = synced_preferences_.begin(); 441 for (PreferenceSet::const_iterator iter = synced_preferences_.begin();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 // TODO(zea): consider taking some further action such as erasing the bad 489 // TODO(zea): consider taking some further action such as erasing the bad
382 // data. 490 // data.
383 if (!value.get()) 491 if (!value.get())
384 continue; 492 continue;
385 493
386 // It is possible that we may receive a change to a preference we do not 494 // 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 495 // want to sync. For example if the user is syncing a Mac client and a
388 // Windows client, the Windows client does not support 496 // Windows client, the Windows client does not support
389 // kConfirmToQuitEnabled. Ignore updates from these preferences. 497 // kConfirmToQuitEnabled. Ignore updates from these preferences.
390 const char* pref_name = name.c_str(); 498 const char* pref_name = name.c_str();
499 std::string new_name;
500 // We migrated this preference name, so do as if the name had not changed.
501 if (IsOldMigratedPreference(pref_name)) {
502 new_name = GetNewMigratedPreferenceName(pref_name);
503 pref_name = new_name.c_str();
504 }
505
391 if (!IsPrefRegistered(pref_name)) 506 if (!IsPrefRegistered(pref_name))
392 continue; 507 continue;
393 508
394 const PrefService::Preference* pref = 509 const PrefService::Preference* pref =
395 pref_service_->FindPreference(pref_name); 510 pref_service_->FindPreference(pref_name);
396 DCHECK(pref); 511 DCHECK(pref);
397 512
398 // This will only modify the user controlled value store, which takes 513 // This will only modify the user controlled value store, which takes
399 // priority over the default value but is ignored if the preference is 514 // priority over the default value but is ignored if the preference is
400 // policy controlled. 515 // policy controlled.
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 } 604 }
490 605
491 base::AutoReset<bool> processing_changes(&processing_syncer_changes_, true); 606 base::AutoReset<bool> processing_changes(&processing_syncer_changes_, true);
492 607
493 NotifySyncedPrefObservers(name, false /*from_sync*/); 608 NotifySyncedPrefObservers(name, false /*from_sync*/);
494 609
495 if (synced_preferences_.count(name) == 0) { 610 if (synced_preferences_.count(name) == 0) {
496 // Not in synced_preferences_ means no synced data. InitPrefAndAssociate(..) 611 // 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 612 // 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. 613 // and hasn't been changed yet we don't) and take care syncing any new data.
499 InitPrefAndAssociate(syncer::SyncData(), name, &changes); 614 InitPrefAndAssociate(syncer::SyncData(), name, &changes, NULL);
500 } else { 615 } else {
501 // We are already syncing this preference, just update it's sync node. 616 // We are already syncing this preference, just update it's sync node.
502 syncer::SyncData sync_data; 617 syncer::SyncData sync_data;
503 if (!CreatePrefSyncData(name, *preference->GetValue(), &sync_data)) { 618 if (!CreatePrefSyncData(name, *preference->GetValue(), &sync_data)) {
504 LOG(ERROR) << "Failed to update preference."; 619 LOG(ERROR) << "Failed to update preference.";
505 return; 620 return;
506 } 621 }
507 changes.push_back( 622 changes.push_back(
508 syncer::SyncChange(FROM_HERE, 623 syncer::SyncChange(FROM_HERE,
509 syncer::SyncChange::ACTION_UPDATE, 624 syncer::SyncChange::ACTION_UPDATE,
510 sync_data)); 625 sync_data));
626 // This preference has been migrated from an old version that must be kept
627 // in sync on older versions of Chrome.
628 if (IsMigratedPreference(name.c_str())) {
629 std::string old_pref_name = GetOldMigratedPreferenceName(name.c_str());
630 if (!CreatePrefSyncData(old_pref_name,
631 *preference->GetValue(),
632 &sync_data)) {
633 LOG(ERROR) << "Failed to update preference.";
634 return;
635 }
636
637 syncer::SyncChange::SyncChangeType change_type =
638 (synced_preferences_.count(name) == 0) ?
Nicolas Zea 2013/10/11 19:58:54 this should be old_pref_name right?
robertshield 2013/10/11 21:47:23 oops, yes. good catch.
639 syncer::SyncChange::ACTION_ADD :
640 syncer::SyncChange::ACTION_UPDATE;
641 changes.push_back(
642 syncer::SyncChange(FROM_HERE, change_type, sync_data));
643 }
511 } 644 }
512 645
513 syncer::SyncError error = 646 syncer::SyncError error =
514 sync_processor_->ProcessSyncChanges(FROM_HERE, changes); 647 sync_processor_->ProcessSyncChanges(FROM_HERE, changes);
515 } 648 }
516 649
517 void PrefModelAssociator::SetPrefService(PrefServiceSyncable* pref_service) { 650 void PrefModelAssociator::SetPrefService(PrefServiceSyncable* pref_service) {
518 DCHECK(pref_service_ == NULL); 651 DCHECK(pref_service_ == NULL);
519 pref_service_ = pref_service; 652 pref_service_ = pref_service;
520 } 653 }
521 654
522 void PrefModelAssociator::NotifySyncedPrefObservers(const std::string& path, 655 void PrefModelAssociator::NotifySyncedPrefObservers(const std::string& path,
523 bool from_sync) const { 656 bool from_sync) const {
524 SyncedPrefObserverMap::const_iterator observer_iter = 657 SyncedPrefObserverMap::const_iterator observer_iter =
525 synced_pref_observers_.find(path); 658 synced_pref_observers_.find(path);
526 if (observer_iter == synced_pref_observers_.end()) 659 if (observer_iter == synced_pref_observers_.end())
527 return; 660 return;
528 SyncedPrefObserverList* observers = observer_iter->second; 661 SyncedPrefObserverList* observers = observer_iter->second;
529 FOR_EACH_OBSERVER(SyncedPrefObserver, *observers, 662 FOR_EACH_OBSERVER(SyncedPrefObserver, *observers,
530 OnSyncedPrefChanged(path, from_sync)); 663 OnSyncedPrefChanged(path, from_sync));
531 } 664 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698