package com.google.firebase.perf;

import com.google.android.gms.measurement.api.AppMeasurementSdk;
import com.google.firebase.Firebase;
import com.google.firebase.perf.metrics.HttpMetric;
import com.google.firebase.perf.metrics.Trace;
import dn.l;
import kotlin.Metadata;
import kotlin.jvm.internal.r;
import kotlin.jvm.internal.t;

@Metadata(d1 = {"\u0000*\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0003\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\b\u0004\u001a$\u0010\u0004\u001a\u00020\u0002*\u00020\u00002\u0012\u0010\u0003\u001a\u000e\u0012\u0004\u0012\u00020\u0000\u0012\u0004\u0012\u00020\u00020\u0001H\u0086\bø\u0001\u0000\u001a1\u0010\u0004\u001a\u00028\u0000\"\u0004\b\u0000\u0010\u0005*\u00020\u00062\u0012\u0010\u0003\u001a\u000e\u0012\u0004\u0012\u00020\u0006\u0012\u0004\u0012\u00028\u00000\u0001H\u0086\bø\u0001\u0000¢\u0006\u0004\b\u0004\u0010\u0007\u001a5\u0010\u0004\u001a\u00028\u0000\"\u0004\b\u0000\u0010\u00052\u0006\u0010\t\u001a\u00020\b2\u0012\u0010\u0003\u001a\u000e\u0012\u0004\u0012\u00020\u0006\u0012\u0004\u0012\u00028\u00000\u0001H\u0086\bø\u0001\u0000¢\u0006\u0004\b\u0004\u0010\n\"\u0015\u0010\u000f\u001a\u00020\f*\u00020\u000b8F¢\u0006\u0006\u001a\u0004\b\r\u0010\u000e\u0082\u0002\u0007\n\u0005\b\u009920\u0001¨\u0006\u0010"}, d2 = {"Lcom/google/firebase/perf/metrics/HttpMetric;", "Lkotlin/Function1;", "Lrm/n0;", "block", "trace", "T", "Lcom/google/firebase/perf/metrics/Trace;", "(Lcom/google/firebase/perf/metrics/Trace;Ldn/l;)Ljava/lang/Object;", "", AppMeasurementSdk.ConditionalUserProperty.NAME, "(Ljava/lang/String;Ldn/l;)Ljava/lang/Object;", "Lcom/google/firebase/Firebase;", "Lcom/google/firebase/perf/FirebasePerformance;", "getPerformance", "(Lcom/google/firebase/Firebase;)Lcom/google/firebase/perf/FirebasePerformance;", "performance", "com.google.firebase-firebase-perf"}, k = 2, mv = {1, 8, 0})
/* loaded from: classes3.dex */
public final class PerformanceKt {
    public static final FirebasePerformance getPerformance(Firebase firebase) {
        t.g(firebase, "<this>");
        FirebasePerformance firebasePerformance = FirebasePerformance.getInstance();
        t.f(firebasePerformance, "getInstance()");
        return firebasePerformance;
    }

    public static final void trace(HttpMetric httpMetric, l block) {
        t.g(httpMetric, "<this>");
        t.g(block, "block");
        httpMetric.start();
        try {
            block.invoke(httpMetric);
        } finally {
            r.b(1);
            httpMetric.stop();
            r.a(1);
        }
    }

    public static final <T> T trace(Trace trace, l block) {
        t.g(trace, "<this>");
        t.g(block, "block");
        trace.start();
        try {
            return (T) block.invoke(trace);
        } finally {
            r.b(1);
            trace.stop();
            r.a(1);
        }
    }

    public static final <T> T trace(String name, l block) {
        t.g(name, "name");
        t.g(block, "block");
        Trace create = Trace.create(name);
        t.f(create, "create(name)");
        create.start();
        try {
            return (T) block.invoke(create);
        } finally {
            r.b(1);
            create.stop();
            r.a(1);
        }
    }
}
