Relay$RelaySource.smali
.class Lokhttp3/internal/cache2/Relay$RelaySource;
.super Ljava/lang/Object;
.source "SourceFile"
# interfaces
.implements Lokio/w;
# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
value = Lokhttp3/internal/cache2/Relay;
.end annotation
.annotation system Ldalvik/annotation/InnerClass;
accessFlags = 0x1
name = "RelaySource"
.end annotation
# instance fields
.field private fileOperator:Lokhttp3/internal/cache2/FileOperator;
.field private sourcePos:J
.field public final synthetic this$0:Lokhttp3/internal/cache2/Relay;
.field private final timeout:Lokio/x;
# direct methods
.method public constructor <init>(Lokhttp3/internal/cache2/Relay;)V
.registers 3
.line 1
iput-object p1, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
.line 2
new-instance v0, Lokio/x;
invoke-direct {v0}, Lokio/x;-><init>()V
iput-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->timeout:Lokio/x;
.line 3
new-instance v0, Lokhttp3/internal/cache2/FileOperator;
iget-object p1, p1, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
invoke-virtual {p1}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
move-result-object p1
invoke-direct {v0, p1}, Lokhttp3/internal/cache2/FileOperator;-><init>(Ljava/nio/channels/FileChannel;)V
iput-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
return-void
.end method
# virtual methods
.method public close()V
.registers 5
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 1
iget-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
if-nez v0, :cond_5
return-void
:cond_5
const/4 v0, 0x0
.line 2
iput-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
.line 3
iget-object v1, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v1
.line 4
:try_start_b
iget-object v2, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget v3, v2, Lokhttp3/internal/cache2/Relay;->sourceCount:I
add-int/lit8 v3, v3, -0x1
iput v3, v2, Lokhttp3/internal/cache2/Relay;->sourceCount:I
if-nez v3, :cond_1a
.line 5
iget-object v3, v2, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
.line 6
iput-object v0, v2, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
move-object v0, v3
.line 7
:cond_1a
monitor-exit v1
:try_end_1b
.catchall {:try_start_b .. :try_end_1b} :catchall_21
if-eqz v0, :cond_20
.line 8
invoke-static {v0}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
:cond_20
return-void
:catchall_21
move-exception v0
.line 9
:try_start_22
monitor-exit v1
:try_end_23
.catchall {:try_start_22 .. :try_end_23} :catchall_21
throw v0
.end method
.method public read(Lokio/b;J)J
.registers 25
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
move-object/from16 v1, p0
move-wide/from16 v2, p2
.line 1
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
if-eqz v0, :cond_108
.line 2
iget-object v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v4
.line 3
:goto_b
:try_start_b
iget-wide v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-wide v7, v0, Lokhttp3/internal/cache2/Relay;->upstreamPos:J
const/4 v9, 0x2
const-wide/16 v10, -0x1
cmp-long v12, v5, v7
if-nez v12, :cond_31
.line 4
iget-boolean v5, v0, Lokhttp3/internal/cache2/Relay;->complete:Z
if-eqz v5, :cond_1e
monitor-exit v4
return-wide v10
.line 5
:cond_1e
iget-object v5, v0, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
if-eqz v5, :cond_28
.line 6
iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->timeout:Lokio/x;
invoke-virtual {v5, v0}, Lokio/x;->waitUntilNotified(Ljava/lang/Object;)V
goto :goto_b
.line 7
:cond_28
invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;
move-result-object v5
iput-object v5, v0, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
const/4 v0, 0x1
.line 8
monitor-exit v4
goto :goto_3d
.line 9
:cond_31
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/b;
.line 10
iget-wide v12, v0, Lokio/b;->b:J
sub-long v12, v7, v12
cmp-long v0, v5, v12
if-gez v0, :cond_ea
.line 11
monitor-exit v4
:try_end_3c
.catchall {:try_start_b .. :try_end_3c} :catchall_105
const/4 v0, 0x2
:goto_3d
const-wide/16 v4, 0x20
if-ne v0, v9, :cond_5a
.line 12
iget-wide v9, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
sub-long/2addr v7, v9
invoke-static {v2, v3, v7, v8}, Ljava/lang/Math;->min(JJ)J
move-result-wide v2
.line 13
iget-object v9, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
iget-wide v6, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
add-long v10, v6, v4
move-object/from16 v12, p1
move-wide v13, v2
invoke-virtual/range {v9 .. v14}, Lokhttp3/internal/cache2/FileOperator;->read(JLokio/b;J)V
.line 14
iget-wide v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
add-long/2addr v4, v2
iput-wide v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
return-wide v2
:cond_5a
const/4 v6, 0x0
.line 15
:try_start_5b
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v9, v0, Lokhttp3/internal/cache2/Relay;->upstream:Lokio/w;
iget-object v12, v0, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/b;
iget-wide v13, v0, Lokhttp3/internal/cache2/Relay;->bufferMaxSize:J
invoke-interface {v9, v12, v13, v14}, Lokio/w;->read(Lokio/b;J)J
move-result-wide v12
cmp-long v0, v12, v10
if-nez v0, :cond_7f
.line 16
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-virtual {v0, v7, v8}, Lokhttp3/internal/cache2/Relay;->commit(J)V
:try_end_70
.catchall {:try_start_5b .. :try_end_70} :catchall_da
.line 17
iget-object v2, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v2
.line 18
:try_start_73
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iput-object v6, v0, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
.line 19
invoke-virtual {v0}, Ljava/lang/Object;->notifyAll()V
.line 20
monitor-exit v2
return-wide v10
:catchall_7c
move-exception v0
monitor-exit v2
:try_end_7e
.catchall {:try_start_73 .. :try_end_7e} :catchall_7c
throw v0
.line 21
:cond_7f
:try_start_7f
invoke-static {v12, v13, v2, v3}, Ljava/lang/Math;->min(JJ)J
move-result-wide v2
.line 22
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v14, v0, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/b;
const-wide/16 v16, 0x0
move-object/from16 v15, p1
move-wide/from16 v18, v2
invoke-virtual/range {v14 .. v19}, Lokio/b;->o(Lokio/b;JJ)Lokio/b;
.line 23
iget-wide v9, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
add-long/2addr v9, v2
iput-wide v9, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
.line 24
iget-object v15, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
add-long v16, v7, v4
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/b;
.line 25
invoke-virtual {v0}, Lokio/b;->h()Lokio/b;
move-result-object v18
move-wide/from16 v19, v12
.line 26
invoke-virtual/range {v15 .. v20}, Lokhttp3/internal/cache2/FileOperator;->write(JLokio/b;J)V
.line 27
iget-object v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v4
:try_end_a9
.catchall {:try_start_7f .. :try_end_a9} :catchall_da
.line 28
:try_start_a9
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v5, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/b;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/b;
invoke-virtual {v5, v0, v12, v13}, Lokio/b;->write(Lokio/b;J)V
.line 29
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v5, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/b;
.line 30
iget-wide v7, v5, Lokio/b;->b:J
.line 31
iget-wide v9, v0, Lokhttp3/internal/cache2/Relay;->bufferMaxSize:J
cmp-long v0, v7, v9
if-lez v0, :cond_c2
sub-long/2addr v7, v9
.line 32
invoke-virtual {v5, v7, v8}, Lokio/b;->skip(J)V
.line 33
:cond_c2
iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-wide v7, v5, Lokhttp3/internal/cache2/Relay;->upstreamPos:J
add-long/2addr v7, v12
iput-wide v7, v5, Lokhttp3/internal/cache2/Relay;->upstreamPos:J
.line 34
monitor-exit v4
:try_end_ca
.catchall {:try_start_a9 .. :try_end_ca} :catchall_d7
.line 35
monitor-enter v5
.line 36
:try_start_cb
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iput-object v6, v0, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
.line 37
invoke-virtual {v0}, Ljava/lang/Object;->notifyAll()V
.line 38
monitor-exit v5
return-wide v2
:catchall_d4
move-exception v0
monitor-exit v5
:try_end_d6
.catchall {:try_start_cb .. :try_end_d6} :catchall_d4
throw v0
:catchall_d7
move-exception v0
.line 39
:try_start_d8
monitor-exit v4
:try_end_d9
.catchall {:try_start_d8 .. :try_end_d9} :catchall_d7
:try_start_d9
throw v0
:try_end_da
.catchall {:try_start_d9 .. :try_end_da} :catchall_da
:catchall_da
move-exception v0
.line 40
iget-object v2, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v2
.line 41
:try_start_de
iget-object v3, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iput-object v6, v3, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
.line 42
invoke-virtual {v3}, Ljava/lang/Object;->notifyAll()V
.line 43
monitor-exit v2
:try_end_e6
.catchall {:try_start_de .. :try_end_e6} :catchall_e7
.line 44
throw v0
:catchall_e7
move-exception v0
.line 45
:try_start_e8
monitor-exit v2
:try_end_e9
.catchall {:try_start_e8 .. :try_end_e9} :catchall_e7
throw v0
:cond_ea
sub-long/2addr v7, v5
.line 46
:try_start_eb
invoke-static {v2, v3, v7, v8}, Ljava/lang/Math;->min(JJ)J
move-result-wide v2
.line 47
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v14, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/b;
iget-wide v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
sub-long v16, v5, v12
move-object/from16 v15, p1
move-wide/from16 v18, v2
invoke-virtual/range {v14 .. v19}, Lokio/b;->o(Lokio/b;JJ)Lokio/b;
.line 48
iget-wide v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
add-long/2addr v5, v2
iput-wide v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
.line 49
monitor-exit v4
return-wide v2
:catchall_105
move-exception v0
.line 50
monitor-exit v4
:try_end_107
.catchall {:try_start_eb .. :try_end_107} :catchall_105
throw v0
.line 51
:cond_108
new-instance v0, Ljava/lang/IllegalStateException;
const-string v2, "closed"
invoke-direct {v0, v2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
throw v0
.end method
.method public timeout()Lokio/x;
.registers 2
iget-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->timeout:Lokio/x;
return-object v0
.end method