diff options
author | bauerb <bauerb@chromium.org> | 2014-08-28 02:20:23 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-28 09:21:38 +0000 |
commit | dab6c6fa3c31a2675db949d36274396abfbcb068 (patch) | |
tree | fd8fb4913097406a1170dd5b91259a6da1b2db71 /sync/android | |
parent | ad468e8b47617a4f9fb70fecfd9ea320e6f8c1cf (diff) | |
download | chromium_src-dab6c6fa3c31a2675db949d36274396abfbcb068.zip chromium_src-dab6c6fa3c31a2675db949d36274396abfbcb068.tar.gz chromium_src-dab6c6fa3c31a2675db949d36274396abfbcb068.tar.bz2 |
Enable invalidations for supervised user settings on Android.
BUG=none
Review URL: https://codereview.chromium.org/493293002
Cr-Commit-Position: refs/heads/master@{#292353}
Diffstat (limited to 'sync/android')
-rw-r--r-- | sync/android/java/src/org/chromium/sync/internal_api/pub/base/ModelType.java | 32 | ||||
-rw-r--r-- | sync/android/javatests/src/org/chromium/sync/notifier/InvalidationServiceTest.java | 8 |
2 files changed, 29 insertions, 11 deletions
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 b2a6877..4fb8d39 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(); 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; + } + } diff --git a/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationServiceTest.java b/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationServiceTest.java index 6a84da6..258c7b6 100644 --- a/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationServiceTest.java +++ b/sync/android/javatests/src/org/chromium/sync/notifier/InvalidationServiceTest.java @@ -529,7 +529,7 @@ public class InvalidationServiceTest extends ServiceTestCase<TestableInvalidatio assertTrue(InvalidationService.getIsClientStartedForTest()); InvalidationPreferences invPrefs = new InvalidationPreferences(getContext()); assertEquals(account, invPrefs.getSavedSyncedAccount()); - assertEquals(ModelType.modelTypesToSyncTypes(desiredRegistrations), + assertEquals(ModelType.modelTypesToSyncTypesForTest(desiredRegistrations), invPrefs.getSavedSyncedTypes()); assertNull(invPrefs.getSavedObjectIds()); assertEquals(1, mStartServiceIntents.size()); @@ -566,7 +566,7 @@ public class InvalidationServiceTest extends ServiceTestCase<TestableInvalidatio private boolean expectedObjectIdsRegistered(Set<ModelType> expectedTypes, Set<ObjectId> expectedObjectIds, boolean isReady) { // Get synced types saved to preferences. - Set<String> expectedSyncTypes = ModelType.modelTypesToSyncTypes(expectedTypes); + Set<String> expectedSyncTypes = ModelType.modelTypesToSyncTypesForTest(expectedTypes); InvalidationPreferences invPrefs = new InvalidationPreferences(getContext()); Set<String> actualSyncTypes = invPrefs.getSavedSyncedTypes(); if (actualSyncTypes == null) { @@ -749,7 +749,7 @@ public class InvalidationServiceTest extends ServiceTestCase<TestableInvalidatio assertFalse(InvalidationService.getIsClientStartedForTest()); InvalidationPreferences invPrefs = new InvalidationPreferences(getContext()); assertEquals(account, invPrefs.getSavedSyncedAccount()); - assertEquals(ModelType.modelTypesToSyncTypes(desiredRegistrations), + assertEquals(ModelType.modelTypesToSyncTypesForTest(desiredRegistrations), invPrefs.getSavedSyncedTypes()); assertEquals(0, mStartServiceIntents.size()); } @@ -777,7 +777,7 @@ public class InvalidationServiceTest extends ServiceTestCase<TestableInvalidatio assertEquals(1, mStartServiceIntents.size()); assertTrue(isAndroidListenerStartIntent(mStartServiceIntents.get(0))); InvalidationPreferences invPrefs = new InvalidationPreferences(getContext()); - assertEquals(ModelType.modelTypesToSyncTypes(desiredRegistrations), + assertEquals(ModelType.modelTypesToSyncTypesForTest(desiredRegistrations), invPrefs.getSavedSyncedTypes()); assertEquals(desiredObjectIds, getService().readRegistrationsFromPrefs()); |