package com.google.android.gms.tasks; import java.util.concurrent.ExecutionException; /* JADX INFO: Access modifiers changed from: package-private */ /* loaded from: classes2.dex */ public final class zzaf implements zzae { private final Object zza = new Object(); private final int zzb; private final zzw zzc; private int zzd; private int zze; private int zzf; private Exception zzg; private boolean zzh; private final void zza() { int i = this.zzd; int i2 = this.zze; int i3 = i + i2 + this.zzf; int i4 = this.zzb; if (i3 == i4) { if (this.zzg == null) { if (this.zzh) { this.zzc.zzc(); return; } else { this.zzc.zzb(null); return; } } this.zzc.zza(new ExecutionException(i2 + " out of " + i4 + " underlying tasks failed", this.zzg)); } } @Override // com.google.android.gms.tasks.OnCanceledListener public final void onCanceled() { synchronized (this.zza) { this.zzf++; this.zzh = true; zza(); } } @Override // com.google.android.gms.tasks.OnFailureListener public final void onFailure(Exception exc) { synchronized (this.zza) { this.zze++; this.zzg = exc; zza(); } } @Override // com.google.android.gms.tasks.OnSuccessListener public final void onSuccess(T t) { synchronized (this.zza) { this.zzd++; zza(); } } public zzaf(int i, zzw zzwVar) { this.zzb = i; this.zzc = zzwVar; } }