This source file includes following definitions.
- getInstance
- registerGenerator
- clearGeneratorMapForTest
package org.chromium.chrome.browser.identity;
import com.google.common.annotations.VisibleForTesting;
import java.util.HashMap;
import java.util.Map;
public final class UniqueIdentificationGeneratorFactory {
private static final Object LOCK = new Object();
private static final Map<String, UniqueIdentificationGenerator> GENERATOR_MAP =
new HashMap<String, UniqueIdentificationGenerator>();
private UniqueIdentificationGeneratorFactory() {
}
public static UniqueIdentificationGenerator getInstance(String generatorType) {
synchronized (LOCK) {
if (!GENERATOR_MAP.containsKey(generatorType)) {
throw new IllegalArgumentException("Unknown generator type " + generatorType);
}
return GENERATOR_MAP.get(generatorType);
}
}
@VisibleForTesting
public static void registerGenerator(String generatorType, UniqueIdentificationGenerator gen,
boolean force) {
synchronized (LOCK) {
if (GENERATOR_MAP.containsKey(generatorType) && !force) {
return;
}
GENERATOR_MAP.put(generatorType, gen);
}
}
@VisibleForTesting
public static void clearGeneratorMapForTest() {
synchronized (LOCK) {
GENERATOR_MAP.clear();
}
}
}