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

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

Issue 24930003: Migrate startup URLs pref. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rename remaining old pref value. 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
« no previous file with comments | « no previous file | chrome/browser/prefs/pref_model_associator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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>
11 11
12 #include "base/basictypes.h" 12 #include "base/basictypes.h"
13 #include "base/compiler_specific.h" 13 #include "base/compiler_specific.h"
14 #include "base/containers/hash_tables.h" 14 #include "base/containers/hash_tables.h"
15 #include "base/gtest_prod_util.h"
15 #include "base/observer_list.h" 16 #include "base/observer_list.h"
16 #include "base/threading/non_thread_safe.h" 17 #include "base/threading/non_thread_safe.h"
17 #include "chrome/browser/prefs/synced_pref_observer.h" 18 #include "chrome/browser/prefs/synced_pref_observer.h"
18 #include "sync/api/sync_data.h" 19 #include "sync/api/sync_data.h"
19 #include "sync/api/syncable_service.h" 20 #include "sync/api/syncable_service.h"
20 21
21 class PrefRegistrySyncable; 22 class PrefRegistrySyncable;
22 class PrefServiceSyncable; 23 class PrefServiceSyncable;
23 24
24 namespace sync_pb { 25 namespace sync_pb {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 // Adds a SyncedPrefObserver to watch for changes to a specific pref. 104 // Adds a SyncedPrefObserver to watch for changes to a specific pref.
104 void AddSyncedPrefObserver(const std::string& name, 105 void AddSyncedPrefObserver(const std::string& name,
105 SyncedPrefObserver* observer); 106 SyncedPrefObserver* observer);
106 107
107 // Removes a SyncedPrefObserver from a pref's list of observers. 108 // Removes a SyncedPrefObserver from a pref's list of observers.
108 void RemoveSyncedPrefObserver(const std::string& name, 109 void RemoveSyncedPrefObserver(const std::string& name,
109 SyncedPrefObserver* observer); 110 SyncedPrefObserver* observer);
110 111
111 protected: 112 protected:
112 friend class ProfileSyncServicePreferenceTest; 113 friend class ProfileSyncServicePreferenceTest;
114 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServicePreferenceTest,
115 ModelAssociationCloudHasOldMigratedData);
116 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServicePreferenceTest,
117 ModelAssociationCloudHasNewMigratedData);
118 FRIEND_TEST_ALL_PREFIXES(ProfileSyncServicePreferenceTest,
119 ModelAssociationCloudAddsOldAndNewMigratedData);
113 120
114 typedef std::map<std::string, syncer::SyncData> SyncDataMap; 121 typedef std::map<std::string, syncer::SyncData> SyncDataMap;
115 122
116 // Create an association for a given preference. If |sync_pref| is valid, 123 // 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 124 // 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 125 // 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 126 // sync_pref is not set, we append an ADD SyncChange to |sync_changes| with
120 // the current preference data. 127 // the current preference data.
128 // |migrated_preference_list| points to a vector that may be updated with a
129 // 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 130 // 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 131 // controlled by policy (are not user modifiable) or have their default value
123 // (are not user controlled). 132 // (are not user controlled).
124 void InitPrefAndAssociate(const syncer::SyncData& sync_pref, 133 void InitPrefAndAssociate(const syncer::SyncData& sync_pref,
125 const std::string& pref_name, 134 const std::string& pref_name,
126 syncer::SyncChangeList* sync_changes); 135 syncer::SyncChangeList* sync_changes,
136 SyncDataMap* migrated_preference_list);
127 137
128 static base::Value* MergeListValues( 138 static base::Value* MergeListValues(
129 const base::Value& from_value, const base::Value& to_value); 139 const base::Value& from_value, const base::Value& to_value);
130 static base::Value* MergeDictionaryValues(const base::Value& from_value, 140 static base::Value* MergeDictionaryValues(const base::Value& from_value,
131 const base::Value& to_value); 141 const base::Value& to_value);
132 142
143 // Returns whether a given preference name is a new name of a migrated
144 // preference. Exposed here for testing.
145 static bool IsMigratedPreference(const char* preference_name);
146 static bool IsOldMigratedPreference(const char* old_preference_name);
147
133 // Do we have an active association between the preferences and sync models? 148 // 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 149 // 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 150 // ignore any local preference changes (when we start syncing we will look
136 // up the most recent values anyways). 151 // up the most recent values anyways).
137 bool models_associated_; 152 bool models_associated_;
138 153
139 // Whether we're currently processing changes from the syncer. While this is 154 // Whether we're currently processing changes from the syncer. While this is
140 // true, we ignore any local preference changes, since we triggered them. 155 // true, we ignore any local preference changes, since we triggered them.
141 bool processing_syncer_changes_; 156 bool processing_syncer_changes_;
142 157
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 SyncedPrefObserverMap; 192 SyncedPrefObserverMap;
178 193
179 void NotifySyncedPrefObservers(const std::string& path, bool from_sync) const; 194 void NotifySyncedPrefObservers(const std::string& path, bool from_sync) const;
180 195
181 SyncedPrefObserverMap synced_pref_observers_; 196 SyncedPrefObserverMap synced_pref_observers_;
182 197
183 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator); 198 DISALLOW_COPY_AND_ASSIGN(PrefModelAssociator);
184 }; 199 };
185 200
186 #endif // CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_ 201 #endif // CHROME_BROWSER_PREFS_PREF_MODEL_ASSOCIATOR_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/prefs/pref_model_associator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698