package com.tencent.mm.plugin.game.luggage;

import android.content.Context;
import android.os.Bundle;
import com.tencent.luggage.d.k;
import com.tencent.luggage.webview.a;
import com.tencent.matrix.trace.core.AppMethodBeat;
import com.tencent.mm.ipcinvoker.l;
import com.tencent.mm.ipcinvoker.wx_extension.service.ToolsProcessIPCService;
import com.tencent.mm.sdk.platformtools.ab;
import com.tencent.mm.sdk.platformtools.ah;
import java.util.HashMap;
import java.util.LinkedList;

public final class d {
    private static HashMap<String, a> ezU = new HashMap();
    private static HashMap<String, k> mTT = new HashMap();
    private static LinkedList<String> mTU = new LinkedList();

    static {
        AppMethodBeat.i(135839);
        AppMethodBeat.o(135839);
    }

    public static void a(Class<? extends a> cls, String str, a aVar) {
        AppMethodBeat.i(135835);
        if (!ah.doF()) {
            Bundle bundle = new Bundle();
            bundle.putInt("action_id", 1);
            bundle.putString("preload_url", str);
            bundle.putSerializable("webcore_impl_class", cls);
            ToolsProcessIPCService.a(bundle, b.class, new 1(aVar));
            AppMethodBeat.o(135835);
        } else if (mTU.contains(str)) {
            ab.i("MicroMsg.PreloadGameWebCoreHelp", "preload ing, return");
            aVar.wM();
            AppMethodBeat.o(135835);
        } else {
            mTU.add(str);
            l.q(new 2(cls, str, aVar));
            AppMethodBeat.o(135835);
        }
    }

    public static k aq(Context context, String str) {
        AppMethodBeat.i(135836);
        k kVar = (k) mTT.remove(str);
        if (kVar != null) {
            kVar.setContext(context);
        }
        AppMethodBeat.o(135836);
        return kVar;
    }

    public static k NO(String str) {
        AppMethodBeat.i(135837);
        k kVar = (k) mTT.get(str);
        AppMethodBeat.o(135837);
        return kVar;
    }

    public static void destroy() {
        AppMethodBeat.i(135838);
        if (ah.doF()) {
            for (k destroy : mTT.values()) {
                destroy.destroy();
            }
            mTT.clear();
            AppMethodBeat.o(135838);
            return;
        }
        Bundle bundle = new Bundle();
        bundle.putInt("action_id", 2);
        ToolsProcessIPCService.a(bundle, b.class, null);
        AppMethodBeat.o(135838);
    }
}
