package a.c.b.z.g;

import a.c.b.s;
import a.c.b.z.c;
import android.os.SystemClock;
import com.google.common.util.concurrent.AbstractFuture;
import java.util.concurrent.Delayed;
import java.util.concurrent.TimeUnit;

public class d<ResT> extends AbstractFuture<ResT> implements Delayed {
    public static final long e = 3000;

    /* renamed from: a  reason: collision with root package name */
    private final c<ResT> f90a;
    private final long b;
    private final long c;
    private final int d;

    public d(c<ResT> cVar, int i) {
        this(cVar, 3000, i);
    }

    public d(c<ResT> cVar, long j, int i) {
        this.b = SystemClock.uptimeMillis();
        this.f90a = cVar;
        this.c = j;
        this.d = i;
    }

    /* renamed from: a */
    public int compareTo(Delayed delayed) {
        TimeUnit timeUnit = TimeUnit.MILLISECONDS;
        return (int) (getDelay(timeUnit) - delayed.getDelay(timeUnit));
    }

    public c<ResT> a() {
        return this.f90a;
    }

    public void a(s sVar) {
        c<ResT> cVar = this.f90a;
        if (cVar != null) {
            ResT a2 = cVar.a(sVar);
            if (!isCancelled()) {
                set(a2);
                this.f90a.a(a2);
            }
            if (!(a2 instanceof a) && sVar != null) {
                sVar.t();
            }
        }
    }

    public void a(Exception exc) {
        c<ResT> cVar = this.f90a;
        if (cVar != null) {
            cVar.a(exc);
        }
        setException(exc);
    }

    public int b() {
        return this.d;
    }

    public long c() {
        return this.c;
    }

    public long getDelay(TimeUnit timeUnit) {
        long j = this.c;
        if (j == 0) {
            return 0;
        }
        return timeUnit.convert((this.b + j) - SystemClock.uptimeMillis(), TimeUnit.MILLISECONDS);
    }

    @Override // com.google.common.util.concurrent.AbstractFuture
    public String toString() {
        return "RequestFuture{start=" + this.b + ", timeoutMs=" + this.c + ", requestId=" + this.d + '}';
    }
}
