package m4;

import com.google.protobuf.InterfaceC1332t0;
import java.util.ArrayList;
import java.util.List;
import k4.AbstractC2396i;

/* JADX INFO: loaded from: classes3.dex */
public final class J extends AbstractC2396i {

    /* JADX INFO: renamed from: a, reason: collision with root package name */
    public final AbstractC2396i f20650a;

    /* JADX INFO: renamed from: b, reason: collision with root package name */
    public volatile boolean f20651b;

    /* JADX INFO: renamed from: c, reason: collision with root package name */
    public List f20652c = new ArrayList();

    public J(AbstractC2396i abstractC2396i) {
        this.f20650a = abstractC2396i;
    }

    public final void a(Runnable runnable) {
        synchronized (this) {
            try {
                if (this.f20651b) {
                    runnable.run();
                } else {
                    this.f20652c.add(runnable);
                }
            } catch (Throwable th) {
                throw th;
            }
        }
    }

    @Override // k4.AbstractC2396i
    public final void onClose(k4.r0 r0Var, k4.g0 g0Var) {
        a(new C1.o(this, r0Var, g0Var, 7));
    }

    @Override // k4.AbstractC2396i
    public final void onHeaders(k4.g0 g0Var) {
        if (this.f20651b) {
            this.f20650a.onHeaders(g0Var);
        } else {
            a(new E(3, this, g0Var));
        }
    }

    @Override // k4.AbstractC2396i
    public final void onMessage(Object obj) {
        if (this.f20651b) {
            this.f20650a.onMessage(obj);
        } else {
            a(new E(4, this, (InterfaceC1332t0) obj));
        }
    }

    @Override // k4.AbstractC2396i
    public final void onReady() {
        if (this.f20651b) {
            this.f20650a.onReady();
        } else {
            a(new I2.K(this, 5));
        }
    }
}
