You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
313 lines
8.5 KiB
313 lines
8.5 KiB
.class public Lcom/android/volley/CacheDispatcher; |
|
.super Ljava/lang/Thread; |
|
.source "CacheDispatcher.java" |
|
|
|
|
|
# static fields |
|
.field private static final DEBUG:Z |
|
|
|
|
|
# instance fields |
|
.field private final mCache:Lcom/android/volley/Cache; |
|
|
|
.field private final mCacheQueue:Ljava/util/concurrent/BlockingQueue; |
|
.annotation system Ldalvik/annotation/Signature; |
|
value = { |
|
"Ljava/util/concurrent/BlockingQueue", |
|
"<", |
|
"Lcom/android/volley/Request", |
|
"<*>;>;" |
|
} |
|
.end annotation |
|
.end field |
|
|
|
.field private final mDelivery:Lcom/android/volley/ResponseDelivery; |
|
|
|
.field private final mNetworkQueue:Ljava/util/concurrent/BlockingQueue; |
|
.annotation system Ldalvik/annotation/Signature; |
|
value = { |
|
"Ljava/util/concurrent/BlockingQueue", |
|
"<", |
|
"Lcom/android/volley/Request", |
|
"<*>;>;" |
|
} |
|
.end annotation |
|
.end field |
|
|
|
.field private volatile mQuit:Z |
|
|
|
|
|
# direct methods |
|
.method static constructor <clinit>()V |
|
.locals 1 |
|
|
|
.prologue |
|
.line 34 |
|
sget-boolean v0, Lcom/android/volley/VolleyLog;->DEBUG:Z |
|
|
|
sput-boolean v0, Lcom/android/volley/CacheDispatcher;->DEBUG:Z |
|
|
|
return-void |
|
.end method |
|
|
|
.method public constructor <init>(Ljava/util/concurrent/BlockingQueue;Ljava/util/concurrent/BlockingQueue;Lcom/android/volley/Cache;Lcom/android/volley/ResponseDelivery;)V |
|
.locals 1 |
|
.annotation system Ldalvik/annotation/Signature; |
|
value = { |
|
"(", |
|
"Ljava/util/concurrent/BlockingQueue", |
|
"<", |
|
"Lcom/android/volley/Request", |
|
"<*>;>;", |
|
"Ljava/util/concurrent/BlockingQueue", |
|
"<", |
|
"Lcom/android/volley/Request", |
|
"<*>;>;", |
|
"Lcom/android/volley/Cache;", |
|
"Lcom/android/volley/ResponseDelivery;", |
|
")V" |
|
} |
|
.end annotation |
|
|
|
.prologue |
|
.line 62 |
|
invoke-direct {p0}, Ljava/lang/Thread;-><init>()V |
|
|
|
.line 49 |
|
const/4 v0, 0x0 |
|
|
|
iput-boolean v0, p0, Lcom/android/volley/CacheDispatcher;->mQuit:Z |
|
|
|
.line 63 |
|
iput-object p1, p0, Lcom/android/volley/CacheDispatcher;->mCacheQueue:Ljava/util/concurrent/BlockingQueue; |
|
|
|
.line 64 |
|
iput-object p2, p0, Lcom/android/volley/CacheDispatcher;->mNetworkQueue:Ljava/util/concurrent/BlockingQueue; |
|
|
|
.line 65 |
|
iput-object p3, p0, Lcom/android/volley/CacheDispatcher;->mCache:Lcom/android/volley/Cache; |
|
|
|
.line 66 |
|
iput-object p4, p0, Lcom/android/volley/CacheDispatcher;->mDelivery:Lcom/android/volley/ResponseDelivery; |
|
|
|
.line 67 |
|
return-void |
|
.end method |
|
|
|
.method static synthetic access$000(Lcom/android/volley/CacheDispatcher;)Ljava/util/concurrent/BlockingQueue; |
|
.locals 1 |
|
|
|
.prologue |
|
.line 32 |
|
iget-object v0, p0, Lcom/android/volley/CacheDispatcher;->mNetworkQueue:Ljava/util/concurrent/BlockingQueue; |
|
|
|
return-object v0 |
|
.end method |
|
|
|
|
|
# virtual methods |
|
.method public quit()V |
|
.locals 1 |
|
|
|
.prologue |
|
.line 74 |
|
const/4 v0, 0x1 |
|
|
|
iput-boolean v0, p0, Lcom/android/volley/CacheDispatcher;->mQuit:Z |
|
|
|
.line 75 |
|
invoke-virtual {p0}, Lcom/android/volley/CacheDispatcher;->interrupt()V |
|
|
|
.line 76 |
|
return-void |
|
.end method |
|
|
|
.method public run()V |
|
.locals 5 |
|
|
|
.prologue |
|
.line 80 |
|
sget-boolean v0, Lcom/android/volley/CacheDispatcher;->DEBUG:Z |
|
|
|
if-eqz v0, :cond_0 |
|
|
|
const-string v0, "start new dispatcher" |
|
|
|
const/4 v1, 0x0 |
|
|
|
new-array v1, v1, [Ljava/lang/Object; |
|
|
|
invoke-static {v0, v1}, Lcom/android/volley/VolleyLog;->v(Ljava/lang/String;[Ljava/lang/Object;)V |
|
|
|
.line 81 |
|
:cond_0 |
|
const/16 v0, 0xa |
|
|
|
invoke-static {v0}, Landroid/os/Process;->setThreadPriority(I)V |
|
|
|
.line 84 |
|
iget-object v0, p0, Lcom/android/volley/CacheDispatcher;->mCache:Lcom/android/volley/Cache; |
|
|
|
invoke-interface {v0}, Lcom/android/volley/Cache;->initialize()V |
|
|
|
.line 90 |
|
:cond_1 |
|
:goto_0 |
|
:try_start_0 |
|
iget-object v0, p0, Lcom/android/volley/CacheDispatcher;->mCacheQueue:Ljava/util/concurrent/BlockingQueue; |
|
|
|
invoke-interface {v0}, Ljava/util/concurrent/BlockingQueue;->take()Ljava/lang/Object; |
|
|
|
move-result-object v0 |
|
|
|
check-cast v0, Lcom/android/volley/Request; |
|
|
|
.line 91 |
|
const-string v1, "cache-queue-take" |
|
|
|
invoke-virtual {v0, v1}, Lcom/android/volley/Request;->addMarker(Ljava/lang/String;)V |
|
|
|
.line 94 |
|
invoke-virtual {v0}, Lcom/android/volley/Request;->isCanceled()Z |
|
|
|
move-result v1 |
|
|
|
if-eqz v1, :cond_2 |
|
|
|
.line 95 |
|
const-string v1, "cache-discard-canceled" |
|
|
|
invoke-virtual {v0, v1}, Lcom/android/volley/Request;->finish(Ljava/lang/String;)V |
|
:try_end_0 |
|
.catch Ljava/lang/InterruptedException; {:try_start_0 .. :try_end_0} :catch_0 |
|
|
|
goto :goto_0 |
|
|
|
.line 149 |
|
:catch_0 |
|
move-exception v0 |
|
|
|
.line 151 |
|
iget-boolean v0, p0, Lcom/android/volley/CacheDispatcher;->mQuit:Z |
|
|
|
if-eqz v0, :cond_1 |
|
|
|
.line 152 |
|
return-void |
|
|
|
.line 100 |
|
:cond_2 |
|
:try_start_1 |
|
iget-object v1, p0, Lcom/android/volley/CacheDispatcher;->mCache:Lcom/android/volley/Cache; |
|
|
|
invoke-virtual {v0}, Lcom/android/volley/Request;->getCacheKey()Ljava/lang/String; |
|
|
|
move-result-object v2 |
|
|
|
invoke-interface {v1, v2}, Lcom/android/volley/Cache;->get(Ljava/lang/String;)Lcom/android/volley/Cache$Entry; |
|
|
|
move-result-object v1 |
|
|
|
.line 101 |
|
if-nez v1, :cond_3 |
|
|
|
.line 102 |
|
const-string v1, "cache-miss" |
|
|
|
invoke-virtual {v0, v1}, Lcom/android/volley/Request;->addMarker(Ljava/lang/String;)V |
|
|
|
.line 104 |
|
iget-object v1, p0, Lcom/android/volley/CacheDispatcher;->mNetworkQueue:Ljava/util/concurrent/BlockingQueue; |
|
|
|
invoke-interface {v1, v0}, Ljava/util/concurrent/BlockingQueue;->put(Ljava/lang/Object;)V |
|
|
|
goto :goto_0 |
|
|
|
.line 109 |
|
:cond_3 |
|
invoke-virtual {v1}, Lcom/android/volley/Cache$Entry;->isExpired()Z |
|
|
|
move-result v2 |
|
|
|
if-eqz v2, :cond_4 |
|
|
|
.line 110 |
|
const-string v2, "cache-hit-expired" |
|
|
|
invoke-virtual {v0, v2}, Lcom/android/volley/Request;->addMarker(Ljava/lang/String;)V |
|
|
|
.line 111 |
|
invoke-virtual {v0, v1}, Lcom/android/volley/Request;->setCacheEntry(Lcom/android/volley/Cache$Entry;)Lcom/android/volley/Request; |
|
|
|
.line 112 |
|
iget-object v1, p0, Lcom/android/volley/CacheDispatcher;->mNetworkQueue:Ljava/util/concurrent/BlockingQueue; |
|
|
|
invoke-interface {v1, v0}, Ljava/util/concurrent/BlockingQueue;->put(Ljava/lang/Object;)V |
|
|
|
goto :goto_0 |
|
|
|
.line 117 |
|
:cond_4 |
|
const-string v2, "cache-hit" |
|
|
|
invoke-virtual {v0, v2}, Lcom/android/volley/Request;->addMarker(Ljava/lang/String;)V |
|
|
|
.line 118 |
|
new-instance v2, Lcom/android/volley/NetworkResponse; |
|
|
|
iget-object v3, v1, Lcom/android/volley/Cache$Entry;->data:[B |
|
|
|
iget-object v4, v1, Lcom/android/volley/Cache$Entry;->responseHeaders:Ljava/util/Map; |
|
|
|
invoke-direct {v2, v3, v4}, Lcom/android/volley/NetworkResponse;-><init>([BLjava/util/Map;)V |
|
|
|
invoke-virtual {v0, v2}, Lcom/android/volley/Request;->parseNetworkResponse(Lcom/android/volley/NetworkResponse;)Lcom/android/volley/Response; |
|
|
|
move-result-object v2 |
|
|
|
.line 120 |
|
const-string v3, "cache-hit-parsed" |
|
|
|
invoke-virtual {v0, v3}, Lcom/android/volley/Request;->addMarker(Ljava/lang/String;)V |
|
|
|
.line 122 |
|
invoke-virtual {v1}, Lcom/android/volley/Cache$Entry;->refreshNeeded()Z |
|
|
|
move-result v3 |
|
|
|
if-nez v3, :cond_5 |
|
|
|
.line 124 |
|
iget-object v1, p0, Lcom/android/volley/CacheDispatcher;->mDelivery:Lcom/android/volley/ResponseDelivery; |
|
|
|
invoke-interface {v1, v0, v2}, Lcom/android/volley/ResponseDelivery;->postResponse(Lcom/android/volley/Request;Lcom/android/volley/Response;)V |
|
|
|
goto :goto_0 |
|
|
|
.line 129 |
|
:cond_5 |
|
const-string v3, "cache-hit-refresh-needed" |
|
|
|
invoke-virtual {v0, v3}, Lcom/android/volley/Request;->addMarker(Ljava/lang/String;)V |
|
|
|
.line 130 |
|
invoke-virtual {v0, v1}, Lcom/android/volley/Request;->setCacheEntry(Lcom/android/volley/Cache$Entry;)Lcom/android/volley/Request; |
|
|
|
.line 133 |
|
const/4 v1, 0x1 |
|
|
|
iput-boolean v1, v2, Lcom/android/volley/Response;->intermediate:Z |
|
|
|
.line 137 |
|
iget-object v1, p0, Lcom/android/volley/CacheDispatcher;->mDelivery:Lcom/android/volley/ResponseDelivery; |
|
|
|
new-instance v3, Lcom/android/volley/CacheDispatcher$1; |
|
|
|
invoke-direct {v3, p0, v0}, Lcom/android/volley/CacheDispatcher$1;-><init>(Lcom/android/volley/CacheDispatcher;Lcom/android/volley/Request;)V |
|
|
|
invoke-interface {v1, v0, v2, v3}, Lcom/android/volley/ResponseDelivery;->postResponse(Lcom/android/volley/Request;Lcom/android/volley/Response;Ljava/lang/Runnable;)V |
|
:try_end_1 |
|
.catch Ljava/lang/InterruptedException; {:try_start_1 .. :try_end_1} :catch_0 |
|
|
|
goto/16 :goto_0 |
|
.end method
|
|
|