OLD | NEW |
---|---|
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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_BASE_MODEL_TYPE_H_ | 5 #ifndef COMPONENTS_SYNC_BASE_MODEL_TYPE_H_ |
6 #define COMPONENTS_SYNC_BASE_MODEL_TYPE_H_ | 6 #define COMPONENTS_SYNC_BASE_MODEL_TYPE_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <memory> | 9 #include <memory> |
10 #include <ostream> | 10 #include <ostream> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 // An object representing a browser session. | 84 // An object representing a browser session. |
85 SESSIONS, | 85 SESSIONS, |
86 // An app object. | 86 // An app object. |
87 APPS, | 87 APPS, |
88 // An app setting from the extension settings API. | 88 // An app setting from the extension settings API. |
89 APP_SETTINGS, | 89 APP_SETTINGS, |
90 // An extension setting from the extension settings API. | 90 // An extension setting from the extension settings API. |
91 EXTENSION_SETTINGS, | 91 EXTENSION_SETTINGS, |
92 // App notifications. | 92 // App notifications. |
93 APP_NOTIFICATIONS, // Deprecated. | 93 APP_NOTIFICATIONS, // Deprecated. |
94 // History delete directives. | 94 // History delete directives. |
pavely
2017/02/23 23:23:03
Seems like git cl format messed up indentation.
skym
2017/02/24 18:59:07
It does. I've moved the Deprecated text onto the l
| |
95 HISTORY_DELETE_DIRECTIVES, | 95 HISTORY_DELETE_DIRECTIVES, |
96 // Synced push notifications. | 96 // Synced push notifications. |
97 SYNCED_NOTIFICATIONS, // Deprecated. | 97 SYNCED_NOTIFICATIONS, // Deprecated. |
98 // Synced Notification app info. | 98 // Synced Notification app info. |
99 SYNCED_NOTIFICATION_APP_INFO, // Deprecated. | 99 SYNCED_NOTIFICATION_APP_INFO, // Deprecated. |
100 // Custom spelling dictionary. | 100 // Custom spelling dictionary. |
101 DICTIONARY, | 101 DICTIONARY, |
102 // Favicon images. | 102 // Favicon images. |
103 FAVICON_IMAGES, | 103 FAVICON_IMAGES, |
104 // Favicon tracking information. | 104 // Favicon tracking information. |
105 FAVICON_TRACKING, | 105 FAVICON_TRACKING, |
106 // Client-specific metadata, synced before other user types. | 106 // Client-specific metadata, synced before other user types. |
107 DEVICE_INFO, | 107 DEVICE_INFO, |
108 // These preferences are synced before other user types and are never | 108 // These preferences are synced before other user types and are never |
109 // encrypted. | 109 // encrypted. |
110 PRIORITY_PREFERENCES, | 110 PRIORITY_PREFERENCES, |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
154 EXPERIMENTS, | 154 EXPERIMENTS, |
155 LAST_CONTROL_MODEL_TYPE = EXPERIMENTS, | 155 LAST_CONTROL_MODEL_TYPE = EXPERIMENTS, |
156 LAST_REAL_MODEL_TYPE = LAST_CONTROL_MODEL_TYPE, | 156 LAST_REAL_MODEL_TYPE = LAST_CONTROL_MODEL_TYPE, |
157 | 157 |
158 // If you are adding a new sync datatype that is exposed to the user via the | 158 // If you are adding a new sync datatype that is exposed to the user via the |
159 // sync preferences UI, be sure to update the list in | 159 // sync preferences UI, be sure to update the list in |
160 // components/sync/driver/user_selectable_sync_type.h so that the UMA | 160 // components/sync/driver/user_selectable_sync_type.h so that the UMA |
161 // histograms for sync include your new type. In this case, be sure to also | 161 // histograms for sync include your new type. In this case, be sure to also |
162 // update the UserSelectableTypes() definition in | 162 // update the UserSelectableTypes() definition in |
163 // sync/syncable/model_type.cc. | 163 // sync/syncable/model_type.cc. |
164 | |
165 // Additionally, enum SyncModelTypes and suffix SyncModelType need to be | |
166 // updated in histograms.xml for all new types. | |
164 MODEL_TYPE_COUNT, | 167 MODEL_TYPE_COUNT, |
165 }; | 168 }; |
166 | 169 |
167 using ModelTypeSet = | 170 using ModelTypeSet = |
168 EnumSet<ModelType, FIRST_REAL_MODEL_TYPE, LAST_REAL_MODEL_TYPE>; | 171 EnumSet<ModelType, FIRST_REAL_MODEL_TYPE, LAST_REAL_MODEL_TYPE>; |
169 using FullModelTypeSet = EnumSet<ModelType, UNSPECIFIED, LAST_REAL_MODEL_TYPE>; | 172 using FullModelTypeSet = EnumSet<ModelType, UNSPECIFIED, LAST_REAL_MODEL_TYPE>; |
170 using ModelTypeNameMap = std::map<ModelType, const char*>; | 173 using ModelTypeNameMap = std::map<ModelType, const char*>; |
171 | 174 |
172 inline ModelType ModelTypeFromInt(int i) { | 175 inline ModelType ModelTypeFromInt(int i) { |
173 DCHECK_GE(i, 0); | 176 DCHECK_GE(i, 0); |
174 DCHECK_LT(i, MODEL_TYPE_COUNT); | 177 DCHECK_LT(i, MODEL_TYPE_COUNT); |
175 return static_cast<ModelType>(i); | 178 return static_cast<ModelType>(i); |
176 } | 179 } |
177 | 180 |
178 // Used by tests outside of sync/. | 181 // Used to mark the type of EntitySpecifics that has no actual data. |
179 void AddDefaultFieldValue(ModelType datatype, | 182 void AddDefaultFieldValue(ModelType type, sync_pb::EntitySpecifics* specifics); |
180 sync_pb::EntitySpecifics* specifics); | |
181 | 183 |
182 // Extract the model type of a SyncEntity protocol buffer. ModelType is a | 184 // Extract the model type of a SyncEntity protocol buffer. ModelType is a |
183 // local concept: the enum is not in the protocol. The SyncEntity's ModelType | 185 // local concept: the enum is not in the protocol. The SyncEntity's ModelType |
184 // is inferred from the presence of particular datatype field in the | 186 // is inferred from the presence of particular datatype field in the |
185 // entity specifics. | 187 // entity specifics. |
186 ModelType GetModelType(const sync_pb::SyncEntity& sync_entity); | 188 ModelType GetModelType(const sync_pb::SyncEntity& sync_entity); |
187 | 189 |
188 // Extract the model type from an EntitySpecifics field. Note that there | 190 // Extract the model type from an EntitySpecifics field. Note that there |
189 // are some ModelTypes (like TOP_LEVEL_FOLDER) that can't be inferred this way; | 191 // are some ModelTypes (like TOP_LEVEL_FOLDER) that can't be inferred this way; |
190 // prefer using GetModelType where possible. | 192 // prefer using GetModelType where possible. |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
348 | 350 |
349 // Returns true if |model_type| supports parent-child hierarchy or entries. | 351 // Returns true if |model_type| supports parent-child hierarchy or entries. |
350 bool TypeSupportsHierarchy(ModelType model_type); | 352 bool TypeSupportsHierarchy(ModelType model_type); |
351 | 353 |
352 // Returns true if |model_type| supports ordering of sibling entries. | 354 // Returns true if |model_type| supports ordering of sibling entries. |
353 bool TypeSupportsOrdering(ModelType model_type); | 355 bool TypeSupportsOrdering(ModelType model_type); |
354 | 356 |
355 } // namespace syncer | 357 } // namespace syncer |
356 | 358 |
357 #endif // COMPONENTS_SYNC_BASE_MODEL_TYPE_H_ | 359 #endif // COMPONENTS_SYNC_BASE_MODEL_TYPE_H_ |
OLD | NEW |