Relay$RelaySource.smali
.class public Lokhttp3/internal/cache2/Relay$RelaySource;
.super Ljava/lang/Object;
.source "Relay.java"
# interfaces
.implements Lokio/Source;
# 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 public fileOperator:Lokhttp3/internal/cache2/FileOperator;
.field public sourcePos:J
.field public final synthetic this$0:Lokhttp3/internal/cache2/Relay;
.field public final timeout:Lokio/Timeout;
# direct methods
.method static constructor <clinit>()V
.registers 1
return-void
.end method
.method public constructor <init>(Lokhttp3/internal/cache2/Relay;)V
.registers 3
iput-object p1, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-direct {p0}, Ljava/lang/Object;-><init>()V
new-instance p1, Lokio/Timeout;
invoke-direct {p1}, Lokio/Timeout;-><init>()V
iput-object p1, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->timeout:Lokio/Timeout;
new-instance p1, Lokhttp3/internal/cache2/FileOperator;
iget-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
invoke-virtual {v0}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
move-result-object v0
invoke-direct {p1, v0}, Lokhttp3/internal/cache2/FileOperator;-><init>(Ljava/nio/channels/FileChannel;)V
iput-object p1, 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
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
iput-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
iget-object v1, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v1
: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
iget-object v2, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget v2, v2, Lokhttp3/internal/cache2/Relay;->sourceCount:I
if-nez v2, :cond_22
iget-object v2, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v2, v2, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
iget-object v3, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iput-object v0, v3, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
move-object v0, v2
:cond_22
monitor-exit v1
:try_end_23
.catchall {:try_start_b .. :try_end_23} :catchall_29
if-eqz v0, :cond_28
invoke-static {v0}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
:cond_28
return-void
:catchall_29
move-exception v0
:try_start_2a
monitor-exit v1
:try_end_2b
.catchall {:try_start_2a .. :try_end_2b} :catchall_29
throw v0
.end method
.method public read(Lokio/Buffer;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
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
if-eqz v0, :cond_13a
iget-object v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v4
: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 v0, 0x2
const-wide/16 v9, -0x1
cmp-long v11, v5, v7
if-nez v11, :cond_39
iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-boolean v5, v5, Lokhttp3/internal/cache2/Relay;->complete:Z
if-eqz v5, :cond_20
monitor-exit v4
return-wide v9
:cond_20
iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v5, v5, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
if-eqz v5, :cond_2e
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->timeout:Lokio/Timeout;
iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-virtual {v0, v5}, Lokio/Timeout;->waitUntilNotified(Ljava/lang/Object;)V
goto :goto_b
:cond_2e
iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;
move-result-object v6
iput-object v6, v5, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
const/4 v5, 0x1
monitor-exit v4
goto :goto_4b
:cond_39
iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v5, v5, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
invoke-virtual {v5}, Lokio/Buffer;->size()J
move-result-wide v5
sub-long v5, v7, v5
iget-wide v11, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
cmp-long v13, v11, v5
if-gez v13, :cond_11b
monitor-exit v4
:try_end_4a
.catchall {:try_start_b .. :try_end_4a} :catchall_137
const/4 v5, 0x2
:goto_4b
const-wide/16 v11, 0x20
if-ne v5, v0, :cond_69
iget-wide v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
sub-long/2addr v7, v4
invoke-static {v2, v3, v7, v8}, Ljava/lang/Math;->min(JJ)J
move-result-wide v2
iget-object v13, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
iget-wide v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
add-long v14, v4, v11
move-object/from16 v16, p1
move-wide/from16 v17, v2
invoke-virtual/range {v13 .. v18}, Lokhttp3/internal/cache2/FileOperator;->read(JLokio/Buffer;J)V
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_69
const/4 v4, 0x0
:try_start_6a
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->upstream:Lokio/Source;
iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v5, v5, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/Buffer;
iget-object v6, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-wide v13, v6, Lokhttp3/internal/cache2/Relay;->bufferMaxSize:J
invoke-interface {v0, v5, v13, v14}, Lokio/Source;->read(Lokio/Buffer;J)J
move-result-wide v5
cmp-long v0, v5, v9
if-nez v0, :cond_94
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_83
.catchall {:try_start_6a .. :try_end_83} :catchall_109
iget-object v2, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v2
:try_start_86
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iput-object v4, v0, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-virtual {v0}, Ljava/lang/Object;->notifyAll()V
monitor-exit v2
return-wide v9
:catchall_91
move-exception v0
monitor-exit v2
:try_end_93
.catchall {:try_start_86 .. :try_end_93} :catchall_91
throw v0
:cond_94
:try_start_94
invoke-static {v5, v6, v2, v3}, Ljava/lang/Math;->min(JJ)J
move-result-wide v2
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v13, v0, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/Buffer;
const-wide/16 v15, 0x0
move-object/from16 v14, p1
move-wide/from16 v17, v2
invoke-virtual/range {v13 .. v18}, Lokio/Buffer;->copyTo(Lokio/Buffer;JJ)Lokio/Buffer;
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
iget-object v15, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
add-long v16, v7, v11
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/Buffer;
invoke-virtual {v0}, Lokio/Buffer;->clone()Lokio/Buffer;
move-result-object v18
move-wide/from16 v19, v5
invoke-virtual/range {v15 .. v20}, Lokhttp3/internal/cache2/FileOperator;->write(JLokio/Buffer;J)V
iget-object v7, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v7
:try_end_be
.catchall {:try_start_94 .. :try_end_be} :catchall_109
:try_start_be
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
iget-object v8, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v8, v8, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/Buffer;
invoke-virtual {v0, v8, v5, v6}, Lokio/Buffer;->write(Lokio/Buffer;J)V
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
invoke-virtual {v0}, Lokio/Buffer;->size()J
move-result-wide v8
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-wide v10, v0, Lokhttp3/internal/cache2/Relay;->bufferMaxSize:J
cmp-long v0, v8, v10
if-lez v0, :cond_ed
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
iget-object v8, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v8, v8, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
invoke-virtual {v8}, Lokio/Buffer;->size()J
move-result-wide v8
iget-object v10, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-wide v10, v10, Lokhttp3/internal/cache2/Relay;->bufferMaxSize:J
sub-long/2addr v8, v10
invoke-virtual {v0, v8, v9}, Lokio/Buffer;->skip(J)V
:cond_ed
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-wide v8, v0, Lokhttp3/internal/cache2/Relay;->upstreamPos:J
add-long/2addr v8, v5
iput-wide v8, v0, Lokhttp3/internal/cache2/Relay;->upstreamPos:J
monitor-exit v7
:try_end_f5
.catchall {:try_start_be .. :try_end_f5} :catchall_106
iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v5
:try_start_f8
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iput-object v4, v0, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-virtual {v0}, Ljava/lang/Object;->notifyAll()V
monitor-exit v5
return-wide v2
:catchall_103
move-exception v0
monitor-exit v5
:try_end_105
.catchall {:try_start_f8 .. :try_end_105} :catchall_103
throw v0
:catchall_106
move-exception v0
:try_start_107
monitor-exit v7
:try_end_108
.catchall {:try_start_107 .. :try_end_108} :catchall_106
:try_start_108
throw v0
:try_end_109
.catchall {:try_start_108 .. :try_end_109} :catchall_109
:catchall_109
move-exception v0
iget-object v2, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
monitor-enter v2
:try_start_10d
iget-object v3, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iput-object v4, v3, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
iget-object v3, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
invoke-virtual {v3}, Ljava/lang/Object;->notifyAll()V
monitor-exit v2
:try_end_117
.catchall {:try_start_10d .. :try_end_117} :catchall_118
throw v0
:catchall_118
move-exception v0
:try_start_119
monitor-exit v2
:try_end_11a
.catchall {:try_start_119 .. :try_end_11a} :catchall_118
throw v0
:cond_11b
:try_start_11b
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
iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
iget-object v9, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
iget-wide v7, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
sub-long v11, v7, v5
move-object/from16 v10, p1
move-wide v13, v2
invoke-virtual/range {v9 .. v14}, Lokio/Buffer;->copyTo(Lokio/Buffer;JJ)Lokio/Buffer;
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
monitor-exit v4
return-wide v2
:catchall_137
move-exception v0
monitor-exit v4
:try_end_139
.catchall {:try_start_11b .. :try_end_139} :catchall_137
throw v0
:cond_13a
new-instance v0, Ljava/lang/IllegalStateException;
const-string v2, "closed"
invoke-direct {v0, v2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
goto :goto_143
:goto_142
throw v0
:goto_143
goto :goto_142
.end method
.method public timeout()Lokio/Timeout;
.registers 2
iget-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->timeout:Lokio/Timeout;
return-object v0
.end method