package com.google.firebase.perf.transport;

import com.google.firebase.inject.Provider;
import com.google.firebase.perf.logging.AndroidLogger;
import com.google.firebase.perf.v1.PerfMetric;
import gi.h;
import gi.i;
import gi.j;

/* JADX INFO: Access modifiers changed from: package-private */
/* loaded from: classes3.dex */
public final class FlgTransport {
    private static final AndroidLogger logger = AndroidLogger.getInstance();
    private i flgTransport;
    private final Provider<j> flgTransportFactoryProvider;
    private final String logSourceName;

    /* JADX INFO: Access modifiers changed from: package-private */
    public FlgTransport(Provider<j> provider, String str) {
        this.logSourceName = str;
        this.flgTransportFactoryProvider = provider;
    }

    private boolean initializeFlgTransportClient() {
        if (this.flgTransport == null) {
            j jVar = this.flgTransportFactoryProvider.get();
            if (jVar != null) {
                this.flgTransport = jVar.a(this.logSourceName, PerfMetric.class, gi.c.b("proto"), new h() { // from class: com.google.firebase.perf.transport.a
                    @Override // gi.h
                    public final Object apply(Object obj) {
                        return ((PerfMetric) obj).toByteArray();
                    }
                });
            } else {
                logger.warn("Flg TransportFactory is not available at the moment");
            }
        }
        return this.flgTransport != null;
    }

    public void log(PerfMetric perfMetric) {
        if (initializeFlgTransportClient()) {
            this.flgTransport.a(gi.d.f(perfMetric));
        } else {
            logger.warn("Unable to dispatch event because Flg Transport is not available");
        }
    }
}
