package com.google.firebase.messaging; import android.content.Context; import android.content.SharedPreferences; import java.lang.ref.WeakReference; import java.util.concurrent.Executor; /* loaded from: classes3.dex */ public final class TopicsStore { public static WeakReference topicsStoreWeakReference; public final SharedPreferences sharedPreferences; public final Executor syncExecutor; public SharedPreferencesQueue topicOperationsQueue; public TopicsStore(SharedPreferences sharedPreferences, Executor executor) { this.syncExecutor = executor; this.sharedPreferences = sharedPreferences; } public final synchronized void initStore() { this.topicOperationsQueue = SharedPreferencesQueue.createInstance(this.sharedPreferences, "topic_operation_queue", ",", this.syncExecutor); } public static synchronized TopicsStore getInstance(Context context, Executor executor) { TopicsStore topicsStore; synchronized (TopicsStore.class) { try { WeakReference weakReference = topicsStoreWeakReference; topicsStore = weakReference != null ? (TopicsStore) weakReference.get() : null; if (topicsStore == null) { topicsStore = new TopicsStore(context.getSharedPreferences("com.google.android.gms.appid", 0), executor); topicsStore.initStore(); topicsStoreWeakReference = new WeakReference(topicsStore); } } catch (Throwable th) { throw th; } } return topicsStore; } public synchronized TopicOperation getNextTopicOperation() { return TopicOperation.from(this.topicOperationsQueue.peek()); } public synchronized boolean removeTopicOperation(TopicOperation topicOperation) { return this.topicOperationsQueue.remove(topicOperation.serialize()); } }