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 // Enumerate the various item subtypes that are supported by sync. | 5 // Enumerate the various item subtypes that are supported by sync. |
6 // Each sync object is expected to have an immutable object type. | 6 // Each sync object is expected to have an immutable object type. |
7 // An object's type is inferred from the type of data it holds. | 7 // An object's type is inferred from the type of data it holds. |
8 | 8 |
9 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_MODEL_TYPE_H_ | 9 #ifndef SYNC_INTERNAL_API_PUBLIC_BASE_MODEL_TYPE_H_ |
10 #define SYNC_INTERNAL_API_PUBLIC_BASE_MODEL_TYPE_H_ | 10 #define SYNC_INTERNAL_API_PUBLIC_BASE_MODEL_TYPE_H_ |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 // - They support custom update application and conflict resolution logic. | 153 // - They support custom update application and conflict resolution logic. |
154 // - All change processing occurs on the sync thread (GROUP_PASSIVE). | 154 // - All change processing occurs on the sync thread (GROUP_PASSIVE). |
155 ModelTypeSet ControlTypes(); | 155 ModelTypeSet ControlTypes(); |
156 | 156 |
157 // Returns true if this is a control type. | 157 // Returns true if this is a control type. |
158 // | 158 // |
159 // See comment above for more information on what makes these types special. | 159 // See comment above for more information on what makes these types special. |
160 bool IsControlType(ModelType model_type); | 160 bool IsControlType(ModelType model_type); |
161 | 161 |
162 // Determine a model type from the field number of its associated | 162 // Determine a model type from the field number of its associated |
163 // EntitySpecifics field. | 163 // EntitySpecifics field. Returns UNSPECIFIED if the field number is |
| 164 // not recognized. |
| 165 // |
| 166 // If you're putting the result in a ModelTypeSet, you should use the |
| 167 // following pattern: |
| 168 // |
| 169 // ModelTypeSet model_types; |
| 170 // // Say we're looping through a list of items, each of which has a |
| 171 // // field number. |
| 172 // for (...) { |
| 173 // int field_number = ...; |
| 174 // ModelType model_type = |
| 175 // GetModelTypeFromSpecificsFieldNumber(field_number); |
| 176 // if (!IsRealDataType(model_type)) { |
| 177 // NOTREACHED() << "Unknown field number " << field_number; |
| 178 // continue; |
| 179 // } |
| 180 // model_types.Put(model_type); |
| 181 // } |
164 ModelType GetModelTypeFromSpecificsFieldNumber(int field_number); | 182 ModelType GetModelTypeFromSpecificsFieldNumber(int field_number); |
165 | 183 |
166 // Return the field number of the EntitySpecifics field associated with | 184 // Return the field number of the EntitySpecifics field associated with |
167 // a model type. | 185 // a model type. |
168 // | 186 // |
169 // Used by tests outside of sync. | 187 // Used by tests outside of sync. |
170 SYNC_EXPORT int GetSpecificsFieldNumberFromModelType( | 188 SYNC_EXPORT int GetSpecificsFieldNumberFromModelType( |
171 ModelType model_type); | 189 ModelType model_type); |
172 | 190 |
173 FullModelTypeSet ToFullModelTypeSet(ModelTypeSet in); | 191 FullModelTypeSet ToFullModelTypeSet(ModelTypeSet in); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
212 // type and |model_type| was filled in. | 230 // type and |model_type| was filled in. |
213 bool NotificationTypeToRealModelType(const std::string& notification_type, | 231 bool NotificationTypeToRealModelType(const std::string& notification_type, |
214 ModelType* model_type); | 232 ModelType* model_type); |
215 | 233 |
216 // Returns true if |model_type| is a real datatype | 234 // Returns true if |model_type| is a real datatype |
217 SYNC_EXPORT bool IsRealDataType(ModelType model_type); | 235 SYNC_EXPORT bool IsRealDataType(ModelType model_type); |
218 | 236 |
219 } // namespace syncer | 237 } // namespace syncer |
220 | 238 |
221 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_MODEL_TYPE_H_ | 239 #endif // SYNC_INTERNAL_API_PUBLIC_BASE_MODEL_TYPE_H_ |
OLD | NEW |