commit | 2cf5c57f54ec0aa57d422f6f4f89dddd9c641051 | [log] [tgz] |
---|---|---|
author | lshang <[email protected]> | Fri Jul 15 01:36:32 2016 |
committer | Commit bot <[email protected]> | Fri Jul 15 01:38:36 2016 |
tree | 439705f6e918f03f08c79b32b47e387e5100f55c | |
parent | 647dfe6fe658b5fc62a99854dc1e0d9308604f09 [diff] [blame] |
Add callback list to PrefModelAssociator after sync data is loaded This is a follow up CL of https://codereview.chromium.org/1895993003. The migrated settings will be synced back because sync process happens after the construction of HostContentSettingsMap. In this CL, a callback list is added to PrefModelAssociator, which will gets registered with the migration code after construction of HostContentSettingsMap, and gets executed at the end of PrefModelAssociator::MergeDataAndStartSyncing. The follow up CL of this is https://codereview.chromium.org/2075103002. BUG=604612 Review-Url: https://codereview.chromium.org/2078893002 Cr-Commit-Position: refs/heads/master@{#405669}
diff --git a/components/syncable_prefs/pref_model_associator.cc b/components/syncable_prefs/pref_model_associator.cc index 4cbdd558..dd9d71494 100644 --- a/components/syncable_prefs/pref_model_associator.cc +++ b/components/syncable_prefs/pref_model_associator.cc
@@ -157,6 +157,14 @@ // we'll send the new user controlled value to the syncer. } +void PrefModelAssociator::RegisterMergeDataFinishedCallback( + const base::Closure& callback) { + if (!models_associated_) + callback_list_.push_back(callback); + else + callback.Run(); +} + syncer::SyncMergeResult PrefModelAssociator::MergeDataAndStartSyncing( syncer::ModelType type, const syncer::SyncDataList& initial_sync_data, @@ -213,6 +221,10 @@ if (merge_result.error().IsSet()) return merge_result; + for (const auto& callback : callback_list_) + callback.Run(); + callback_list_.clear(); + models_associated_ = true; pref_service_->OnIsSyncingChanged(); return merge_result;