package com.tencent.mm.plugin.webview.modelcache;

import android.util.SparseArray;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.kernel.g;
import com.tencent.mm.sdk.b.c;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.al;
import java.util.Iterator;
import java.util.Set;

public final class r {
    private volatile al ftB;
    private final Object iRa;
    public final c uoc;
    public final c uod;
    private volatile j uoe;
    final SparseArray<m> uof;
    public final d uog;
    final f uoh;
    public final byte[] uoi;
    public final SparseArray<Set<Object>> uoj;

    /* synthetic */ r(byte b) {
        this();
    }

    private r() {
        AppMethodBeat.i(6886);
        this.uoc = new 1(this);
        this.uod = new 2(this);
        this.uof = new SparseArray();
        this.uog = new d();
        this.uoh = new f();
        this.iRa = new Object();
        this.uoi = new byte[0];
        this.uoj = new SparseArray();
        AppMethodBeat.o(6886);
    }

    public final void release(boolean z) {
        AppMethodBeat.i(6887);
        for (int i = 0; i < this.uof.size(); i++) {
            this.uof.valueAt(i);
        }
        this.uof.clear();
        a.clearCache();
        if (this.ftB != null) {
            synchronized (this.iRa) {
                try {
                    if (this.ftB == null) {
                    } else if (z) {
                        this.ftB.oAl.quit();
                        AppMethodBeat.o(6887);
                    } else {
                        this.ftB.aa(new 4(this, this.ftB));
                        this.ftB = null;
                        AppMethodBeat.o(6887);
                    }
                } finally {
                    while (true) {
                    }
                    AppMethodBeat.o(6887);
                }
            }
        } else {
            AppMethodBeat.o(6887);
        }
    }

    public final al aNS() {
        AppMethodBeat.i(6888);
        if (this.ftB == null) {
            synchronized (this.iRa) {
                try {
                    if (this.ftB == null) {
                        this.ftB = new 3(this, "WebViewCacheWorkerManager#WorkerThread");
                    }
                } catch (Throwable th) {
                    while (true) {
                        AppMethodBeat.o(6888);
                    }
                }
            }
        }
        al alVar = this.ftB;
        AppMethodBeat.o(6888);
        return alVar;
    }

    public final void IP(int i) {
        AppMethodBeat.i(6889);
        if (g.RK()) {
            try {
                a.cYq().uoh.IM(i);
                IQ(i);
                AppMethodBeat.o(6889);
                return;
            } catch (Exception e) {
                ab.e("MicroMsg.WebViewCacheWorkerManager", "onWebViewUIDestroy, accHasReady, but occurred exception = %s", new Object[]{e});
            }
        }
        AppMethodBeat.o(6889);
    }

    private void IQ(int i) {
        Set set;
        AppMethodBeat.i(6890);
        synchronized (this.uoi) {
            try {
                set = (Set) this.uoj.get(i);
            } catch (Throwable th) {
                while (true) {
                    AppMethodBeat.o(6890);
                }
            }
        }
        if (set != null && set.size() > 0) {
            Iterator it = set.iterator();
            while (it.hasNext()) {
                it.next();
                if (this.uoe == null) {
                    this.uoe = new j();
                }
                j jVar = this.uoe;
            }
        }
        AppMethodBeat.o(6890);
    }
}
