Http2Codec$StreamFinishingSource.smali

.class Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;
.super Lokio/g;
.source "SourceFile"


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lokhttp3/internal/http2/Http2Codec;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x1
    name = "StreamFinishingSource"
.end annotation


# instance fields
.field public bytesRead:J

.field public completed:Z

.field private invokeStartEvent:Z

.field private tag:Lokhttp3/HttpRequestTag;

.field public final synthetic this$0:Lokhttp3/internal/http2/Http2Codec;


# direct methods
.method public constructor <init>(Lokhttp3/internal/http2/Http2Codec;Lokio/w;)V
    .registers 5

    .line 1
    iput-object p1, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->this$0:Lokhttp3/internal/http2/Http2Codec;

    .line 2
    invoke-direct {p0, p2}, Lokio/g;-><init>(Lokio/w;)V

    const/4 p2, 0x0

    .line 3
    iput-boolean p2, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->completed:Z

    const-wide/16 v0, 0x0

    .line 4
    iput-wide v0, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->bytesRead:J

    const/4 p2, 0x1

    .line 5
    iput-boolean p2, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->invokeStartEvent:Z

    .line 6
    iget-object p2, p1, Lokhttp3/internal/http2/Http2Codec;->streamAllocation:Lokhttp3/internal/connection/StreamAllocation;

    if-eqz p2, :cond_2f

    iget-object p2, p2, Lokhttp3/internal/connection/StreamAllocation;->call:Lokhttp3/Call;

    if-eqz p2, :cond_2f

    invoke-interface {p2}, Lokhttp3/Call;->request()Lokhttp3/Request;

    move-result-object p2

    if-eqz p2, :cond_2f

    .line 7
    iget-object p1, p1, Lokhttp3/internal/http2/Http2Codec;->streamAllocation:Lokhttp3/internal/connection/StreamAllocation;

    iget-object p1, p1, Lokhttp3/internal/connection/StreamAllocation;->call:Lokhttp3/Call;

    invoke-interface {p1}, Lokhttp3/Call;->request()Lokhttp3/Request;

    move-result-object p1

    const-class p2, Lokhttp3/HttpRequestTag;

    invoke-virtual {p1, p2}, Lokhttp3/Request;->tag(Ljava/lang/Class;)Ljava/lang/Object;

    move-result-object p1

    check-cast p1, Lokhttp3/HttpRequestTag;

    iput-object p1, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->tag:Lokhttp3/HttpRequestTag;

    :cond_2f
    return-void
.end method

.method private bytesLengthMetrics()V
    .registers 9

    .line 1
    iget-object v0, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->tag:Lokhttp3/HttpRequestTag;

    if-nez v0, :cond_5

    return-void

    .line 2
    :cond_5
    iget-wide v1, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->bytesRead:J

    const-wide/32 v3, 0x10000

    const-wide/16 v5, -0x1

    cmp-long v7, v1, v3

    if-ltz v7, :cond_21

    invoke-virtual {v0}, Lokhttp3/HttpRequestTag;->getCost64KB()J

    move-result-wide v0

    cmp-long v2, v0, v5

    if-nez v2, :cond_21

    .line 3
    iget-object v0, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->tag:Lokhttp3/HttpRequestTag;

    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v1

    invoke-virtual {v0, v1, v2}, Lokhttp3/HttpRequestTag;->setCost64KB(J)V

    .line 4
    :cond_21
    iget-wide v0, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->bytesRead:J

    const-wide/32 v2, 0x20000

    cmp-long v4, v0, v2

    if-ltz v4, :cond_3d

    iget-object v0, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->tag:Lokhttp3/HttpRequestTag;

    invoke-virtual {v0}, Lokhttp3/HttpRequestTag;->getCost128KB()J

    move-result-wide v0

    cmp-long v2, v0, v5

    if-nez v2, :cond_3d

    .line 5
    iget-object v0, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->tag:Lokhttp3/HttpRequestTag;

    invoke-static {}, Ljava/lang/System;->currentTimeMillis()J

    move-result-wide v1

    invoke-virtual {v0, v1, v2}, Lokhttp3/HttpRequestTag;->setCost128KB(J)V

    :cond_3d
    return-void
.end method

.method private endOfInput(Ljava/io/IOException;)V
    .registers 10

    .line 1
    iget-boolean v0, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->completed:Z

    if-eqz v0, :cond_5

    return-void

    :cond_5
    const/4 v0, 0x1

    .line 2
    iput-boolean v0, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->completed:Z

    if-nez p1, :cond_1c

    .line 3
    iget-boolean v0, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->invokeStartEvent:Z

    if-eqz v0, :cond_1c

    const/4 v0, 0x0

    .line 4
    iput-boolean v0, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->invokeStartEvent:Z

    .line 5
    iget-object v0, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->this$0:Lokhttp3/internal/http2/Http2Codec;

    iget-object v0, v0, Lokhttp3/internal/http2/Http2Codec;->streamAllocation:Lokhttp3/internal/connection/StreamAllocation;

    iget-object v1, v0, Lokhttp3/internal/connection/StreamAllocation;->eventListener:Lokhttp3/EventListener;

    iget-object v0, v0, Lokhttp3/internal/connection/StreamAllocation;->call:Lokhttp3/Call;

    invoke-virtual {v1, v0}, Lokhttp3/EventListener;->responseBodyStart(Lokhttp3/Call;)V

    .line 6
    :cond_1c
    iget-object v4, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->this$0:Lokhttp3/internal/http2/Http2Codec;

    iget-object v2, v4, Lokhttp3/internal/http2/Http2Codec;->streamAllocation:Lokhttp3/internal/connection/StreamAllocation;

    const/4 v3, 0x0

    iget-wide v5, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->bytesRead:J

    move-object v7, p1

    invoke-virtual/range {v2 .. v7}, Lokhttp3/internal/connection/StreamAllocation;->streamFinished(ZLokhttp3/internal/http/HttpCodec;JLjava/io/IOException;)V

    return-void
.end method


# virtual methods
.method public close()V
    .registers 2
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .line 1
    invoke-super {p0}, Lokio/g;->close()V

    const/4 v0, 0x0

    .line 2
    invoke-direct {p0, v0}, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->endOfInput(Ljava/io/IOException;)V

    return-void
.end method

.method public read(Lokio/b;J)J
    .registers 6
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .line 1
    :try_start_0
    invoke-virtual {p0}, Lokio/g;->delegate()Lokio/w;

    move-result-object v0

    invoke-interface {v0, p1, p2, p3}, Lokio/w;->read(Lokio/b;J)J

    move-result-wide p1

    .line 2
    iget-boolean p3, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->invokeStartEvent:Z

    if-eqz p3, :cond_1a

    const/4 p3, 0x0

    .line 3
    iput-boolean p3, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->invokeStartEvent:Z

    .line 4
    iget-object p3, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->this$0:Lokhttp3/internal/http2/Http2Codec;

    iget-object p3, p3, Lokhttp3/internal/http2/Http2Codec;->streamAllocation:Lokhttp3/internal/connection/StreamAllocation;

    iget-object v0, p3, Lokhttp3/internal/connection/StreamAllocation;->eventListener:Lokhttp3/EventListener;

    iget-object p3, p3, Lokhttp3/internal/connection/StreamAllocation;->call:Lokhttp3/Call;

    invoke-virtual {v0, p3}, Lokhttp3/EventListener;->responseBodyStart(Lokhttp3/Call;)V

    :cond_1a
    const-wide/16 v0, 0x0

    cmp-long p3, p1, v0

    if-lez p3, :cond_25

    .line 5
    iget-wide v0, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->bytesRead:J

    add-long/2addr v0, p1

    iput-wide v0, p0, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->bytesRead:J

    .line 6
    :cond_25
    invoke-direct {p0}, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->bytesLengthMetrics()V
    :try_end_28
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_28} :catch_29

    return-wide p1

    :catch_29
    move-exception p1

    .line 7
    invoke-direct {p0, p1}, Lokhttp3/internal/http2/Http2Codec$StreamFinishingSource;->endOfInput(Ljava/io/IOException;)V

    .line 8
    throw p1
.end method