package com.google.firebase.firestore.local; import com.google.firebase.firestore.auth.User; import com.google.firebase.firestore.util.Assert; import com.google.firebase.firestore.util.Supplier; import java.util.HashMap; import java.util.Map; /* loaded from: classes2.dex */ public final class MemoryPersistence extends Persistence { private ReferenceDelegate referenceDelegate; private boolean started; private final Map mutationQueues = new HashMap(); private final MemoryIndexManager indexManager = new MemoryIndexManager(); private final MemoryTargetCache targetCache = new MemoryTargetCache(this); private final MemoryBundleCache bundleCache = new MemoryBundleCache(); private final MemoryRemoteDocumentCache remoteDocumentCache = new MemoryRemoteDocumentCache(); private final Map overlays = new HashMap(); public static MemoryPersistence createEagerGcMemoryPersistence() { MemoryPersistence memoryPersistence = new MemoryPersistence(); memoryPersistence.setReferenceDelegate(new MemoryEagerReferenceDelegate(memoryPersistence)); return memoryPersistence; } private MemoryPersistence() { } @Override // com.google.firebase.firestore.local.Persistence public final void start() { Assert.hardAssert(!this.started, "MemoryPersistence double-started!", new Object[0]); this.started = true; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.firebase.firestore.local.Persistence public final MutationQueue getMutationQueue(User user, IndexManager indexManager) { MemoryMutationQueue memoryMutationQueue = this.mutationQueues.get(user); if (memoryMutationQueue != null) { return memoryMutationQueue; } MemoryMutationQueue memoryMutationQueue2 = new MemoryMutationQueue(this, user); this.mutationQueues.put(user, memoryMutationQueue2); return memoryMutationQueue2; } /* JADX INFO: Access modifiers changed from: package-private */ public final Iterable getMutationQueues() { return this.mutationQueues.values(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.firebase.firestore.local.Persistence public final DocumentOverlayCache getDocumentOverlayCache(User user) { MemoryDocumentOverlayCache memoryDocumentOverlayCache = this.overlays.get(user); if (memoryDocumentOverlayCache != null) { return memoryDocumentOverlayCache; } MemoryDocumentOverlayCache memoryDocumentOverlayCache2 = new MemoryDocumentOverlayCache(); this.overlays.put(user, memoryDocumentOverlayCache2); return memoryDocumentOverlayCache2; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.firebase.firestore.local.Persistence public final OverlayMigrationManager getOverlayMigrationManager() { return new MemoryOverlayMigrationManager(); } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.firebase.firestore.local.Persistence public final void runTransaction(String str, Runnable runnable) { this.referenceDelegate.onTransactionStarted(); try { runnable.run(); } finally { this.referenceDelegate.onTransactionCommitted(); } } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.firebase.firestore.local.Persistence public final T runTransaction(String str, Supplier supplier) { this.referenceDelegate.onTransactionStarted(); try { return supplier.get(); } finally { this.referenceDelegate.onTransactionCommitted(); } } @Override // com.google.firebase.firestore.local.Persistence public final boolean isStarted() { return this.started; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.firebase.firestore.local.Persistence public final MemoryTargetCache getTargetCache() { return this.targetCache; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.firebase.firestore.local.Persistence public final MemoryRemoteDocumentCache getRemoteDocumentCache() { return this.remoteDocumentCache; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.firebase.firestore.local.Persistence public final ReferenceDelegate getReferenceDelegate() { return this.referenceDelegate; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.firebase.firestore.local.Persistence public final MemoryIndexManager getIndexManager(User user) { return this.indexManager; } /* JADX INFO: Access modifiers changed from: package-private */ @Override // com.google.firebase.firestore.local.Persistence public final BundleCache getBundleCache() { return this.bundleCache; } private void setReferenceDelegate(ReferenceDelegate referenceDelegate) { this.referenceDelegate = referenceDelegate; } }