NetworkDispatcher.smali
.class public Lcom/mopub/volley/NetworkDispatcher;
.super Ljava/lang/Thread;
.source "SourceFile"
# instance fields
.field private final mCache:Lcom/mopub/volley/Cache;
.field private final mDelivery:Lcom/mopub/volley/ResponseDelivery;
.field private final mNetwork:Lcom/mopub/volley/Network;
.field private final mQueue:Ljava/util/concurrent/BlockingQueue;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/concurrent/BlockingQueue<",
"Lcom/mopub/volley/Request<",
"*>;>;"
}
.end annotation
.end field
.field private volatile mQuit:Z
# direct methods
.method public constructor <init>(Ljava/util/concurrent/BlockingQueue;Lcom/mopub/volley/Network;Lcom/mopub/volley/Cache;Lcom/mopub/volley/ResponseDelivery;)V
.registers 6
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Ljava/util/concurrent/BlockingQueue<",
"Lcom/mopub/volley/Request<",
"*>;>;",
"Lcom/mopub/volley/Network;",
"Lcom/mopub/volley/Cache;",
"Lcom/mopub/volley/ResponseDelivery;",
")V"
}
.end annotation
.line 58
invoke-direct {p0}, Ljava/lang/Thread;-><init>()V
const/4 v0, 0x0
.line 46
iput-boolean v0, p0, Lcom/mopub/volley/NetworkDispatcher;->mQuit:Z
.line 59
iput-object p1, p0, Lcom/mopub/volley/NetworkDispatcher;->mQueue:Ljava/util/concurrent/BlockingQueue;
.line 60
iput-object p2, p0, Lcom/mopub/volley/NetworkDispatcher;->mNetwork:Lcom/mopub/volley/Network;
.line 61
iput-object p3, p0, Lcom/mopub/volley/NetworkDispatcher;->mCache:Lcom/mopub/volley/Cache;
.line 62
iput-object p4, p0, Lcom/mopub/volley/NetworkDispatcher;->mDelivery:Lcom/mopub/volley/ResponseDelivery;
return-void
.end method
.method private addTrafficStatsTag(Lcom/mopub/volley/Request;)V
.registers 4
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/mopub/volley/Request<",
"*>;)V"
}
.end annotation
.line 77
sget v0, Landroid/os/Build$VERSION;->SDK_INT:I
const/16 v1, 0xe
if-lt v0, v1, :cond_d
.line 78
invoke-virtual {p1}, Lcom/mopub/volley/Request;->getTrafficStatsTag()I
move-result p1
invoke-static {p1}, Landroid/net/TrafficStats;->setThreadStatsTag(I)V
:cond_d
return-void
.end method
.method private parseAndDeliverNetworkError(Lcom/mopub/volley/Request;Lcom/mopub/volley/VolleyError;)V
.registers 4
.annotation system Ldalvik/annotation/Signature;
value = {
"(",
"Lcom/mopub/volley/Request<",
"*>;",
"Lcom/mopub/volley/VolleyError;",
")V"
}
.end annotation
.line 160
invoke-virtual {p1, p2}, Lcom/mopub/volley/Request;->parseNetworkError(Lcom/mopub/volley/VolleyError;)Lcom/mopub/volley/VolleyError;
move-result-object p2
.line 161
iget-object v0, p0, Lcom/mopub/volley/NetworkDispatcher;->mDelivery:Lcom/mopub/volley/ResponseDelivery;
invoke-interface {v0, p1, p2}, Lcom/mopub/volley/ResponseDelivery;->postError(Lcom/mopub/volley/Request;Lcom/mopub/volley/VolleyError;)V
return-void
.end method
.method private processRequest()V
.registers 8
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/lang/InterruptedException;
}
.end annotation
.line 103
iget-object v0, p0, Lcom/mopub/volley/NetworkDispatcher;->mQueue:Ljava/util/concurrent/BlockingQueue;
invoke-interface {v0}, Ljava/util/concurrent/BlockingQueue;->take()Ljava/lang/Object;
move-result-object v0
check-cast v0, Lcom/mopub/volley/Request;
.line 105
invoke-static {}, Landroid/os/SystemClock;->elapsedRealtime()J
move-result-wide v1
:try_start_c
const-string v3, "network-queue-take"
.line 107
invoke-virtual {v0, v3}, Lcom/mopub/volley/Request;->addMarker(Ljava/lang/String;)V
.line 111
invoke-virtual {v0}, Lcom/mopub/volley/Request;->isCanceled()Z
move-result v3
if-eqz v3, :cond_20
const-string v3, "network-discard-cancelled"
.line 112
invoke-virtual {v0, v3}, Lcom/mopub/volley/Request;->finish(Ljava/lang/String;)V
.line 113
invoke-virtual {v0}, Lcom/mopub/volley/Request;->notifyListenerResponseNotUsable()V
return-void
.line 117
:cond_20
invoke-direct {p0, v0}, Lcom/mopub/volley/NetworkDispatcher;->addTrafficStatsTag(Lcom/mopub/volley/Request;)V
.line 120
iget-object v3, p0, Lcom/mopub/volley/NetworkDispatcher;->mNetwork:Lcom/mopub/volley/Network;
invoke-interface {v3, v0}, Lcom/mopub/volley/Network;->performRequest(Lcom/mopub/volley/Request;)Lcom/mopub/volley/NetworkResponse;
move-result-object v3
const-string v4, "network-http-complete"
.line 121
invoke-virtual {v0, v4}, Lcom/mopub/volley/Request;->addMarker(Ljava/lang/String;)V
.line 125
iget-boolean v4, v3, Lcom/mopub/volley/NetworkResponse;->notModified:Z
if-eqz v4, :cond_41
invoke-virtual {v0}, Lcom/mopub/volley/Request;->hasHadResponseDelivered()Z
move-result v4
if-eqz v4, :cond_41
const-string v3, "not-modified"
.line 126
invoke-virtual {v0, v3}, Lcom/mopub/volley/Request;->finish(Ljava/lang/String;)V
.line 127
invoke-virtual {v0}, Lcom/mopub/volley/Request;->notifyListenerResponseNotUsable()V
return-void
.line 132
:cond_41
invoke-virtual {v0, v3}, Lcom/mopub/volley/Request;->parseNetworkResponse(Lcom/mopub/volley/NetworkResponse;)Lcom/mopub/volley/Response;
move-result-object v3
const-string v4, "network-parse-complete"
.line 133
invoke-virtual {v0, v4}, Lcom/mopub/volley/Request;->addMarker(Ljava/lang/String;)V
.line 137
invoke-virtual {v0}, Lcom/mopub/volley/Request;->shouldCache()Z
move-result v4
if-eqz v4, :cond_64
iget-object v4, v3, Lcom/mopub/volley/Response;->cacheEntry:Lcom/mopub/volley/Cache$Entry;
if-eqz v4, :cond_64
.line 138
iget-object v4, p0, Lcom/mopub/volley/NetworkDispatcher;->mCache:Lcom/mopub/volley/Cache;
invoke-virtual {v0}, Lcom/mopub/volley/Request;->getCacheKey()Ljava/lang/String;
move-result-object v5
iget-object v6, v3, Lcom/mopub/volley/Response;->cacheEntry:Lcom/mopub/volley/Cache$Entry;
invoke-interface {v4, v5, v6}, Lcom/mopub/volley/Cache;->put(Ljava/lang/String;Lcom/mopub/volley/Cache$Entry;)V
const-string v4, "network-cache-written"
.line 139
invoke-virtual {v0, v4}, Lcom/mopub/volley/Request;->addMarker(Ljava/lang/String;)V
.line 143
:cond_64
invoke-virtual {v0}, Lcom/mopub/volley/Request;->markDelivered()V
.line 144
iget-object v4, p0, Lcom/mopub/volley/NetworkDispatcher;->mDelivery:Lcom/mopub/volley/ResponseDelivery;
invoke-interface {v4, v0, v3}, Lcom/mopub/volley/ResponseDelivery;->postResponse(Lcom/mopub/volley/Request;Lcom/mopub/volley/Response;)V
.line 145
invoke-virtual {v0, v3}, Lcom/mopub/volley/Request;->notifyListenerResponseReceived(Lcom/mopub/volley/Response;)V
:try_end_6f
.catch Lcom/mopub/volley/VolleyError; {:try_start_c .. :try_end_6f} :catch_96
.catch Ljava/lang/Exception; {:try_start_c .. :try_end_6f} :catch_70
return-void
:catch_70
move-exception v3
const/4 v4, 0x1
new-array v4, v4, [Ljava/lang/Object;
const/4 v5, 0x0
.line 151
invoke-virtual {v3}, Ljava/lang/Exception;->toString()Ljava/lang/String;
move-result-object v6
aput-object v6, v4, v5
const-string v5, "Unhandled exception %s"
invoke-static {v3, v5, v4}, Lcom/mopub/volley/VolleyLog;->e(Ljava/lang/Throwable;Ljava/lang/String;[Ljava/lang/Object;)V
.line 152
new-instance v4, Lcom/mopub/volley/VolleyError;
invoke-direct {v4, v3}, Lcom/mopub/volley/VolleyError;-><init>(Ljava/lang/Throwable;)V
.line 153
invoke-static {}, Landroid/os/SystemClock;->elapsedRealtime()J
move-result-wide v5
sub-long/2addr v5, v1
invoke-virtual {v4, v5, v6}, Lcom/mopub/volley/VolleyError;->setNetworkTimeMs(J)V
.line 154
iget-object v1, p0, Lcom/mopub/volley/NetworkDispatcher;->mDelivery:Lcom/mopub/volley/ResponseDelivery;
invoke-interface {v1, v0, v4}, Lcom/mopub/volley/ResponseDelivery;->postError(Lcom/mopub/volley/Request;Lcom/mopub/volley/VolleyError;)V
.line 155
invoke-virtual {v0}, Lcom/mopub/volley/Request;->notifyListenerResponseNotUsable()V
return-void
:catch_96
move-exception v3
.line 147
invoke-static {}, Landroid/os/SystemClock;->elapsedRealtime()J
move-result-wide v4
sub-long/2addr v4, v1
invoke-virtual {v3, v4, v5}, Lcom/mopub/volley/VolleyError;->setNetworkTimeMs(J)V
.line 148
invoke-direct {p0, v0, v3}, Lcom/mopub/volley/NetworkDispatcher;->parseAndDeliverNetworkError(Lcom/mopub/volley/Request;Lcom/mopub/volley/VolleyError;)V
.line 149
invoke-virtual {v0}, Lcom/mopub/volley/Request;->notifyListenerResponseNotUsable()V
return-void
.end method
# virtual methods
.method public quit()V
.registers 2
const/4 v0, 0x1
.line 70
iput-boolean v0, p0, Lcom/mopub/volley/NetworkDispatcher;->mQuit:Z
.line 71
invoke-virtual {p0}, Lcom/mopub/volley/NetworkDispatcher;->interrupt()V
return-void
.end method
.method public run()V
.registers 2
const/16 v0, 0xa
.line 84
invoke-static {v0}, Landroid/os/Process;->setThreadPriority(I)V
.line 87
:cond_5
:goto_5
:try_start_5
invoke-direct {p0}, Lcom/mopub/volley/NetworkDispatcher;->processRequest()V
:try_end_8
.catch Ljava/lang/InterruptedException; {:try_start_5 .. :try_end_8} :catch_9
goto :goto_5
.line 90
:catch_9
iget-boolean v0, p0, Lcom/mopub/volley/NetworkDispatcher;->mQuit:Z
if-eqz v0, :cond_5
return-void
.end method