ResponseHandlingInputStream.smali
.class public final Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;
.super Ljava/io/FilterInputStream;
.source "SourceFile"
# static fields
.field private static final BUFFER_SIZE:I = 0x400
.field public static final TAG:Ljava/lang/String; = "ResponseHandlingInputStream"
# instance fields
.field private mClosed:Z
.field private final mDecompressedCounter:Lcom/facebook/stetho/inspector/network/CountingOutputStream;
.field private mEofSeen:Z
.field private mLastDecompressedCount:J
.field private final mNetworkPeerManager:Lcom/facebook/stetho/inspector/helper/ChromePeerManager;
.field private final mOutputStream:Ljava/io/OutputStream;
.field private final mRequestId:Ljava/lang/String;
.field private final mResponseHandler:Lcom/facebook/stetho/inspector/network/ResponseHandler;
.field private mSkipBuffer:[B
# direct methods
.method public constructor <init>(Ljava/io/InputStream;Ljava/lang/String;Ljava/io/OutputStream;Lcom/facebook/stetho/inspector/network/CountingOutputStream;Lcom/facebook/stetho/inspector/helper/ChromePeerManager;Lcom/facebook/stetho/inspector/network/ResponseHandler;)V
.registers 9
.line 1
invoke-direct {p0, p1}, Ljava/io/FilterInputStream;-><init>(Ljava/io/InputStream;)V
const-wide/16 v0, 0x0
.line 2
iput-wide v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mLastDecompressedCount:J
.line 3
iput-object p2, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mRequestId:Ljava/lang/String;
.line 4
iput-object p3, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mOutputStream:Ljava/io/OutputStream;
.line 5
iput-object p4, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mDecompressedCounter:Lcom/facebook/stetho/inspector/network/CountingOutputStream;
.line 6
iput-object p5, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mNetworkPeerManager:Lcom/facebook/stetho/inspector/helper/ChromePeerManager;
.line 7
iput-object p6, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mResponseHandler:Lcom/facebook/stetho/inspector/network/ResponseHandler;
const/4 p1, 0x0
.line 8
iput-boolean p1, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mClosed:Z
return-void
.end method
.method private declared-synchronized checkEOF(I)I
.registers 3
monitor-enter p0
const/4 v0, -0x1
if-ne p1, v0, :cond_13
.line 1
:try_start_4
invoke-direct {p0}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->closeOutputStreamQuietly()V
.line 2
iget-object v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mResponseHandler:Lcom/facebook/stetho/inspector/network/ResponseHandler;
invoke-interface {v0}, Lcom/facebook/stetho/inspector/network/ResponseHandler;->onEOF()V
const/4 v0, 0x1
.line 3
iput-boolean v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mEofSeen:Z
:try_end_f
.catchall {:try_start_4 .. :try_end_f} :catchall_10
goto :goto_13
:catchall_10
move-exception p1
monitor-exit p0
throw p1
.line 4
:cond_13
:goto_13
monitor-exit p0
return p1
.end method
.method private declared-synchronized closeOutputStreamQuietly()V
.registers 8
monitor-enter p0
.line 1
:try_start_1
iget-boolean v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mClosed:Z
:try_end_3
.catchall {:try_start_1 .. :try_end_3} :catchall_34
if-nez v0, :cond_32
const/4 v0, 0x1
.line 2
:try_start_6
iget-object v1, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mOutputStream:Ljava/io/OutputStream;
invoke-virtual {v1}, Ljava/io/OutputStream;->close()V
.line 3
invoke-direct {p0}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->reportDecodedSizeIfApplicable()V
:try_end_e
.catch Ljava/io/IOException; {:try_start_6 .. :try_end_e} :catch_13
.catchall {:try_start_6 .. :try_end_e} :catchall_11
.line 4
:goto_e
:try_start_e
iput-boolean v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mClosed:Z
:try_end_10
.catchall {:try_start_e .. :try_end_10} :catchall_34
goto :goto_32
:catchall_11
move-exception v1
goto :goto_2f
:catch_13
move-exception v1
.line 5
:try_start_14
iget-object v2, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mNetworkPeerManager:Lcom/facebook/stetho/inspector/helper/ChromePeerManager;
sget-object v3, Lcom/facebook/stetho/inspector/protocol/module/Console$MessageLevel;->ERROR:Lcom/facebook/stetho/inspector/protocol/module/Console$MessageLevel;
sget-object v4, Lcom/facebook/stetho/inspector/protocol/module/Console$MessageSource;->NETWORK:Lcom/facebook/stetho/inspector/protocol/module/Console$MessageSource;
new-instance v5, Ljava/lang/StringBuilder;
invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V
const-string v6, "Could not close the output stream"
invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v5, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v1
invoke-static {v2, v3, v4, v1}, Lcom/facebook/stetho/inspector/console/CLog;->writeToConsole(Lcom/facebook/stetho/inspector/helper/ChromePeerManager;Lcom/facebook/stetho/inspector/protocol/module/Console$MessageLevel;Lcom/facebook/stetho/inspector/protocol/module/Console$MessageSource;Ljava/lang/String;)V
:try_end_2e
.catchall {:try_start_14 .. :try_end_2e} :catchall_11
goto :goto_e
.line 6
:goto_2f
:try_start_2f
iput-boolean v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mClosed:Z
throw v1
:try_end_32
.catchall {:try_start_2f .. :try_end_32} :catchall_34
.line 7
:cond_32
:goto_32
monitor-exit p0
return-void
:catchall_34
move-exception v0
monitor-exit p0
throw v0
.end method
.method private getSkipBufferLocked()[B
.registers 2
.line 1
iget-object v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mSkipBuffer:[B
if-nez v0, :cond_a
const/16 v0, 0x400
new-array v0, v0, [B
.line 2
iput-object v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mSkipBuffer:[B
.line 3
:cond_a
iget-object v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mSkipBuffer:[B
return-object v0
.end method
.method private handleIOException(Ljava/io/IOException;)Ljava/io/IOException;
.registers 3
iget-object v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mResponseHandler:Lcom/facebook/stetho/inspector/network/ResponseHandler;
invoke-interface {v0, p1}, Lcom/facebook/stetho/inspector/network/ResponseHandler;->onError(Ljava/io/IOException;)V
return-object p1
.end method
.method private handleIOExceptionWritingToStream(Ljava/io/IOException;)V
.registers 7
.line 1
iget-object v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mNetworkPeerManager:Lcom/facebook/stetho/inspector/helper/ChromePeerManager;
sget-object v1, Lcom/facebook/stetho/inspector/protocol/module/Console$MessageLevel;->ERROR:Lcom/facebook/stetho/inspector/protocol/module/Console$MessageLevel;
sget-object v2, Lcom/facebook/stetho/inspector/protocol/module/Console$MessageSource;->NETWORK:Lcom/facebook/stetho/inspector/protocol/module/Console$MessageSource;
new-instance v3, Ljava/lang/StringBuilder;
invoke-direct {v3}, Ljava/lang/StringBuilder;-><init>()V
const-string v4, "Could not write response body to the stream "
invoke-virtual {v3, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v3, p1}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder;
invoke-virtual {v3}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object p1
invoke-static {v0, v1, v2, p1}, Lcom/facebook/stetho/inspector/console/CLog;->writeToConsole(Lcom/facebook/stetho/inspector/helper/ChromePeerManager;Lcom/facebook/stetho/inspector/protocol/module/Console$MessageLevel;Lcom/facebook/stetho/inspector/protocol/module/Console$MessageSource;Ljava/lang/String;)V
.line 2
invoke-direct {p0}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->closeOutputStreamQuietly()V
return-void
.end method
.method private reportDecodedSizeIfApplicable()V
.registers 5
.line 1
iget-object v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mDecompressedCounter:Lcom/facebook/stetho/inspector/network/CountingOutputStream;
if-eqz v0, :cond_14
.line 2
invoke-virtual {v0}, Lcom/facebook/stetho/inspector/network/CountingOutputStream;->getCount()J
move-result-wide v0
.line 3
iget-wide v2, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mLastDecompressedCount:J
sub-long v2, v0, v2
long-to-int v3, v2
.line 4
iget-object v2, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mResponseHandler:Lcom/facebook/stetho/inspector/network/ResponseHandler;
invoke-interface {v2, v3}, Lcom/facebook/stetho/inspector/network/ResponseHandler;->onReadDecoded(I)V
.line 5
iput-wide v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mLastDecompressedCount:J
:cond_14
return-void
.end method
.method private declared-synchronized writeToOutputStream(I)V
.registers 3
monitor-enter p0
.line 1
:try_start_1
iget-boolean v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mClosed:Z
:try_end_3
.catchall {:try_start_1 .. :try_end_3} :catchall_16
if-eqz v0, :cond_7
.line 2
monitor-exit p0
return-void
.line 3
:cond_7
:try_start_7
iget-object v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mOutputStream:Ljava/io/OutputStream;
invoke-virtual {v0, p1}, Ljava/io/OutputStream;->write(I)V
.line 4
invoke-direct {p0}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->reportDecodedSizeIfApplicable()V
:try_end_f
.catch Ljava/io/IOException; {:try_start_7 .. :try_end_f} :catch_10
.catchall {:try_start_7 .. :try_end_f} :catchall_16
goto :goto_14
:catch_10
move-exception p1
.line 5
:try_start_11
invoke-direct {p0, p1}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->handleIOExceptionWritingToStream(Ljava/io/IOException;)V
:try_end_14
.catchall {:try_start_11 .. :try_end_14} :catchall_16
.line 6
:goto_14
monitor-exit p0
return-void
:catchall_16
move-exception p1
monitor-exit p0
throw p1
.end method
.method private declared-synchronized writeToOutputStream([BII)V
.registers 5
monitor-enter p0
.line 7
:try_start_1
iget-boolean v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mClosed:Z
:try_end_3
.catchall {:try_start_1 .. :try_end_3} :catchall_16
if-eqz v0, :cond_7
.line 8
monitor-exit p0
return-void
.line 9
:cond_7
:try_start_7
iget-object v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mOutputStream:Ljava/io/OutputStream;
invoke-virtual {v0, p1, p2, p3}, Ljava/io/OutputStream;->write([BII)V
.line 10
invoke-direct {p0}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->reportDecodedSizeIfApplicable()V
:try_end_f
.catch Ljava/io/IOException; {:try_start_7 .. :try_end_f} :catch_10
.catchall {:try_start_7 .. :try_end_f} :catchall_16
goto :goto_14
:catch_10
move-exception p1
.line 11
:try_start_11
invoke-direct {p0, p1}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->handleIOExceptionWritingToStream(Ljava/io/IOException;)V
:try_end_14
.catchall {:try_start_11 .. :try_end_14} :catchall_16
.line 12
:goto_14
monitor-exit p0
return-void
:catchall_16
move-exception p1
monitor-exit p0
throw p1
.end method
# virtual methods
.method public close()V
.registers 8
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 1
:try_start_0
iget-boolean v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mEofSeen:Z
const-wide/16 v1, 0x0
if-nez v0, :cond_15
const/16 v0, 0x400
new-array v0, v0, [B
move-wide v3, v1
.line 2
:goto_b
invoke-virtual {p0, v0}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->read([B)I
move-result v5
const/4 v6, -0x1
if-eq v5, v6, :cond_16
int-to-long v5, v5
add-long/2addr v3, v5
goto :goto_b
:cond_15
move-wide v3, v1
:cond_16
cmp-long v0, v3, v1
if-lez v0, :cond_42
.line 3
iget-object v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mNetworkPeerManager:Lcom/facebook/stetho/inspector/helper/ChromePeerManager;
sget-object v1, Lcom/facebook/stetho/inspector/protocol/module/Console$MessageLevel;->ERROR:Lcom/facebook/stetho/inspector/protocol/module/Console$MessageLevel;
sget-object v2, Lcom/facebook/stetho/inspector/protocol/module/Console$MessageSource;->NETWORK:Lcom/facebook/stetho/inspector/protocol/module/Console$MessageSource;
new-instance v5, Ljava/lang/StringBuilder;
invoke-direct {v5}, Ljava/lang/StringBuilder;-><init>()V
const-string v6, "There were "
invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
.line 4
invoke-static {v3, v4}, Ljava/lang/String;->valueOf(J)Ljava/lang/String;
move-result-object v3
invoke-virtual {v5, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
const-string v3, " bytes that were not consumed while processing request "
invoke-virtual {v5, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
iget-object v3, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mRequestId:Ljava/lang/String;
invoke-virtual {v5, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
move-result-object v3
.line 5
invoke-static {v0, v1, v2, v3}, Lcom/facebook/stetho/inspector/console/CLog;->writeToConsole(Lcom/facebook/stetho/inspector/helper/ChromePeerManager;Lcom/facebook/stetho/inspector/protocol/module/Console$MessageLevel;Lcom/facebook/stetho/inspector/protocol/module/Console$MessageSource;Ljava/lang/String;)V
:try_end_42
.catchall {:try_start_0 .. :try_end_42} :catchall_49
.line 6
:cond_42
invoke-super {p0}, Ljava/io/FilterInputStream;->close()V
.line 7
invoke-direct {p0}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->closeOutputStreamQuietly()V
return-void
:catchall_49
move-exception v0
.line 8
invoke-super {p0}, Ljava/io/FilterInputStream;->close()V
.line 9
invoke-direct {p0}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->closeOutputStreamQuietly()V
throw v0
.end method
.method public mark(I)V
.registers 2
return-void
.end method
.method public markSupported()Z
.registers 2
const/4 v0, 0x0
return v0
.end method
.method public read()I
.registers 4
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 1
:try_start_0
iget-object v0, p0, Ljava/io/FilterInputStream;->in:Ljava/io/InputStream;
invoke-virtual {v0}, Ljava/io/InputStream;->read()I
move-result v0
invoke-direct {p0, v0}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->checkEOF(I)I
move-result v0
const/4 v1, -0x1
if-eq v0, v1, :cond_16
.line 2
iget-object v1, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mResponseHandler:Lcom/facebook/stetho/inspector/network/ResponseHandler;
const/4 v2, 0x1
invoke-interface {v1, v2}, Lcom/facebook/stetho/inspector/network/ResponseHandler;->onRead(I)V
.line 3
invoke-direct {p0, v0}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->writeToOutputStream(I)V
:try_end_16
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_16} :catch_17
:cond_16
return v0
:catch_17
move-exception v0
.line 4
invoke-direct {p0, v0}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->handleIOException(Ljava/io/IOException;)Ljava/io/IOException;
move-result-object v0
throw v0
.end method
.method public read([B)I
.registers 4
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 5
array-length v0, p1
const/4 v1, 0x0
invoke-virtual {p0, p1, v1, v0}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->read([BII)I
move-result p1
return p1
.end method
.method public read([BII)I
.registers 5
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
.line 6
:try_start_0
iget-object v0, p0, Ljava/io/FilterInputStream;->in:Ljava/io/InputStream;
invoke-virtual {v0, p1, p2, p3}, Ljava/io/InputStream;->read([BII)I
move-result p3
invoke-direct {p0, p3}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->checkEOF(I)I
move-result p3
const/4 v0, -0x1
if-eq p3, v0, :cond_15
.line 7
iget-object v0, p0, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->mResponseHandler:Lcom/facebook/stetho/inspector/network/ResponseHandler;
invoke-interface {v0, p3}, Lcom/facebook/stetho/inspector/network/ResponseHandler;->onRead(I)V
.line 8
invoke-direct {p0, p1, p2, p3}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->writeToOutputStream([BII)V
:try_end_15
.catch Ljava/io/IOException; {:try_start_0 .. :try_end_15} :catch_16
:cond_15
return p3
:catch_16
move-exception p1
.line 9
invoke-direct {p0, p1}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->handleIOException(Ljava/io/IOException;)Ljava/io/IOException;
move-result-object p1
throw p1
.end method
.method public reset()V
.registers 3
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
new-instance v0, Ljava/lang/UnsupportedOperationException;
const-string v1, "Mark not supported"
invoke-direct {v0, v1}, Ljava/lang/UnsupportedOperationException;-><init>(Ljava/lang/String;)V
throw v0
.end method
.method public declared-synchronized skip(J)J
.registers 10
.annotation system Ldalvik/annotation/Throws;
value = {
Ljava/io/IOException;
}
.end annotation
monitor-enter p0
.line 1
:try_start_1
invoke-direct {p0}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->getSkipBufferLocked()[B
move-result-object v0
const-wide/16 v1, 0x0
:goto_7
cmp-long v3, v1, p1
if-gez v3, :cond_20
sub-long v3, p1, v1
.line 2
array-length v5, v0
int-to-long v5, v5
invoke-static {v5, v6, v3, v4}, Ljava/lang/Math;->min(JJ)J
move-result-wide v3
long-to-int v4, v3
const/4 v3, 0x0
.line 3
invoke-virtual {p0, v0, v3, v4}, Lcom/facebook/stetho/inspector/network/ResponseHandlingInputStream;->read([BII)I
move-result v3
:try_end_19
.catchall {:try_start_1 .. :try_end_19} :catchall_22
const/4 v4, -0x1
if-ne v3, v4, :cond_1d
goto :goto_20
:cond_1d
int-to-long v3, v3
add-long/2addr v1, v3
goto :goto_7
.line 4
:cond_20
:goto_20
monitor-exit p0
return-wide v1
:catchall_22
move-exception p1
monitor-exit p0
throw p1
.end method