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

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

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