| 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 #include "sync/internal_api/public/base/model_type.h" | 5 #include "sync/internal_api/public/base/model_type.h" |
| 6 | 6 |
| 7 #include "base/string_split.h" | 7 #include "base/string_split.h" |
| 8 #include "base/values.h" | 8 #include "base/values.h" |
| 9 #include "sync/protocol/app_notification_specifics.pb.h" | 9 #include "sync/protocol/app_notification_specifics.pb.h" |
| 10 #include "sync/protocol/app_setting_specifics.pb.h" | 10 #include "sync/protocol/app_setting_specifics.pb.h" |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 break; | 137 break; |
| 138 default: | 138 default: |
| 139 NOTREACHED() << "No known extension for model type."; | 139 NOTREACHED() << "No known extension for model type."; |
| 140 return 0; | 140 return 0; |
| 141 } | 141 } |
| 142 NOTREACHED() << "Needed for linux_keep_shadow_stacks because of " | 142 NOTREACHED() << "Needed for linux_keep_shadow_stacks because of " |
| 143 << "http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20681"; | 143 << "http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20681"; |
| 144 return 0; | 144 return 0; |
| 145 } | 145 } |
| 146 | 146 |
| 147 FullModelTypeSet ToFullModelTypeSet(ModelTypeSet in) { |
| 148 FullModelTypeSet out; |
| 149 for (ModelTypeSet::Iterator i = in.First(); i.Good(); i.Inc()) { |
| 150 out.Put(i.Get()); |
| 151 } |
| 152 return out; |
| 153 } |
| 154 |
| 147 // Note: keep this consistent with GetModelType in syncable.cc! | 155 // Note: keep this consistent with GetModelType in syncable.cc! |
| 148 ModelType GetModelType(const sync_pb::SyncEntity& sync_entity) { | 156 ModelType GetModelType(const sync_pb::SyncEntity& sync_entity) { |
| 149 DCHECK(!IsRoot(sync_entity)); // Root shouldn't ever go over the wire. | 157 DCHECK(!IsRoot(sync_entity)); // Root shouldn't ever go over the wire. |
| 150 | 158 |
| 151 if (sync_entity.deleted()) | 159 if (sync_entity.deleted()) |
| 152 return UNSPECIFIED; | 160 return UNSPECIFIED; |
| 153 | 161 |
| 154 // Backwards compatibility with old (pre-specifics) protocol. | 162 // Backwards compatibility with old (pre-specifics) protocol. |
| 155 if (sync_entity.has_bookmarkdata()) | 163 if (sync_entity.has_bookmarkdata()) |
| 156 return BOOKMARKS; | 164 return BOOKMARKS; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 if (specifics.has_app_notification()) | 227 if (specifics.has_app_notification()) |
| 220 return APP_NOTIFICATIONS; | 228 return APP_NOTIFICATIONS; |
| 221 | 229 |
| 222 return UNSPECIFIED; | 230 return UNSPECIFIED; |
| 223 } | 231 } |
| 224 | 232 |
| 225 bool ShouldMaintainPosition(ModelType model_type) { | 233 bool ShouldMaintainPosition(ModelType model_type) { |
| 226 return model_type == BOOKMARKS; | 234 return model_type == BOOKMARKS; |
| 227 } | 235 } |
| 228 | 236 |
| 237 ModelTypeSet UserTypes() { |
| 238 ModelTypeSet set; |
| 239 for (int i = FIRST_USER_MODEL_TYPE; i <= LAST_USER_MODEL_TYPE; ++i) { |
| 240 set.Put(ModelTypeFromInt(i)); |
| 241 } |
| 242 return set; |
| 243 } |
| 244 |
| 245 ModelTypeSet ControlTypes() { |
| 246 ModelTypeSet set; |
| 247 for (int i = FIRST_CONTROL_MODEL_TYPE; i <= LAST_CONTROL_MODEL_TYPE; ++i) { |
| 248 set.Put(ModelTypeFromInt(i)); |
| 249 } |
| 250 return set; |
| 251 } |
| 252 |
| 253 bool IsControlType(ModelType model_type) { |
| 254 return ControlTypes().Has(model_type); |
| 255 } |
| 256 |
| 229 const char* ModelTypeToString(ModelType model_type) { | 257 const char* ModelTypeToString(ModelType model_type) { |
| 230 // This is used in serialization routines as well as for displaying debug | 258 // This is used in serialization routines as well as for displaying debug |
| 231 // information. Do not attempt to change these string values unless you know | 259 // information. Do not attempt to change these string values unless you know |
| 232 // what you're doing. | 260 // what you're doing. |
| 233 switch (model_type) { | 261 switch (model_type) { |
| 234 case TOP_LEVEL_FOLDER: | 262 case TOP_LEVEL_FOLDER: |
| 235 return "Top Level Folder"; | 263 return "Top Level Folder"; |
| 236 case UNSPECIFIED: | 264 case UNSPECIFIED: |
| 237 return "Unspecified"; | 265 return "Unspecified"; |
| 238 case BOOKMARKS: | 266 case BOOKMARKS: |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 531 *model_type = UNSPECIFIED; | 559 *model_type = UNSPECIFIED; |
| 532 return false; | 560 return false; |
| 533 } | 561 } |
| 534 } | 562 } |
| 535 | 563 |
| 536 bool IsRealDataType(ModelType model_type) { | 564 bool IsRealDataType(ModelType model_type) { |
| 537 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; | 565 return model_type >= FIRST_REAL_MODEL_TYPE && model_type < MODEL_TYPE_COUNT; |
| 538 } | 566 } |
| 539 | 567 |
| 540 } // namespace syncer | 568 } // namespace syncer |
| OLD | NEW |