CacheDispatcher.smali
.class public Lcom/tradplus/ads/volley/CacheDispatcher;
.super Ljava/lang/Thread;
# static fields
.field private static final a:Z
# instance fields
.field private final b:Ljava/util/concurrent/BlockingQueue;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/concurrent/BlockingQueue<",
"Lcom/tradplus/ads/volley/Request<",
"*>;>;"
}
.end annotation
.end field
.field private final c:Ljava/util/concurrent/BlockingQueue;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/concurrent/BlockingQueue<",
"Lcom/tradplus/ads/volley/Request<",
"*>;>;"
}
.end annotation
.end field
.field private final d:Lcom/tradplus/ads/volley/Cache;
.field private final e:Lcom/tradplus/ads/volley/ResponseDelivery;
.field private volatile f:Z
# direct methods
.method static constructor <clinit>()V
.registers 1
sget-boolean v0, Lcom/tradplus/ads/volley/VolleyLog;->DEBUG:Z
sput-boolean v0, Lcom/tradplus/ads/volley/CacheDispatcher;->a:Z
return-void
.end method
.method public constructor <init>(Ljava/util/concurrent/BlockingQueue;Ljava/util/concurrent/BlockingQueue;Lcom/tradplus/ads/volley/Cache;Lcom/tradplus/ads/volley/ResponseDelivery;)V
.registers 6
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Ljava/util/concurrent/BlockingQueue<",
"Lcom/tradplus/ads/volley/Request<",
"*>;>;",
"Ljava/util/concurrent/BlockingQueue<",
"Lcom/tradplus/ads/volley/Request<",
"*>;>;",
"Lcom/tradplus/ads/volley/Cache;",
"Lcom/tradplus/ads/volley/ResponseDelivery;",
")V"
}
.end annotation
invoke-direct {p0}, Ljava/lang/Thread;-><init>()V
const/4 v0, 0x0
iput-boolean v0, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->f:Z
iput-object p1, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->b:Ljava/util/concurrent/BlockingQueue;
iput-object p2, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->c:Ljava/util/concurrent/BlockingQueue;
iput-object p3, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->d:Lcom/tradplus/ads/volley/Cache;
iput-object p4, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->e:Lcom/tradplus/ads/volley/ResponseDelivery;
return-void
.end method
.method static synthetic a(Lcom/tradplus/ads/volley/CacheDispatcher;)Ljava/util/concurrent/BlockingQueue;
.registers 1
iget-object p0, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->c:Ljava/util/concurrent/BlockingQueue;
return-object p0
.end method
# virtual methods
.method public quit()V
.registers 2
const/4 v0, 0x1
iput-boolean v0, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->f:Z
invoke-virtual {p0}, Ljava/lang/Thread;->interrupt()V
return-void
.end method
.method public run()V
.registers 6
sget-boolean v0, Lcom/tradplus/ads/volley/CacheDispatcher;->a:Z
if-eqz v0, :cond_c
const/4 v0, 0x0
new-array v0, v0, [Ljava/lang/Object;
const-string v1, "start new dispatcher"
invoke-static {v1, v0}, Lcom/tradplus/ads/volley/VolleyLog;->v(Ljava/lang/String;[Ljava/lang/Object;)V
:cond_c
const/16 v0, 0xa
invoke-static {v0}, Landroid/os/Process;->setThreadPriority(I)V
iget-object v0, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->d:Lcom/tradplus/ads/volley/Cache;
invoke-interface {v0}, Lcom/tradplus/ads/volley/Cache;->initialize()V
:cond_16
:goto_16
:try_start_16
iget-object v0, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->b:Ljava/util/concurrent/BlockingQueue;
invoke-interface {v0}, Ljava/util/concurrent/BlockingQueue;->take()Ljava/lang/Object;
move-result-object v0
check-cast v0, Lcom/tradplus/ads/volley/Request;
const-string v1, "cache-queue-take"
invoke-virtual {v0, v1}, Lcom/tradplus/ads/volley/Request;->addMarker(Ljava/lang/String;)V
invoke-virtual {v0}, Lcom/tradplus/ads/volley/Request;->isCanceled()Z
move-result v1
if-eqz v1, :cond_2f
const-string v1, "cache-discard-canceled"
invoke-virtual {v0, v1}, Lcom/tradplus/ads/volley/Request;->a(Ljava/lang/String;)V
:try_end_2e
.catch Ljava/lang/InterruptedException; {:try_start_16 .. :try_end_2e} :catch_91
goto :goto_16
:cond_2f
const/4 v1, 0x0
:try_start_30
iget-object v2, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->d:Lcom/tradplus/ads/volley/Cache;
invoke-virtual {v0}, Lcom/tradplus/ads/volley/Request;->getCacheKey()Ljava/lang/String;
move-result-object v3
invoke-interface {v2, v3}, Lcom/tradplus/ads/volley/Cache;->get(Ljava/lang/String;)Lcom/tradplus/ads/volley/Cache$Entry;
move-result-object v1
:try_end_3a
.catch Ljava/lang/Exception; {:try_start_30 .. :try_end_3a} :catch_3a
:catch_3a
if-nez v1, :cond_47
:try_start_3c
const-string v1, "cache-miss"
invoke-virtual {v0, v1}, Lcom/tradplus/ads/volley/Request;->addMarker(Ljava/lang/String;)V
iget-object v1, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->c:Ljava/util/concurrent/BlockingQueue;
:goto_43
invoke-interface {v1, v0}, Ljava/util/concurrent/BlockingQueue;->put(Ljava/lang/Object;)V
goto :goto_16
:cond_47
invoke-virtual {v1}, Lcom/tradplus/ads/volley/Cache$Entry;->isExpired()Z
move-result v2
if-eqz v2, :cond_58
const-string v2, "cache-hit-expired"
invoke-virtual {v0, v2}, Lcom/tradplus/ads/volley/Request;->addMarker(Ljava/lang/String;)V
invoke-virtual {v0, v1}, Lcom/tradplus/ads/volley/Request;->setCacheEntry(Lcom/tradplus/ads/volley/Cache$Entry;)Lcom/tradplus/ads/volley/Request;
iget-object v1, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->c:Ljava/util/concurrent/BlockingQueue;
goto :goto_43
:cond_58
const-string v2, "cache-hit"
invoke-virtual {v0, v2}, Lcom/tradplus/ads/volley/Request;->addMarker(Ljava/lang/String;)V
new-instance v2, Lcom/tradplus/ads/volley/NetworkResponse;
iget-object v3, v1, Lcom/tradplus/ads/volley/Cache$Entry;->data:[B
iget-object v4, v1, Lcom/tradplus/ads/volley/Cache$Entry;->responseHeaders:Ljava/util/Map;
invoke-direct {v2, v3, v4}, Lcom/tradplus/ads/volley/NetworkResponse;-><init>([BLjava/util/Map;)V
invoke-virtual {v0, v2}, Lcom/tradplus/ads/volley/Request;->a(Lcom/tradplus/ads/volley/NetworkResponse;)Lcom/tradplus/ads/volley/Response;
move-result-object v2
const-string v3, "cache-hit-parsed"
invoke-virtual {v0, v3}, Lcom/tradplus/ads/volley/Request;->addMarker(Ljava/lang/String;)V
invoke-virtual {v1}, Lcom/tradplus/ads/volley/Cache$Entry;->refreshNeeded()Z
move-result v3
if-nez v3, :cond_7b
iget-object v1, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->e:Lcom/tradplus/ads/volley/ResponseDelivery;
invoke-interface {v1, v0, v2}, Lcom/tradplus/ads/volley/ResponseDelivery;->postResponse(Lcom/tradplus/ads/volley/Request;Lcom/tradplus/ads/volley/Response;)V
goto :goto_16
:cond_7b
const-string v3, "cache-hit-refresh-needed"
invoke-virtual {v0, v3}, Lcom/tradplus/ads/volley/Request;->addMarker(Ljava/lang/String;)V
invoke-virtual {v0, v1}, Lcom/tradplus/ads/volley/Request;->setCacheEntry(Lcom/tradplus/ads/volley/Cache$Entry;)Lcom/tradplus/ads/volley/Request;
const/4 v1, 0x1
iput-boolean v1, v2, Lcom/tradplus/ads/volley/Response;->intermediate:Z
iget-object v1, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->e:Lcom/tradplus/ads/volley/ResponseDelivery;
new-instance v3, Lcom/tradplus/ads/volley/CacheDispatcher$1;
invoke-direct {v3, p0, v0}, Lcom/tradplus/ads/volley/CacheDispatcher$1;-><init>(Lcom/tradplus/ads/volley/CacheDispatcher;Lcom/tradplus/ads/volley/Request;)V
invoke-interface {v1, v0, v2, v3}, Lcom/tradplus/ads/volley/ResponseDelivery;->postResponse(Lcom/tradplus/ads/volley/Request;Lcom/tradplus/ads/volley/Response;Ljava/lang/Runnable;)V
:try_end_90
.catch Ljava/lang/InterruptedException; {:try_start_3c .. :try_end_90} :catch_91
goto :goto_16
:catch_91
nop
iget-boolean v0, p0, Lcom/tradplus/ads/volley/CacheDispatcher;->f:Z
if-eqz v0, :cond_16
return-void
.end method