109 lines
3.8 KiB
Java
109 lines
3.8 KiB
Java
|
package o;
|
||
|
|
||
|
import java.util.ArrayList;
|
||
|
import java.util.HashMap;
|
||
|
import java.util.Iterator;
|
||
|
import java.util.List;
|
||
|
import java.util.Map;
|
||
|
import java.util.concurrent.BlockingQueue;
|
||
|
import o.HJP;
|
||
|
import o.InterfaceC17333vqS;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
/* renamed from: o.hOs, reason: case insensitive filesystem */
|
||
|
/* loaded from: classes.dex */
|
||
|
public final class C15640hOs implements HJP.HBt {
|
||
|
private final qNX a;
|
||
|
private final DqI b;
|
||
|
private final BlockingQueue<HJP<?>> c;
|
||
|
private final Map<String, List<HJP<?>>> e = new HashMap();
|
||
|
private final C1117VzR d = null;
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public C15640hOs(DqI dqI, BlockingQueue<HJP<?>> blockingQueue, qNX qnx) {
|
||
|
this.a = qnx;
|
||
|
this.b = dqI;
|
||
|
this.c = blockingQueue;
|
||
|
}
|
||
|
|
||
|
@Override // o.HJP.HBt
|
||
|
public final void d(HJP<?> hjp, C15788ibz<?> c15788ibz) {
|
||
|
List<HJP<?>> remove;
|
||
|
if (c15788ibz.a != null) {
|
||
|
InterfaceC17333vqS.IeS ieS = c15788ibz.a;
|
||
|
if (ieS.f >= System.currentTimeMillis()) {
|
||
|
String cacheKey = hjp.getCacheKey();
|
||
|
synchronized (this) {
|
||
|
remove = this.e.remove(cacheKey);
|
||
|
}
|
||
|
if (remove != null) {
|
||
|
if (qWd.a) {
|
||
|
qWd.e("Releasing %d waiting requests for cacheKey=%s.", Integer.valueOf(remove.size()), cacheKey);
|
||
|
}
|
||
|
Iterator<HJP<?>> it = remove.iterator();
|
||
|
while (it.hasNext()) {
|
||
|
this.a.e(it.next(), c15788ibz);
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
e(hjp);
|
||
|
}
|
||
|
|
||
|
@Override // o.HJP.HBt
|
||
|
public final void e(HJP<?> hjp) {
|
||
|
BlockingQueue<HJP<?>> blockingQueue;
|
||
|
synchronized (this) {
|
||
|
String cacheKey = hjp.getCacheKey();
|
||
|
List<HJP<?>> remove = this.e.remove(cacheKey);
|
||
|
if (remove != null && !remove.isEmpty()) {
|
||
|
if (qWd.a) {
|
||
|
qWd.e("%d waiting requests for cacheKey=%s; resend to network", Integer.valueOf(remove.size()), cacheKey);
|
||
|
}
|
||
|
HJP<?> remove2 = remove.remove(0);
|
||
|
this.e.put(cacheKey, remove);
|
||
|
remove2.setNetworkRequestCompleteListener(this);
|
||
|
if (this.b != null && (blockingQueue = this.c) != null) {
|
||
|
try {
|
||
|
blockingQueue.put(remove2);
|
||
|
} catch (InterruptedException e) {
|
||
|
qWd.a("Couldn't add request to queue. %s", e.toString());
|
||
|
Thread.currentThread().interrupt();
|
||
|
DqI dqI = this.b;
|
||
|
dqI.b = true;
|
||
|
dqI.interrupt();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
/* JADX INFO: Access modifiers changed from: package-private */
|
||
|
public final boolean c(HJP<?> hjp) {
|
||
|
synchronized (this) {
|
||
|
String cacheKey = hjp.getCacheKey();
|
||
|
if (this.e.containsKey(cacheKey)) {
|
||
|
List<HJP<?>> list = this.e.get(cacheKey);
|
||
|
if (list == null) {
|
||
|
list = new ArrayList<>();
|
||
|
}
|
||
|
hjp.addMarker("waiting-for-response");
|
||
|
list.add(hjp);
|
||
|
this.e.put(cacheKey, list);
|
||
|
if (qWd.a) {
|
||
|
qWd.d("Request for cacheKey=%s is in flight, putting on hold.", cacheKey);
|
||
|
}
|
||
|
return true;
|
||
|
}
|
||
|
this.e.put(cacheKey, null);
|
||
|
hjp.setNetworkRequestCompleteListener(this);
|
||
|
if (qWd.a) {
|
||
|
qWd.d("new request, sending to network %s", cacheKey);
|
||
|
}
|
||
|
return false;
|
||
|
}
|
||
|
}
|
||
|
}
|