package w8;

import java.util.concurrent.ExecutionException;

/* JADX INFO: loaded from: classes2.dex */
public final class n implements f, e, c {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final Object f34231a = new Object();

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public final int f34232b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public final t f34233c;

    /* JADX INFO: renamed from: d, reason: collision with root package name */
    public int f34234d;

    /* JADX INFO: renamed from: e, reason: collision with root package name */
    public int f34235e;

    /* JADX INFO: renamed from: f, reason: collision with root package name */
    public int f34236f;

    /* JADX INFO: renamed from: g, reason: collision with root package name */
    public Exception f34237g;

    /* JADX INFO: renamed from: h, reason: collision with root package name */
    public boolean f34238h;

    public n(int i10, t tVar) {
        this.f34232b = i10;
        this.f34233c = tVar;
    }

    @Override // w8.c
    public final void a() {
        synchronized (this.f34231a) {
            this.f34236f++;
            this.f34238h = true;
            b();
        }
    }

    public final void b() {
        int i10 = this.f34234d + this.f34235e + this.f34236f;
        int i11 = this.f34232b;
        if (i10 == i11) {
            Exception exc = this.f34237g;
            t tVar = this.f34233c;
            if (exc == null) {
                if (this.f34238h) {
                    tVar.l();
                    return;
                } else {
                    tVar.zzb(null);
                    return;
                }
            }
            tVar.k(new ExecutionException(this.f34235e + " out of " + i11 + " underlying tasks failed", this.f34237g));
        }
    }

    @Override // w8.e
    public final void onFailure(Exception exc) {
        synchronized (this.f34231a) {
            this.f34235e++;
            this.f34237g = exc;
            b();
        }
    }

    @Override // w8.f
    public final void onSuccess(Object obj) {
        synchronized (this.f34231a) {
            this.f34234d++;
            b();
        }
    }
}
