Chromium Code Reviews| Index: sync/android/java/src/org/chromium/sync/internal_api/pub/base/ModelType.java |
| diff --git a/sync/android/java/src/org/chromium/sync/internal_api/pub/base/ModelType.java b/sync/android/java/src/org/chromium/sync/internal_api/pub/base/ModelType.java |
| index b2a6877624aa53c75282ae97b70202fb441a0af7..4fb8d39747c7a4d4f110b341b273d543a1a32bf7 100644 |
| --- a/sync/android/java/src/org/chromium/sync/internal_api/pub/base/ModelType.java |
| +++ b/sync/android/java/src/org/chromium/sync/internal_api/pub/base/ModelType.java |
| @@ -73,7 +73,12 @@ public enum ModelType { |
| /** |
| * A favicon tracking object. |
| */ |
| - FAVICON_TRACKING("FAVICON_TRACKING"); |
| + FAVICON_TRACKING("FAVICON_TRACKING"), |
| + /** |
| + * A supervised user setting object. The old name "managed user" is used for backwards |
| + * compatibility. |
| + */ |
| + MANAGED_USER_SETTING("MANAGED_USER_SETTING"); |
| /** Special type representing all possible types. */ |
| public static final String ALL_TYPES_TYPE = "ALL_TYPES"; |
| @@ -85,6 +90,7 @@ public enum ModelType { |
| private final boolean mNonInvalidationType; |
| ModelType(String modelType, boolean nonInvalidationType) { |
| + assert nonInvalidationType || modelType == toString(); |
|
nyquist
2014/08/28 15:03:34
Never compare two strings in Java using ==, use .e
Bernhard Bauer
2014/08/28 15:16:47
Done, see https://codereview.chromium.org/51125300
|
| mModelType = modelType; |
| mNonInvalidationType = nonInvalidationType; |
| } |
| @@ -165,21 +171,33 @@ public enum ModelType { |
| * This strips out any {@link ModelType} that is not an invalidation type. |
| */ |
| public static Set<ObjectId> modelTypesToObjectIds(Set<ModelType> modelTypes) { |
| - Set<ObjectId> objectIds = new HashSet<ObjectId>(modelTypes.size()); |
| - for (ModelType modelType : modelTypes) { |
| - if (!modelType.isNonInvalidationType()) { |
| - objectIds.add(modelType.toObjectId()); |
| - } |
| + Set<ModelType> filteredModelTypes = filterOutNonInvalidationTypes(modelTypes); |
| + Set<ObjectId> objectIds = new HashSet<ObjectId>(filteredModelTypes.size()); |
| + for (ModelType modelType : filteredModelTypes) { |
| + objectIds.add(modelType.toObjectId()); |
| } |
| return objectIds; |
| } |
| /** Converts a set of {@link ModelType} to a set of string names. */ |
| - public static Set<String> modelTypesToSyncTypes(Set<ModelType> modelTypes) { |
| + public static Set<String> modelTypesToSyncTypesForTest(Set<ModelType> modelTypes) { |
| Set<String> objectIds = new HashSet<String>(modelTypes.size()); |
| for (ModelType modelType : modelTypes) { |
| objectIds.add(modelType.toString()); |
| } |
| return objectIds; |
| } |
| + |
| + /** Filters out non-invalidation types from a set of {@link ModelType}. */ |
| + @VisibleForTesting |
| + public static Set<ModelType> filterOutNonInvalidationTypes(Set<ModelType> modelTypes) { |
| + Set<ModelType> filteredTypes = new HashSet<ModelType>(modelTypes.size()); |
| + for (ModelType modelType : modelTypes) { |
| + if (!modelType.isNonInvalidationType()) { |
| + filteredTypes.add(modelType); |
| + } |
| + } |
| + return filteredTypes; |
| + } |
| + |
| } |