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

Side by Side Diff: components/sync/driver/sync_prefs.h

Issue 2376123003: [Sync] Move //components/sync to the syncer namespace. (Closed)
Patch Set: Rebase. Created 4 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
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 COMPONENTS_SYNC_DRIVER_SYNC_PREFS_H_ 5 #ifndef COMPONENTS_SYNC_DRIVER_SYNC_PREFS_H_
6 #define COMPONENTS_SYNC_DRIVER_SYNC_PREFS_H_ 6 #define COMPONENTS_SYNC_DRIVER_SYNC_PREFS_H_
7 7
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 11 matching lines...) Expand all
22 #include "components/sync/base/model_type.h" 22 #include "components/sync/base/model_type.h"
23 #include "components/sync/core/sync_encryption_handler.h" 23 #include "components/sync/core/sync_encryption_handler.h"
24 24
25 class PrefService; 25 class PrefService;
26 class ProfileIOData; 26 class ProfileIOData;
27 27
28 namespace user_prefs { 28 namespace user_prefs {
29 class PrefRegistrySyncable; 29 class PrefRegistrySyncable;
30 } 30 }
31 31
32 namespace sync_driver { 32 namespace syncer {
33 33
34 class SyncPrefObserver { 34 class SyncPrefObserver {
35 public: 35 public:
36 // Called whenever the pref that controls whether sync is managed 36 // Called whenever the pref that controls whether sync is managed
37 // changes. 37 // changes.
38 virtual void OnSyncManagedPrefChange(bool is_sync_managed) = 0; 38 virtual void OnSyncManagedPrefChange(bool is_sync_managed) = 0;
39 39
40 protected: 40 protected:
41 virtual ~SyncPrefObserver(); 41 virtual ~SyncPrefObserver();
42 }; 42 };
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 90
91 base::Time GetLastPollTime() const; 91 base::Time GetLastPollTime() const;
92 void SetLastPollTime(base::Time time); 92 void SetLastPollTime(base::Time time);
93 93
94 bool HasKeepEverythingSynced() const; 94 bool HasKeepEverythingSynced() const;
95 void SetKeepEverythingSynced(bool keep_everything_synced); 95 void SetKeepEverythingSynced(bool keep_everything_synced);
96 96
97 // The returned set is guaranteed to be a subset of 97 // The returned set is guaranteed to be a subset of
98 // |registered_types|. Returns |registered_types| directly if 98 // |registered_types|. Returns |registered_types| directly if
99 // HasKeepEverythingSynced() is true. 99 // HasKeepEverythingSynced() is true.
100 syncer::ModelTypeSet GetPreferredDataTypes( 100 ModelTypeSet GetPreferredDataTypes(ModelTypeSet registered_types) const;
101 syncer::ModelTypeSet registered_types) const;
102 // |preferred_types| should be a subset of |registered_types|. All 101 // |preferred_types| should be a subset of |registered_types|. All
103 // types in |preferred_types| are marked preferred, and all types in 102 // types in |preferred_types| are marked preferred, and all types in
104 // |registered_types| \ |preferred_types| are marked not preferred. 103 // |registered_types| \ |preferred_types| are marked not preferred.
105 // Changes are still made to the prefs even if 104 // Changes are still made to the prefs even if
106 // HasKeepEverythingSynced() is true, but won't be visible until 105 // HasKeepEverythingSynced() is true, but won't be visible until
107 // SetKeepEverythingSynced(false) is called. 106 // SetKeepEverythingSynced(false) is called.
108 void SetPreferredDataTypes(syncer::ModelTypeSet registered_types, 107 void SetPreferredDataTypes(ModelTypeSet registered_types,
109 syncer::ModelTypeSet preferred_types); 108 ModelTypeSet preferred_types);
110 109
111 // This pref is set outside of sync. 110 // This pref is set outside of sync.
112 bool IsManaged() const; 111 bool IsManaged() const;
113 112
114 // Use this encryption bootstrap token if we're using an explicit passphrase. 113 // Use this encryption bootstrap token if we're using an explicit passphrase.
115 std::string GetEncryptionBootstrapToken() const; 114 std::string GetEncryptionBootstrapToken() const;
116 void SetEncryptionBootstrapToken(const std::string& token); 115 void SetEncryptionBootstrapToken(const std::string& token);
117 116
118 // Use this keystore bootstrap token if we're not using an explicit 117 // Use this keystore bootstrap token if we're not using an explicit
119 // passphrase. 118 // passphrase.
120 std::string GetKeystoreEncryptionBootstrapToken() const; 119 std::string GetKeystoreEncryptionBootstrapToken() const;
121 void SetKeystoreEncryptionBootstrapToken(const std::string& token); 120 void SetKeystoreEncryptionBootstrapToken(const std::string& token);
122 121
123 // Use this for the unique machine tag used for session sync. 122 // Use this for the unique machine tag used for session sync.
124 std::string GetSyncSessionsGUID() const; 123 std::string GetSyncSessionsGUID() const;
125 void SetSyncSessionsGUID(const std::string& guid); 124 void SetSyncSessionsGUID(const std::string& guid);
126 125
127 // Maps |data_type| to its corresponding preference name. 126 // Maps |data_type| to its corresponding preference name.
128 static const char* GetPrefNameForDataType(syncer::ModelType data_type); 127 static const char* GetPrefNameForDataType(ModelType data_type);
129 128
130 #if defined(OS_CHROMEOS) 129 #if defined(OS_CHROMEOS)
131 // Use this spare bootstrap token only when setting up sync for the first 130 // Use this spare bootstrap token only when setting up sync for the first
132 // time. 131 // time.
133 std::string GetSpareBootstrapToken() const; 132 std::string GetSpareBootstrapToken() const;
134 void SetSpareBootstrapToken(const std::string& token); 133 void SetSpareBootstrapToken(const std::string& token);
135 #endif 134 #endif
136 135
137 // Get/set/clear first sync time of current user. Used to roll back browsing 136 // Get/set/clear first sync time of current user. Used to roll back browsing
138 // data later when user signs out. 137 // data later when user signs out.
(...skipping 13 matching lines...) Expand all
152 void SetMemoryPressureWarningCount(int value); 151 void SetMemoryPressureWarningCount(int value);
153 152
154 // Check if the previous shutdown was clean. 153 // Check if the previous shutdown was clean.
155 bool DidSyncShutdownCleanly() const; 154 bool DidSyncShutdownCleanly() const;
156 155
157 // Set whether the last shutdown was clean. 156 // Set whether the last shutdown was clean.
158 void SetCleanShutdown(bool value); 157 void SetCleanShutdown(bool value);
159 158
160 // Get/set for the last known sync invalidation versions. 159 // Get/set for the last known sync invalidation versions.
161 void GetInvalidationVersions( 160 void GetInvalidationVersions(
162 std::map<syncer::ModelType, int64_t>* invalidation_versions) const; 161 std::map<ModelType, int64_t>* invalidation_versions) const;
163 void UpdateInvalidationVersions( 162 void UpdateInvalidationVersions(
164 const std::map<syncer::ModelType, int64_t>& invalidation_versions); 163 const std::map<ModelType, int64_t>& invalidation_versions);
165 164
166 // Will return the contents of the LastRunVersion preference. This may be an 165 // Will return the contents of the LastRunVersion preference. This may be an
167 // empty string if no version info was present, and is only valid at 166 // empty string if no version info was present, and is only valid at
168 // Sync startup time (after which the LastRunVersion preference will have been 167 // Sync startup time (after which the LastRunVersion preference will have been
169 // updated to the current version). 168 // updated to the current version).
170 std::string GetLastRunVersion() const; 169 std::string GetLastRunVersion() const;
171 void SetLastRunVersion(const std::string& current_version); 170 void SetLastRunVersion(const std::string& current_version);
172 171
173 // Get/set for flag indicating that passphrase encryption transition is in 172 // Get/set for flag indicating that passphrase encryption transition is in
174 // progress. 173 // progress.
175 void SetPassphraseEncryptionTransitionInProgress(bool value); 174 void SetPassphraseEncryptionTransitionInProgress(bool value);
176 bool GetPassphraseEncryptionTransitionInProgress() const; 175 bool GetPassphraseEncryptionTransitionInProgress() const;
177 176
178 // Get/set for saved Nigori state that needs to be passed to backend 177 // Get/set for saved Nigori state that needs to be passed to backend
179 // initialization after transition. 178 // initialization after transition.
180 void SetSavedNigoriStateForPassphraseEncryptionTransition( 179 void SetSavedNigoriStateForPassphraseEncryptionTransition(
181 const syncer::SyncEncryptionHandler::NigoriState& nigori_state); 180 const SyncEncryptionHandler::NigoriState& nigori_state);
182 std::unique_ptr<syncer::SyncEncryptionHandler::NigoriState> 181 std::unique_ptr<SyncEncryptionHandler::NigoriState>
183 GetSavedNigoriStateForPassphraseEncryptionTransition() const; 182 GetSavedNigoriStateForPassphraseEncryptionTransition() const;
184 183
185 private: 184 private:
186 void RegisterPrefGroups(); 185 void RegisterPrefGroups();
187 186
188 static void RegisterDataTypePreferredPref( 187 static void RegisterDataTypePreferredPref(
189 user_prefs::PrefRegistrySyncable* prefs, 188 user_prefs::PrefRegistrySyncable* prefs,
190 syncer::ModelType type, 189 ModelType type,
191 bool is_preferred); 190 bool is_preferred);
192 bool GetDataTypePreferred(syncer::ModelType type) const; 191 bool GetDataTypePreferred(ModelType type) const;
193 void SetDataTypePreferred(syncer::ModelType type, bool is_preferred); 192 void SetDataTypePreferred(ModelType type, bool is_preferred);
194 193
195 // Returns a ModelTypeSet based on |types| expanded to include pref groups 194 // Returns a ModelTypeSet based on |types| expanded to include pref groups
196 // (see |pref_groups_|), but as a subset of |registered_types|. 195 // (see |pref_groups_|), but as a subset of |registered_types|.
197 syncer::ModelTypeSet ResolvePrefGroups(syncer::ModelTypeSet registered_types, 196 ModelTypeSet ResolvePrefGroups(ModelTypeSet registered_types,
198 syncer::ModelTypeSet types) const; 197 ModelTypeSet types) const;
199 198
200 void OnSyncManagedPrefChanged(); 199 void OnSyncManagedPrefChanged();
201 200
202 // May be NULL. 201 // May be NULL.
203 PrefService* const pref_service_; 202 PrefService* const pref_service_;
204 203
205 base::ObserverList<SyncPrefObserver> sync_pref_observers_; 204 base::ObserverList<SyncPrefObserver> sync_pref_observers_;
206 205
207 // The preference that controls whether sync is under control by 206 // The preference that controls whether sync is under control by
208 // configuration management. 207 // configuration management.
209 BooleanPrefMember pref_sync_managed_; 208 BooleanPrefMember pref_sync_managed_;
210 209
211 // Groups of prefs that always have the same value as a "master" pref. 210 // Groups of prefs that always have the same value as a "master" pref.
212 // For example, the APPS group has {APP_NOTIFICATIONS, APP_SETTINGS} 211 // For example, the APPS group has {APP_NOTIFICATIONS, APP_SETTINGS}
213 // (as well as APPS, but that is implied), so 212 // (as well as APPS, but that is implied), so
214 // pref_groups_[syncer::APPS] = { syncer::APP_NOTIFICATIONS, 213 // pref_groups_[APPS] = { APP_NOTIFICATIONS,
215 // syncer::APP_SETTINGS } 214 // APP_SETTINGS }
216 // pref_groups_[syncer::EXTENSIONS] = { syncer::EXTENSION_SETTINGS } 215 // pref_groups_[EXTENSIONS] = { EXTENSION_SETTINGS }
217 // etc. 216 // etc.
218 typedef std::map<syncer::ModelType, syncer::ModelTypeSet> PrefGroupsMap; 217 typedef std::map<ModelType, ModelTypeSet> PrefGroupsMap;
219 PrefGroupsMap pref_groups_; 218 PrefGroupsMap pref_groups_;
220 219
221 DISALLOW_COPY_AND_ASSIGN(SyncPrefs); 220 DISALLOW_COPY_AND_ASSIGN(SyncPrefs);
222 }; 221 };
223 222
224 } // namespace sync_driver 223 } // namespace syncer
225 224
226 #endif // COMPONENTS_SYNC_DRIVER_SYNC_PREFS_H_ 225 #endif // COMPONENTS_SYNC_DRIVER_SYNC_PREFS_H_
OLDNEW
« no previous file with comments | « components/sync/driver/sync_policy_handler_unittest.cc ('k') | components/sync/driver/sync_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698