RequestQueue.smali
.class public Lcom/mopub/volley/RequestQueue;
.super Ljava/lang/Object;
.source "SourceFile"
# annotations
.annotation system Ldalvik/annotation/MemberClasses;
value = {
Lcom/mopub/volley/RequestQueue$RequestFilter;,
Lcom/mopub/volley/RequestQueue$RequestFinishedListener;
}
.end annotation
# static fields
.field private static final DEFAULT_NETWORK_THREAD_POOL_SIZE:I = 0x4
# instance fields
.field private final mCache:Lcom/mopub/volley/Cache;
.field private mCacheDispatcher:Lcom/mopub/volley/CacheDispatcher;
.field private final mCacheQueue:Ljava/util/concurrent/PriorityBlockingQueue;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/concurrent/PriorityBlockingQueue<",
"Lcom/mopub/volley/Request<",
"*>;>;"
}
.end annotation
.end field
.field private final mCurrentRequests:Ljava/util/Set;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/Set<",
"Lcom/mopub/volley/Request<",
"*>;>;"
}
.end annotation
.end field
.field private final mDelivery:Lcom/mopub/volley/ResponseDelivery;
.field private final mDispatchers:[Lcom/mopub/volley/NetworkDispatcher;
.field private final mFinishedListeners:Ljava/util/List;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/List<",
"Lcom/mopub/volley/RequestQueue$RequestFinishedListener;",
">;"
}
.end annotation
.end field
.field private final mNetwork:Lcom/mopub/volley/Network;
.field private final mNetworkQueue:Ljava/util/concurrent/PriorityBlockingQueue;
.annotation system Ldalvik/annotation/Signature;
value = {
"Ljava/util/concurrent/PriorityBlockingQueue<",
"Lcom/mopub/volley/Request<",
"*>;>;"
}
.end annotation
.end field
.field private final mSequenceGenerator:Ljava/util/concurrent/atomic/AtomicInteger;
# direct methods
.method public constructor <init>(Lcom/mopub/volley/Cache;Lcom/mopub/volley/Network;)V
.registers 4
const/4 v0, 0x4
.line 118
invoke-direct {p0, p1, p2, v0}, Lcom/mopub/volley/RequestQueue;-><init>(Lcom/mopub/volley/Cache;Lcom/mopub/volley/Network;I)V
return-void
.end method
.method public constructor <init>(Lcom/mopub/volley/Cache;Lcom/mopub/volley/Network;I)V
.registers 7
.line 107
new-instance v0, Lcom/mopub/volley/ExecutorDelivery;
new-instance v1, Landroid/os/Handler;
.line 108
invoke-static {}, Landroid/os/Looper;->getMainLooper()Landroid/os/Looper;
move-result-object v2
invoke-direct {v1, v2}, Landroid/os/Handler;-><init>(Landroid/os/Looper;)V
invoke-direct {v0, v1}, Lcom/mopub/volley/ExecutorDelivery;-><init>(Landroid/os/Handler;)V
.line 107
invoke-direct {p0, p1, p2, p3, v0}, Lcom/mopub/volley/RequestQueue;-><init>(Lcom/mopub/volley/Cache;Lcom/mopub/volley/Network;ILcom/mopub/volley/ResponseDelivery;)V
return-void
.end method
.method public constructor <init>(Lcom/mopub/volley/Cache;Lcom/mopub/volley/Network;ILcom/mopub/volley/ResponseDelivery;)V
.registers 6
.line 92
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 45
new-instance v0, Ljava/util/concurrent/atomic/AtomicInteger;
invoke-direct {v0}, Ljava/util/concurrent/atomic/AtomicInteger;-><init>()V
iput-object v0, p0, Lcom/mopub/volley/RequestQueue;->mSequenceGenerator:Ljava/util/concurrent/atomic/AtomicInteger;
.line 52
new-instance v0, Ljava/util/HashSet;
invoke-direct {v0}, Ljava/util/HashSet;-><init>()V
iput-object v0, p0, Lcom/mopub/volley/RequestQueue;->mCurrentRequests:Ljava/util/Set;
.line 55
new-instance v0, Ljava/util/concurrent/PriorityBlockingQueue;
invoke-direct {v0}, Ljava/util/concurrent/PriorityBlockingQueue;-><init>()V
iput-object v0, p0, Lcom/mopub/volley/RequestQueue;->mCacheQueue:Ljava/util/concurrent/PriorityBlockingQueue;
.line 59
new-instance v0, Ljava/util/concurrent/PriorityBlockingQueue;
invoke-direct {v0}, Ljava/util/concurrent/PriorityBlockingQueue;-><init>()V
iput-object v0, p0, Lcom/mopub/volley/RequestQueue;->mNetworkQueue:Ljava/util/concurrent/PriorityBlockingQueue;
.line 80
new-instance v0, Ljava/util/ArrayList;
invoke-direct {v0}, Ljava/util/ArrayList;-><init>()V
iput-object v0, p0, Lcom/mopub/volley/RequestQueue;->mFinishedListeners:Ljava/util/List;
.line 93
iput-object p1, p0, Lcom/mopub/volley/RequestQueue;->mCache:Lcom/mopub/volley/Cache;
.line 94
iput-object p2, p0, Lcom/mopub/volley/RequestQueue;->mNetwork:Lcom/mopub/volley/Network;
.line 95
new-array p1, p3, [Lcom/mopub/volley/NetworkDispatcher;
iput-object p1, p0, Lcom/mopub/volley/RequestQueue;->mDispatchers:[Lcom/mopub/volley/NetworkDispatcher;
.line 96
iput-object p4, p0, Lcom/mopub/volley/RequestQueue;->mDelivery:Lcom/mopub/volley/ResponseDelivery;
return-void
.end method
# virtual methods
.method public add(Lcom/mopub/volley/Request;)Lcom/mopub/volley/Request;
.registers 4
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Lcom/mopub/volley/Request<",
"TT;>;)",
"Lcom/mopub/volley/Request<",
"TT;>;"
}
.end annotation
.line 212
invoke-virtual {p1, p0}, Lcom/mopub/volley/Request;->setRequestQueue(Lcom/mopub/volley/RequestQueue;)Lcom/mopub/volley/Request;
.line 213
iget-object v0, p0, Lcom/mopub/volley/RequestQueue;->mCurrentRequests:Ljava/util/Set;
monitor-enter v0
.line 214
:try_start_6
iget-object v1, p0, Lcom/mopub/volley/RequestQueue;->mCurrentRequests:Ljava/util/Set;
invoke-interface {v1, p1}, Ljava/util/Set;->add(Ljava/lang/Object;)Z
.line 215
monitor-exit v0
:try_end_c
.catchall {:try_start_6 .. :try_end_c} :catchall_2a
.line 218
invoke-virtual {p0}, Lcom/mopub/volley/RequestQueue;->getSequenceNumber()I
move-result v0
invoke-virtual {p1, v0}, Lcom/mopub/volley/Request;->setSequence(I)Lcom/mopub/volley/Request;
const-string v0, "add-to-queue"
.line 219
invoke-virtual {p1, v0}, Lcom/mopub/volley/Request;->addMarker(Ljava/lang/String;)V
.line 222
invoke-virtual {p1}, Lcom/mopub/volley/Request;->shouldCache()Z
move-result v0
if-nez v0, :cond_24
.line 223
iget-object v0, p0, Lcom/mopub/volley/RequestQueue;->mNetworkQueue:Ljava/util/concurrent/PriorityBlockingQueue;
invoke-virtual {v0, p1}, Ljava/util/concurrent/PriorityBlockingQueue;->add(Ljava/lang/Object;)Z
return-object p1
.line 226
:cond_24
iget-object v0, p0, Lcom/mopub/volley/RequestQueue;->mCacheQueue:Ljava/util/concurrent/PriorityBlockingQueue;
invoke-virtual {v0, p1}, Ljava/util/concurrent/PriorityBlockingQueue;->add(Ljava/lang/Object;)Z
return-object p1
:catchall_2a
move-exception p1
.line 215
:try_start_2b
monitor-exit v0
:try_end_2c
.catchall {:try_start_2b .. :try_end_2c} :catchall_2a
throw p1
.end method
.method public addRequestFinishedListener(Lcom/mopub/volley/RequestQueue$RequestFinishedListener;)V
.registers 4
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Lcom/mopub/volley/RequestQueue$RequestFinishedListener<",
"TT;>;)V"
}
.end annotation
.line 248
iget-object v0, p0, Lcom/mopub/volley/RequestQueue;->mFinishedListeners:Ljava/util/List;
monitor-enter v0
.line 249
:try_start_3
iget-object v1, p0, Lcom/mopub/volley/RequestQueue;->mFinishedListeners:Ljava/util/List;
invoke-interface {v1, p1}, Ljava/util/List;->add(Ljava/lang/Object;)Z
.line 250
monitor-exit v0
return-void
:catchall_a
move-exception p1
monitor-exit v0
:try_end_c
.catchall {:try_start_3 .. :try_end_c} :catchall_a
throw p1
.end method
.method public cancelAll(Lcom/mopub/volley/RequestQueue$RequestFilter;)V
.registers 6
.line 180
iget-object v0, p0, Lcom/mopub/volley/RequestQueue;->mCurrentRequests:Ljava/util/Set;
monitor-enter v0
.line 181
:try_start_3
iget-object v1, p0, Lcom/mopub/volley/RequestQueue;->mCurrentRequests:Ljava/util/Set;
invoke-interface {v1}, Ljava/util/Set;->iterator()Ljava/util/Iterator;
move-result-object v1
:cond_9
:goto_9
invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z
move-result v2
if-eqz v2, :cond_1f
invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v2
check-cast v2, Lcom/mopub/volley/Request;
.line 182
invoke-interface {p1, v2}, Lcom/mopub/volley/RequestQueue$RequestFilter;->apply(Lcom/mopub/volley/Request;)Z
move-result v3
if-eqz v3, :cond_9
.line 183
invoke-virtual {v2}, Lcom/mopub/volley/Request;->cancel()V
goto :goto_9
.line 186
:cond_1f
monitor-exit v0
return-void
:catchall_21
move-exception p1
monitor-exit v0
:try_end_23
.catchall {:try_start_3 .. :try_end_23} :catchall_21
goto :goto_25
:goto_24
throw p1
:goto_25
goto :goto_24
.end method
.method public cancelAll(Ljava/lang/Object;)V
.registers 3
if-eqz p1, :cond_b
.line 197
new-instance v0, Lcom/mopub/volley/RequestQueue$1;
invoke-direct {v0, p0, p1}, Lcom/mopub/volley/RequestQueue$1;-><init>(Lcom/mopub/volley/RequestQueue;Ljava/lang/Object;)V
invoke-virtual {p0, v0}, Lcom/mopub/volley/RequestQueue;->cancelAll(Lcom/mopub/volley/RequestQueue$RequestFilter;)V
return-void
.line 195
:cond_b
new-instance p1, Ljava/lang/IllegalArgumentException;
const-string v0, "Cannot cancelAll with a null tag"
invoke-direct {p1, v0}, Ljava/lang/IllegalArgumentException;-><init>(Ljava/lang/String;)V
throw p1
.end method
.method finish(Lcom/mopub/volley/Request;)V
.registers 5
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Lcom/mopub/volley/Request<",
"TT;>;)V"
}
.end annotation
.line 236
iget-object v0, p0, Lcom/mopub/volley/RequestQueue;->mCurrentRequests:Ljava/util/Set;
monitor-enter v0
.line 237
:try_start_3
iget-object v1, p0, Lcom/mopub/volley/RequestQueue;->mCurrentRequests:Ljava/util/Set;
invoke-interface {v1, p1}, Ljava/util/Set;->remove(Ljava/lang/Object;)Z
.line 238
monitor-exit v0
:try_end_9
.catchall {:try_start_3 .. :try_end_9} :catchall_27
.line 239
iget-object v1, p0, Lcom/mopub/volley/RequestQueue;->mFinishedListeners:Ljava/util/List;
monitor-enter v1
.line 240
:try_start_c
iget-object v0, p0, Lcom/mopub/volley/RequestQueue;->mFinishedListeners:Ljava/util/List;
invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator;
move-result-object v0
:goto_12
invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z
move-result v2
if-eqz v2, :cond_22
invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object;
move-result-object v2
check-cast v2, Lcom/mopub/volley/RequestQueue$RequestFinishedListener;
.line 241
invoke-interface {v2, p1}, Lcom/mopub/volley/RequestQueue$RequestFinishedListener;->onRequestFinished(Lcom/mopub/volley/Request;)V
goto :goto_12
.line 243
:cond_22
monitor-exit v1
return-void
:catchall_24
move-exception p1
monitor-exit v1
:try_end_26
.catchall {:try_start_c .. :try_end_26} :catchall_24
throw p1
:catchall_27
move-exception p1
.line 238
:try_start_28
monitor-exit v0
:try_end_29
.catchall {:try_start_28 .. :try_end_29} :catchall_27
goto :goto_2b
:goto_2a
throw p1
:goto_2b
goto :goto_2a
.end method
.method public getCache()Lcom/mopub/volley/Cache;
.registers 2
.line 164
iget-object v0, p0, Lcom/mopub/volley/RequestQueue;->mCache:Lcom/mopub/volley/Cache;
return-object v0
.end method
.method public getSequenceNumber()I
.registers 2
.line 157
iget-object v0, p0, Lcom/mopub/volley/RequestQueue;->mSequenceGenerator:Ljava/util/concurrent/atomic/AtomicInteger;
invoke-virtual {v0}, Ljava/util/concurrent/atomic/AtomicInteger;->incrementAndGet()I
move-result v0
return v0
.end method
.method public removeRequestFinishedListener(Lcom/mopub/volley/RequestQueue$RequestFinishedListener;)V
.registers 4
.annotation system Ldalvik/annotation/Signature;
value = {
"<T:",
"Ljava/lang/Object;",
">(",
"Lcom/mopub/volley/RequestQueue$RequestFinishedListener<",
"TT;>;)V"
}
.end annotation
.line 257
iget-object v0, p0, Lcom/mopub/volley/RequestQueue;->mFinishedListeners:Ljava/util/List;
monitor-enter v0
.line 258
:try_start_3
iget-object v1, p0, Lcom/mopub/volley/RequestQueue;->mFinishedListeners:Ljava/util/List;
invoke-interface {v1, p1}, Ljava/util/List;->remove(Ljava/lang/Object;)Z
.line 259
monitor-exit v0
return-void
:catchall_a
move-exception p1
monitor-exit v0
:try_end_c
.catchall {:try_start_3 .. :try_end_c} :catchall_a
throw p1
.end method
.method public start()V
.registers 7
.line 125
invoke-virtual {p0}, Lcom/mopub/volley/RequestQueue;->stop()V
.line 127
new-instance v0, Lcom/mopub/volley/CacheDispatcher;
iget-object v1, p0, Lcom/mopub/volley/RequestQueue;->mCacheQueue:Ljava/util/concurrent/PriorityBlockingQueue;
iget-object v2, p0, Lcom/mopub/volley/RequestQueue;->mNetworkQueue:Ljava/util/concurrent/PriorityBlockingQueue;
iget-object v3, p0, Lcom/mopub/volley/RequestQueue;->mCache:Lcom/mopub/volley/Cache;
iget-object v4, p0, Lcom/mopub/volley/RequestQueue;->mDelivery:Lcom/mopub/volley/ResponseDelivery;
invoke-direct {v0, v1, v2, v3, v4}, Lcom/mopub/volley/CacheDispatcher;-><init>(Ljava/util/concurrent/BlockingQueue;Ljava/util/concurrent/BlockingQueue;Lcom/mopub/volley/Cache;Lcom/mopub/volley/ResponseDelivery;)V
iput-object v0, p0, Lcom/mopub/volley/RequestQueue;->mCacheDispatcher:Lcom/mopub/volley/CacheDispatcher;
.line 128
invoke-virtual {v0}, Lcom/mopub/volley/CacheDispatcher;->start()V
const/4 v0, 0x0
.line 131
:goto_16
iget-object v1, p0, Lcom/mopub/volley/RequestQueue;->mDispatchers:[Lcom/mopub/volley/NetworkDispatcher;
array-length v1, v1
if-ge v0, v1, :cond_32
.line 132
new-instance v1, Lcom/mopub/volley/NetworkDispatcher;
iget-object v2, p0, Lcom/mopub/volley/RequestQueue;->mNetworkQueue:Ljava/util/concurrent/PriorityBlockingQueue;
iget-object v3, p0, Lcom/mopub/volley/RequestQueue;->mNetwork:Lcom/mopub/volley/Network;
iget-object v4, p0, Lcom/mopub/volley/RequestQueue;->mCache:Lcom/mopub/volley/Cache;
iget-object v5, p0, Lcom/mopub/volley/RequestQueue;->mDelivery:Lcom/mopub/volley/ResponseDelivery;
invoke-direct {v1, v2, v3, v4, v5}, Lcom/mopub/volley/NetworkDispatcher;-><init>(Ljava/util/concurrent/BlockingQueue;Lcom/mopub/volley/Network;Lcom/mopub/volley/Cache;Lcom/mopub/volley/ResponseDelivery;)V
.line 134
iget-object v2, p0, Lcom/mopub/volley/RequestQueue;->mDispatchers:[Lcom/mopub/volley/NetworkDispatcher;
aput-object v1, v2, v0
.line 135
invoke-virtual {v1}, Lcom/mopub/volley/NetworkDispatcher;->start()V
add-int/lit8 v0, v0, 0x1
goto :goto_16
:cond_32
return-void
.end method
.method public stop()V
.registers 5
.line 143
iget-object v0, p0, Lcom/mopub/volley/RequestQueue;->mCacheDispatcher:Lcom/mopub/volley/CacheDispatcher;
if-eqz v0, :cond_7
.line 144
invoke-virtual {v0}, Lcom/mopub/volley/CacheDispatcher;->quit()V
.line 146
:cond_7
iget-object v0, p0, Lcom/mopub/volley/RequestQueue;->mDispatchers:[Lcom/mopub/volley/NetworkDispatcher;
array-length v1, v0
const/4 v2, 0x0
:goto_b
if-ge v2, v1, :cond_17
aget-object v3, v0, v2
if-eqz v3, :cond_14
.line 148
invoke-virtual {v3}, Lcom/mopub/volley/NetworkDispatcher;->quit()V
:cond_14
add-int/lit8 v2, v2, 0x1
goto :goto_b
:cond_17
return-void
.end method