Chromium Code Reviews| Index: sync/syncable/model_type.cc |
| diff --git a/sync/syncable/model_type.cc b/sync/syncable/model_type.cc |
| index 719f65b89dc816b07dfce59e0a8ed1c0ec27b6a7..7f844308e80fca05ca7298e551d90773c95f13bc 100644 |
| --- a/sync/syncable/model_type.cc |
| +++ b/sync/syncable/model_type.cc |
| @@ -27,6 +27,10 @@ namespace syncer { |
| void AddDefaultFieldValue(ModelType datatype, |
| sync_pb::EntitySpecifics* specifics) { |
| + if (VirtualTypes().Has(datatype)) { |
| + NOTREACHED() << "Virtual types have no default field."; |
| + return; |
| + } |
| switch (datatype) { |
| case BOOKMARKS: |
| specifics->mutable_bookmark(); |
| @@ -99,6 +103,8 @@ void AddDefaultFieldValue(ModelType datatype, |
| ModelType GetModelTypeFromSpecificsFieldNumber(int field_number) { |
| for (int i = FIRST_REAL_MODEL_TYPE; i < MODEL_TYPE_COUNT; ++i) { |
| ModelType model_type = ModelTypeFromInt(i); |
| + if (VirtualTypes().Has(model_type)) |
| + continue; |
| if (GetSpecificsFieldNumberFromModelType(model_type) == field_number) |
| return model_type; |
| } |
| @@ -106,6 +112,10 @@ ModelType GetModelTypeFromSpecificsFieldNumber(int field_number) { |
| } |
| int GetSpecificsFieldNumberFromModelType(ModelType model_type) { |
| + if (VirtualTypes().Has(model_type)) { |
| + NOTREACHED() << "Virtual types have no field number."; |
| + return 0; |
| + } |
| switch (model_type) { |
| case BOOKMARKS: |
| return sync_pb::EntitySpecifics::kBookmarkFieldNumber; |
| @@ -299,6 +309,10 @@ ModelTypeSet EncryptableUserTypes() { |
| encryptable_user_types.Remove(HISTORY_DELETE_DIRECTIVES); |
| // Synced notifications are not encrypted since the server must see changes. |
| encryptable_user_types.Remove(SYNCED_NOTIFICATIONS); |
| + // Virtual types have no sync representation and are therefore not encrypted |
| + // either. Their underlying implicit types may or may not be encrypted |
| + // though. |
|
tim (not reviewing)
2013/02/05 02:41:58
'Their underlying implicit types may or may not be
Nicolas Zea
2013/02/07 01:18:48
Done.
|
| + encryptable_user_types.RemoveAll(VirtualTypes()); |
| return encryptable_user_types; |
| } |
| @@ -314,6 +328,12 @@ ModelTypeSet ControlTypes() { |
| return set; |
| } |
| +ModelTypeSet VirtualTypes() { |
| + ModelTypeSet set; |
| + // TODO(zea): add a TABS type here. |
| + return set; |
| +} |
| + |
| bool IsControlType(ModelType model_type) { |
| return ControlTypes().Has(model_type); |
| } |
| @@ -482,6 +502,8 @@ ModelTypeSet ModelTypeSetFromValue(const base::ListValue& value) { |
| // TODO(zea): remove all hardcoded tags in model associators and have them use |
| // this instead. |
| +// NOTE: Virtual types should return empty strings (so that we don't NOTREACHED |
| +// in tests when we verify they have no root node). |
| std::string ModelTypeToRootTag(ModelType type) { |
| switch (type) { |
| case BOOKMARKS: |
| @@ -534,7 +556,8 @@ std::string ModelTypeToRootTag(ModelType type) { |
| } |
| // TODO(akalin): Figure out a better way to do these mappings. |
| - |
| +// Note: Do not include virtual types in this list. They should never receive |
| +// or trigger notifications. |
| namespace { |
| const char kBookmarkNotificationType[] = "BOOKMARK"; |
| const char kPreferenceNotificationType[] = "PREFERENCE"; |