.class Lokhttp3/internal/cache2/Relay$RelaySource; .super Ljava/lang/Object; .source "" # interfaces .implements Lokio/Source; # annotations .annotation system Ldalvik/annotation/EnclosingClass; value = Lokhttp3/internal/cache2/Relay; .end annotation .annotation system Ldalvik/annotation/InnerClass; accessFlags = 0x0 name = "RelaySource" .end annotation # instance fields .field private fileOperator:Lokhttp3/internal/cache2/FileOperator; .field private sourcePos:J .field final synthetic this$0:Lokhttp3/internal/cache2/Relay; .field private final timeout:Lokio/Timeout; # direct methods .method constructor (Lokhttp3/internal/cache2/Relay;)V .locals 1 iput-object p1, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay; invoke-direct {p0}, Ljava/lang/Object;->()V new-instance p1, Lokio/Timeout; invoke-direct {p1}, Lokio/Timeout;->()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;->(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 .locals 4 .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_0 return-void :cond_0 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_0 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_1 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_1 monitor-exit v1 :try_end_0 .catchall {:try_start_0 .. :try_end_0} :catchall_0 if-eqz v0, :cond_2 invoke-static {v0}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V :cond_2 return-void :catchall_0 move-exception v0 :try_start_1 monitor-exit v1 :try_end_1 .catchall {:try_start_1 .. :try_end_1} :catchall_0 throw v0 .end method .method public read(Lokio/Buffer;J)J .locals 21 .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_7 iget-object v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay; monitor-enter v4 :goto_0 :try_start_0 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_2 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_0 monitor-exit v4 return-wide v9 :cond_0 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_1 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_0 :cond_1 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_1 :cond_2 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_6 monitor-exit v4 :try_end_0 .catchall {:try_start_0 .. :try_end_0} :catchall_5 const/4 v5, 0x2 :goto_1 const-wide/16 v11, 0x20 if-ne v5, v0, :cond_3 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_3 const/4 v4, 0x0 :try_start_1 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_4 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_1 .catchall {:try_start_1 .. :try_end_1} :catchall_3 iget-object v2, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay; monitor-enter v2 :try_start_2 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_0 move-exception v0 monitor-exit v2 :try_end_2 .catchall {:try_start_2 .. :try_end_2} :catchall_0 throw v0 :cond_4 :try_start_3 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_3 .catchall {:try_start_3 .. :try_end_3} :catchall_3 :try_start_4 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_5 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_5 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_4 .catchall {:try_start_4 .. :try_end_4} :catchall_2 iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay; monitor-enter v5 :try_start_5 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_1 move-exception v0 monitor-exit v5 :try_end_5 .catchall {:try_start_5 .. :try_end_5} :catchall_1 throw v0 :catchall_2 move-exception v0 :try_start_6 monitor-exit v7 :try_end_6 .catchall {:try_start_6 .. :try_end_6} :catchall_2 :try_start_7 throw v0 :try_end_7 .catchall {:try_start_7 .. :try_end_7} :catchall_3 :catchall_3 move-exception v0 iget-object v2, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay; monitor-enter v2 :try_start_8 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_8 .catchall {:try_start_8 .. :try_end_8} :catchall_4 throw v0 :catchall_4 move-exception v0 :try_start_9 monitor-exit v2 :try_end_9 .catchall {:try_start_9 .. :try_end_9} :catchall_4 throw v0 :cond_6 :try_start_a 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_5 move-exception v0 monitor-exit v4 :try_end_a .catchall {:try_start_a .. :try_end_a} :catchall_5 throw v0 :cond_7 new-instance v0, Ljava/lang/IllegalStateException; const-string v2, "closed" invoke-direct {v0, v2}, Ljava/lang/IllegalStateException;->(Ljava/lang/String;)V goto :goto_3 :goto_2 throw v0 :goto_3 goto :goto_2 .end method .method public timeout()Lokio/Timeout; .locals 1 iget-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->timeout:Lokio/Timeout; return-object v0 .end method