123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511 |
- .class final Lokhttp3/internal/cache2/Relay;
- .super Ljava/lang/Object;
- .source ""
- # annotations
- .annotation system Ldalvik/annotation/MemberClasses;
- value = {
- Lokhttp3/internal/cache2/Relay$RelaySource;
- }
- .end annotation
- # static fields
- .field private static final FILE_HEADER_SIZE:J = 0x20L
- .field static final PREFIX_CLEAN:Lokio/ByteString;
- .field static final PREFIX_DIRTY:Lokio/ByteString;
- .field private static final SOURCE_FILE:I = 0x2
- .field private static final SOURCE_UPSTREAM:I = 0x1
- # instance fields
- .field final buffer:Lokio/Buffer;
- .field final bufferMaxSize:J
- .field complete:Z
- .field file:Ljava/io/RandomAccessFile;
- .field private final metadata:Lokio/ByteString;
- .field sourceCount:I
- .field upstream:Lokio/Source;
- .field final upstreamBuffer:Lokio/Buffer;
- .field upstreamPos:J
- .field upstreamReader:Ljava/lang/Thread;
- # direct methods
- .method static constructor <clinit>()V
- .locals 1
- const-string v0, "OkHttp cache v1\n"
- invoke-static {v0}, Lokio/ByteString;->encodeUtf8(Ljava/lang/String;)Lokio/ByteString;
- move-result-object v0
- sput-object v0, Lokhttp3/internal/cache2/Relay;->PREFIX_CLEAN:Lokio/ByteString;
- const-string v0, "OkHttp DIRTY :(\n"
- invoke-static {v0}, Lokio/ByteString;->encodeUtf8(Ljava/lang/String;)Lokio/ByteString;
- move-result-object v0
- sput-object v0, Lokhttp3/internal/cache2/Relay;->PREFIX_DIRTY:Lokio/ByteString;
- return-void
- .end method
- .method private constructor <init>(Ljava/io/RandomAccessFile;Lokio/Source;JLokio/ByteString;J)V
- .locals 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- new-instance v0, Lokio/Buffer;
- invoke-direct {v0}, Lokio/Buffer;-><init>()V
- iput-object v0, p0, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/Buffer;
- new-instance v0, Lokio/Buffer;
- invoke-direct {v0}, Lokio/Buffer;-><init>()V
- iput-object v0, p0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
- iput-object p1, p0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
- iput-object p2, p0, Lokhttp3/internal/cache2/Relay;->upstream:Lokio/Source;
- if-nez p2, :cond_0
- const/4 p1, 0x1
- goto :goto_0
- :cond_0
- const/4 p1, 0x0
- :goto_0
- iput-boolean p1, p0, Lokhttp3/internal/cache2/Relay;->complete:Z
- iput-wide p3, p0, Lokhttp3/internal/cache2/Relay;->upstreamPos:J
- iput-object p5, p0, Lokhttp3/internal/cache2/Relay;->metadata:Lokio/ByteString;
- iput-wide p6, p0, Lokhttp3/internal/cache2/Relay;->bufferMaxSize:J
- return-void
- .end method
- .method public static edit(Ljava/io/File;Lokio/Source;Lokio/ByteString;J)Lokhttp3/internal/cache2/Relay;
- .locals 9
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- new-instance v8, Ljava/io/RandomAccessFile;
- const-string v0, "rw"
- invoke-direct {v8, p0, v0}, Ljava/io/RandomAccessFile;-><init>(Ljava/io/File;Ljava/lang/String;)V
- new-instance p0, Lokhttp3/internal/cache2/Relay;
- const-wide/16 v3, 0x0
- move-object v0, p0
- move-object v1, v8
- move-object v2, p1
- move-object v5, p2
- move-wide v6, p3
- invoke-direct/range {v0 .. v7}, Lokhttp3/internal/cache2/Relay;-><init>(Ljava/io/RandomAccessFile;Lokio/Source;JLokio/ByteString;J)V
- const-wide/16 p1, 0x0
- invoke-virtual {v8, p1, p2}, Ljava/io/RandomAccessFile;->setLength(J)V
- sget-object v2, Lokhttp3/internal/cache2/Relay;->PREFIX_DIRTY:Lokio/ByteString;
- const-wide/16 v3, -0x1
- const-wide/16 v5, -0x1
- move-object v1, p0
- invoke-direct/range {v1 .. v6}, Lokhttp3/internal/cache2/Relay;->writeHeader(Lokio/ByteString;JJ)V
- return-object p0
- .end method
- .method public static read(Ljava/io/File;)Lokhttp3/internal/cache2/Relay;
- .locals 10
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- new-instance v1, Ljava/io/RandomAccessFile;
- const-string v0, "rw"
- invoke-direct {v1, p0, v0}, Ljava/io/RandomAccessFile;-><init>(Ljava/io/File;Ljava/lang/String;)V
- new-instance p0, Lokhttp3/internal/cache2/FileOperator;
- invoke-virtual {v1}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
- move-result-object v0
- invoke-direct {p0, v0}, Lokhttp3/internal/cache2/FileOperator;-><init>(Ljava/nio/channels/FileChannel;)V
- new-instance v0, Lokio/Buffer;
- invoke-direct {v0}, Lokio/Buffer;-><init>()V
- const-wide/16 v3, 0x0
- const-wide/16 v6, 0x20
- move-object v2, p0
- move-object v5, v0
- invoke-virtual/range {v2 .. v7}, Lokhttp3/internal/cache2/FileOperator;->read(JLokio/Buffer;J)V
- sget-object v2, Lokhttp3/internal/cache2/Relay;->PREFIX_CLEAN:Lokio/ByteString;
- invoke-virtual {v2}, Lokio/ByteString;->size()I
- move-result v2
- int-to-long v2, v2
- invoke-virtual {v0, v2, v3}, Lokio/Buffer;->readByteString(J)Lokio/ByteString;
- move-result-object v2
- sget-object v3, Lokhttp3/internal/cache2/Relay;->PREFIX_CLEAN:Lokio/ByteString;
- invoke-virtual {v2, v3}, Lokio/ByteString;->equals(Ljava/lang/Object;)Z
- move-result v2
- if-eqz v2, :cond_0
- invoke-virtual {v0}, Lokio/Buffer;->readLong()J
- move-result-wide v8
- invoke-virtual {v0}, Lokio/Buffer;->readLong()J
- move-result-wide v6
- new-instance v0, Lokio/Buffer;
- invoke-direct {v0}, Lokio/Buffer;-><init>()V
- const-wide/16 v2, 0x20
- add-long v4, v8, v2
- move-object v2, p0
- move-wide v3, v4
- move-object v5, v0
- invoke-virtual/range {v2 .. v7}, Lokhttp3/internal/cache2/FileOperator;->read(JLokio/Buffer;J)V
- invoke-virtual {v0}, Lokio/Buffer;->readByteString()Lokio/ByteString;
- move-result-object v5
- new-instance p0, Lokhttp3/internal/cache2/Relay;
- const/4 v2, 0x0
- const-wide/16 v6, 0x0
- move-object v0, p0
- move-wide v3, v8
- invoke-direct/range {v0 .. v7}, Lokhttp3/internal/cache2/Relay;-><init>(Ljava/io/RandomAccessFile;Lokio/Source;JLokio/ByteString;J)V
- return-object p0
- :cond_0
- new-instance p0, Ljava/io/IOException;
- const-string v0, "unreadable cache file"
- invoke-direct {p0, v0}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
- throw p0
- .end method
- .method private writeHeader(Lokio/ByteString;JJ)V
- .locals 6
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- new-instance v3, Lokio/Buffer;
- invoke-direct {v3}, Lokio/Buffer;-><init>()V
- invoke-virtual {v3, p1}, Lokio/Buffer;->write(Lokio/ByteString;)Lokio/Buffer;
- invoke-virtual {v3, p2, p3}, Lokio/Buffer;->writeLong(J)Lokio/Buffer;
- invoke-virtual {v3, p4, p5}, Lokio/Buffer;->writeLong(J)Lokio/Buffer;
- invoke-virtual {v3}, Lokio/Buffer;->size()J
- move-result-wide p1
- const-wide/16 p3, 0x20
- cmp-long p5, p1, p3
- if-nez p5, :cond_0
- new-instance v0, Lokhttp3/internal/cache2/FileOperator;
- iget-object p1, p0, 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
- const-wide/16 v1, 0x0
- const-wide/16 v4, 0x20
- invoke-virtual/range {v0 .. v5}, Lokhttp3/internal/cache2/FileOperator;->write(JLokio/Buffer;J)V
- return-void
- :cond_0
- new-instance p1, Ljava/lang/IllegalArgumentException;
- invoke-direct {p1}, Ljava/lang/IllegalArgumentException;-><init>()V
- throw p1
- .end method
- .method private writeMetadata(J)V
- .locals 6
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- new-instance v3, Lokio/Buffer;
- invoke-direct {v3}, Lokio/Buffer;-><init>()V
- iget-object v0, p0, Lokhttp3/internal/cache2/Relay;->metadata:Lokio/ByteString;
- invoke-virtual {v3, v0}, Lokio/Buffer;->write(Lokio/ByteString;)Lokio/Buffer;
- new-instance v0, Lokhttp3/internal/cache2/FileOperator;
- iget-object v1, p0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
- invoke-virtual {v1}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
- move-result-object v1
- invoke-direct {v0, v1}, Lokhttp3/internal/cache2/FileOperator;-><init>(Ljava/nio/channels/FileChannel;)V
- const-wide/16 v1, 0x20
- add-long/2addr v1, p1
- iget-object p1, p0, Lokhttp3/internal/cache2/Relay;->metadata:Lokio/ByteString;
- invoke-virtual {p1}, Lokio/ByteString;->size()I
- move-result p1
- int-to-long v4, p1
- invoke-virtual/range {v0 .. v5}, Lokhttp3/internal/cache2/FileOperator;->write(JLokio/Buffer;J)V
- return-void
- .end method
- # virtual methods
- .method commit(J)V
- .locals 8
- .annotation system Ldalvik/annotation/Throws;
- value = {
- Ljava/io/IOException;
- }
- .end annotation
- invoke-direct {p0, p1, p2}, Lokhttp3/internal/cache2/Relay;->writeMetadata(J)V
- iget-object v0, p0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
- invoke-virtual {v0}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
- move-result-object v0
- const/4 v1, 0x0
- invoke-virtual {v0, v1}, Ljava/nio/channels/FileChannel;->force(Z)V
- sget-object v3, Lokhttp3/internal/cache2/Relay;->PREFIX_CLEAN:Lokio/ByteString;
- iget-object v0, p0, Lokhttp3/internal/cache2/Relay;->metadata:Lokio/ByteString;
- invoke-virtual {v0}, Lokio/ByteString;->size()I
- move-result v0
- int-to-long v6, v0
- move-object v2, p0
- move-wide v4, p1
- invoke-direct/range {v2 .. v7}, Lokhttp3/internal/cache2/Relay;->writeHeader(Lokio/ByteString;JJ)V
- iget-object p1, p0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
- invoke-virtual {p1}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
- move-result-object p1
- invoke-virtual {p1, v1}, Ljava/nio/channels/FileChannel;->force(Z)V
- monitor-enter p0
- const/4 p1, 0x1
- :try_start_0
- iput-boolean p1, p0, Lokhttp3/internal/cache2/Relay;->complete:Z
- monitor-exit p0
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- iget-object p1, p0, Lokhttp3/internal/cache2/Relay;->upstream:Lokio/Source;
- invoke-static {p1}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
- const/4 p1, 0x0
- iput-object p1, p0, Lokhttp3/internal/cache2/Relay;->upstream:Lokio/Source;
- return-void
- :catchall_0
- move-exception p1
- :try_start_1
- monitor-exit p0
- :try_end_1
- .catchall {:try_start_1 .. :try_end_1} :catchall_0
- throw p1
- .end method
- .method isClosed()Z
- .locals 1
- iget-object v0, p0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
- if-nez v0, :cond_0
- const/4 v0, 0x1
- goto :goto_0
- :cond_0
- const/4 v0, 0x0
- :goto_0
- return v0
- .end method
- .method public metadata()Lokio/ByteString;
- .locals 1
- iget-object v0, p0, Lokhttp3/internal/cache2/Relay;->metadata:Lokio/ByteString;
- return-object v0
- .end method
- .method public newSource()Lokio/Source;
- .locals 1
- monitor-enter p0
- :try_start_0
- iget-object v0, p0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
- if-nez v0, :cond_0
- const/4 v0, 0x0
- monitor-exit p0
- return-object v0
- :cond_0
- iget v0, p0, Lokhttp3/internal/cache2/Relay;->sourceCount:I
- add-int/lit8 v0, v0, 0x1
- iput v0, p0, Lokhttp3/internal/cache2/Relay;->sourceCount:I
- monitor-exit p0
- :try_end_0
- .catchall {:try_start_0 .. :try_end_0} :catchall_0
- new-instance v0, Lokhttp3/internal/cache2/Relay$RelaySource;
- invoke-direct {v0, p0}, Lokhttp3/internal/cache2/Relay$RelaySource;-><init>(Lokhttp3/internal/cache2/Relay;)V
- return-object v0
- :catchall_0
- move-exception v0
- :try_start_1
- monitor-exit p0
- :try_end_1
- .catchall {:try_start_1 .. :try_end_1} :catchall_0
- throw v0
- .end method
|