Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ | 5 #ifndef CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ |
| 6 #define CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ | 6 #define CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 104 void AddSyncedPrefObserver(const std::string& name, | 104 void AddSyncedPrefObserver(const std::string& name, |
| 105 SyncedPrefObserver* observer); | 105 SyncedPrefObserver* observer); |
| 106 | 106 |
| 107 // Removes a SyncedPrefObserver from a pref's list of observers. | 107 // Removes a SyncedPrefObserver from a pref's list of observers. |
| 108 void RemoveSyncedPrefObserver(const std::string& name, | 108 void RemoveSyncedPrefObserver(const std::string& name, |
| 109 SyncedPrefObserver* observer); | 109 SyncedPrefObserver* observer); |
| 110 | 110 |
| 111 protected: | 111 protected: |
| 112 friend class ProfileSyncServicePreferenceTest; | 112 friend class ProfileSyncServicePreferenceTest; |
| 113 | 113 |
| 114 typedef std::map<std::string, syncer::SyncData> SyncDataMap; | 114 typedef std::vector<std::pair<std::string, syncer::SyncData> > |
|
Nicolas Zea
2013/10/10 17:44:14
why switch to a vector? I think a map is still cor
robertshield
2013/10/10 20:06:21
Ok, I hadn't understood that MergeDataAndStartSync
Nicolas Zea
2013/10/10 20:35:09
Well, it's not that MergeDataAndStartSyncing will
robertshield
2013/10/11 18:29:31
Done.
| |
| 115 SyncDataPrefList; | |
| 115 | 116 |
| 116 // Create an association for a given preference. If |sync_pref| is valid, | 117 // Create an association for a given preference. If |sync_pref| is valid, |
| 117 // signifying that sync has data for this preference, we reconcile their data | 118 // signifying that sync has data for this preference, we reconcile their data |
| 118 // with ours and append a new UPDATE SyncChange to |sync_changes|. If | 119 // with ours and append a new UPDATE SyncChange to |sync_changes|. If |
| 119 // sync_pref is not set, we append an ADD SyncChange to |sync_changes| with | 120 // sync_pref is not set, we append an ADD SyncChange to |sync_changes| with |
| 120 // the current preference data. | 121 // the current preference data. |
| 122 // |migrated_preference_list| points to a vector that may be updated with a | |
| 123 // string containing the old name of the preference described by |pref_name|. | |
| 121 // Note: We do not modify the sync data for preferences that are either | 124 // Note: We do not modify the sync data for preferences that are either |
| 122 // controlled by policy (are not user modifiable) or have their default value | 125 // controlled by policy (are not user modifiable) or have their default value |
| 123 // (are not user controlled). | 126 // (are not user controlled). |
| 124 void InitPrefAndAssociate(const syncer::SyncData& sync_pref, | 127 void InitPrefAndAssociate(const syncer::SyncData& sync_pref, |
| 125 const std::string& pref_name, | 128 const std::string& pref_name, |
| 126 syncer::SyncChangeList* sync_changes); | 129 syncer::SyncChangeList* sync_changes, |
| 130 SyncDataPrefList* migrated_preference_list); | |
| 127 | 131 |
| 128 static base::Value* MergeListValues( | 132 static base::Value* MergeListValues( |
| 129 const base::Value& from_value, const base::Value& to_value); | 133 const base::Value& from_value, const base::Value& to_value); |
| 130 static base::Value* MergeDictionaryValues(const base::Value& from_value, | 134 static base::Value* MergeDictionaryValues(const base::Value& from_value, |
| 131 const base::Value& to_value); | 135 const base::Value& to_value); |
| 132 | 136 |
| 133 // Do we have an active association between the preferences and sync models? | 137 // Do we have an active association between the preferences and sync models? |
| 134 // Set when start syncing, reset in StopSyncing. While this is not set, we | 138 // Set when start syncing, reset in StopSyncing. While this is not set, we |
| 135 // ignore any local preference changes (when we start syncing we will look | 139 // ignore any local preference changes (when we start syncing we will look |
| 136 // up the most recent values anyways). | 140 // up the most recent values anyways). |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 177 SyncedPrefObserverMap; | 181 SyncedPrefObserverMap; |
| 178 | 182 |
| 179 void NotifySyncedPrefObservers(const std::string& path, bool from_sync) const; | 183 void NotifySyncedPrefObservers(const std::string& path, bool from_sync) const; |
| 180 | 184 |
| 181 SyncedPrefObserverMap synced_pref_observers_; | 185 SyncedPrefObserverMap synced_pref_observers_; |
| 182 | 186 |
| 183 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); | 187 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); |
| 184 }; | 188 }; |
| 185 | 189 |
| 186 #endif // CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ | 190 #endif // CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ |
| OLD | NEW |