Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: components/sync/android/java/src/org/chromium/components/sync/ModelTypeHelper.java

Issue 2130453004: [Sync] Move //sync to //components/sync. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 package org.chromium.sync; 5 package org.chromium.components.sync;
6 6
7 import com.google.ipc.invalidation.external.client.types.ObjectId; 7 import com.google.ipc.invalidation.external.client.types.ObjectId;
8 import com.google.protos.ipc.invalidation.Types; 8 import com.google.protos.ipc.invalidation.Types;
9 9
10 import org.chromium.base.VisibleForTesting; 10 import org.chromium.base.VisibleForTesting;
11 import org.chromium.base.annotations.JNINamespace; 11 import org.chromium.base.annotations.JNINamespace;
12 12
13 import java.util.Collection; 13 import java.util.Collection;
14 import java.util.HashSet; 14 import java.util.HashSet;
15 import java.util.Set; 15 import java.util.Set;
16 16
17 /** 17 /**
18 * Helper methods for dealing with ModelTypes. 18 * Helper methods for dealing with ModelTypes.
19 * 19 *
20 * This class deals primarily with converting ModelTypes into notification types (string 20 * This class deals primarily with converting ModelTypes into notification types (string
21 * representations that are used to register for invalidations) and converting n otification 21 * representations that are used to register for invalidations) and converting n otification
22 * types into the actual ObjectIds used for invalidations. 22 * types into the actual ObjectIds used for invalidations.
23 * 23 *
24 */ 24 */
25 @JNINamespace("syncer") 25 @JNINamespace("syncer")
26 public class ModelTypeHelper { 26 public class ModelTypeHelper {
27 /** 27 /**
28 * Implement this class to override the behavior of 28 * Implement this class to override the behavior of
29 * {@link ModelTypeHelper#toNotificationType()} for tests. 29 * {@link ModelTypeHelper#toNotificationType()} for tests.
30 */ 30 */
31 public interface TestDelegate { 31 public interface TestDelegate { public String toNotificationType(int modelTy pe); }
32 public String toNotificationType(int modelType);
33 }
34 32
35 private static final String TAG = "ModelTypeHelper"; 33 private static final String TAG = "ModelTypeHelper";
36 34
37 private static final Object sLock = new Object(); 35 private static final Object sLock = new Object();
38 36
39 private static final int[] NON_INVALIDATION_TYPES_ARRAY = new int[] { 37 private static final int[] NON_INVALIDATION_TYPES_ARRAY = new int[] {ModelTy pe.PROXY_TABS};
40 ModelType.PROXY_TABS
41 };
42 38
43 private static TestDelegate sDelegate = null; 39 private static TestDelegate sDelegate = null;
44 40
45 // Convenience sets for checking whether a type can have invalidations. Some ModelTypes 41 // Convenience sets for checking whether a type can have invalidations. Some ModelTypes
46 // such as PROXY_TABS are not real types and can't be registered. Initializi ng these 42 // such as PROXY_TABS are not real types and can't be registered. Initializi ng these
47 // once reduces toNotificationType() calls in the isInvalidationType() metho d. 43 // once reduces toNotificationType() calls in the isInvalidationType() metho d.
48 private static Set<String> sNonInvalidationTypes = null; 44 private static Set<String> sNonInvalidationTypes = null;
49 45
50 /** 46 /**
51 * Initializes the non-invalidation sets. Called lazily the first time they' re needed. 47 * Initializes the non-invalidation sets. Called lazily the first time they' re needed.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 return objectIds; 118 return objectIds;
123 } 119 }
124 120
125 @VisibleForTesting 121 @VisibleForTesting
126 public static void setTestDelegate(TestDelegate delegate) { 122 public static void setTestDelegate(TestDelegate delegate) {
127 sDelegate = delegate; 123 sDelegate = delegate;
128 } 124 }
129 125
130 private static native String nativeModelTypeToNotificationType(int modelType ); 126 private static native String nativeModelTypeToNotificationType(int modelType );
131 } 127 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698