Http1Codec$AbstractSource.smali

.class abstract Lokhttp3/internal/http1/Http1Codec$AbstractSource;
.super Ljava/lang/Object;
.source "SourceFile"

# interfaces
.implements Lokio/w;


# annotations
.annotation system Ldalvik/annotation/EnclosingClass;
    value = Lokhttp3/internal/http1/Http1Codec;
.end annotation

.annotation system Ldalvik/annotation/InnerClass;
    accessFlags = 0x401
    name = "AbstractSource"
.end annotation


# instance fields
.field public bytesRead:J

.field public closed:Z

.field private invokeStartEvent:Z

.field private tag:Lokhttp3/HttpRequestTag;

.field public final synthetic this$0:Lokhttp3/internal/http1/Http1Codec;

.field public final timeout:Lokio/h;


# direct methods
.method public constructor <init>(Lokhttp3/internal/http1/Http1Codec;)V
    .registers 4

    .line 1
    iput-object p1, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->this$0:Lokhttp3/internal/http1/Http1Codec;

    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 2
    new-instance v0, Lokio/h;

    iget-object v1, p1, Lokhttp3/internal/http1/Http1Codec;->source:Lokio/d;

    invoke-interface {v1}, Lokio/w;->timeout()Lokio/x;

    move-result-object v1

    invoke-direct {v0, v1}, Lokio/h;-><init>(Lokio/x;)V

    iput-object v0, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->timeout:Lokio/h;

    const-wide/16 v0, 0x0

    .line 3
    iput-wide v0, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->bytesRead:J

    const/4 v0, 0x1

    .line 4
    iput-boolean v0, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->invokeStartEvent:Z

    .line 5
    iget-object v0, p1, Lokhttp3/internal/http1/Http1Codec;->streamAllocation:Lokhttp3/internal/connection/StreamAllocation;

    if-eqz v0, :cond_39

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

    if-eqz v0, :cond_39

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

    move-result-object v0

    if-eqz v0, :cond_39

    .line 6
    iget-object p1, p1, Lokhttp3/internal/http1/Http1Codec;->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 v0, Lokhttp3/HttpRequestTag;

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

    move-result-object p1

    check-cast p1, Lokhttp3/HttpRequestTag;

    iput-object p1, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->tag:Lokhttp3/HttpRequestTag;

    :cond_39
    return-void
.end method

.method private bytesLengthMetrics()V
    .registers 9

    .line 1
    iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->tag:Lokhttp3/HttpRequestTag;

    if-nez v0, :cond_5

    return-void

    .line 2
    :cond_5
    iget-wide v1, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->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/http1/Http1Codec$AbstractSource;->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/http1/Http1Codec$AbstractSource;->bytesRead:J

    const-wide/32 v2, 0x20000

    cmp-long v4, v0, v2

    if-ltz v4, :cond_3d

    iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->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/http1/Http1Codec$AbstractSource;->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


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

.method public final endOfInput(ZLjava/io/IOException;)V
    .registers 11
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/io/IOException;
        }
    .end annotation

    .line 1
    iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->this$0:Lokhttp3/internal/http1/Http1Codec;

    iget v1, v0, Lokhttp3/internal/http1/Http1Codec;->state:I

    const/4 v2, 0x6

    if-ne v1, v2, :cond_8

    return-void

    :cond_8
    const/4 v3, 0x5

    if-ne v1, v3, :cond_31

    .line 2
    iget-object v1, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->timeout:Lokio/h;

    invoke-virtual {v0, v1}, Lokhttp3/internal/http1/Http1Codec;->detachTimeout(Lokio/h;)V

    .line 3
    iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->this$0:Lokhttp3/internal/http1/Http1Codec;

    iput v2, v0, Lokhttp3/internal/http1/Http1Codec;->state:I

    .line 4
    iget-object v1, v0, Lokhttp3/internal/http1/Http1Codec;->streamAllocation:Lokhttp3/internal/connection/StreamAllocation;

    if-eqz v1, :cond_30

    if-nez p2, :cond_24

    .line 5
    iget-boolean v1, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->invokeStartEvent:Z

    if-eqz v1, :cond_24

    const/4 v1, 0x0

    .line 6
    iput-boolean v1, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->invokeStartEvent:Z

    .line 7
    # invokes: Lokhttp3/internal/http1/Http1Codec;->notifyResponseBodyStart()V
    invoke-static {v0}, Lokhttp3/internal/http1/Http1Codec;->access$000(Lokhttp3/internal/http1/Http1Codec;)V

    .line 8
    :cond_24
    iget-object v4, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->this$0:Lokhttp3/internal/http1/Http1Codec;

    iget-object v2, v4, Lokhttp3/internal/http1/Http1Codec;->streamAllocation:Lokhttp3/internal/connection/StreamAllocation;

    xor-int/lit8 v3, p1, 0x1

    iget-wide v5, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->bytesRead:J

    move-object v7, p2

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

    :cond_30
    return-void

    .line 9
    :cond_31
    new-instance p1, Ljava/lang/IllegalStateException;

    const-string p2, "state: "

    .line 10
    invoke-static {p2}, Landroid/support/v4/media/c;->c(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object p2

    .line 11
    iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->this$0:Lokhttp3/internal/http1/Http1Codec;

    iget v0, v0, Lokhttp3/internal/http1/Http1Codec;->state:I

    invoke-virtual {p2, v0}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    invoke-virtual {p2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object p2

    invoke-direct {p1, p2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V

    throw p1
.end method

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

    const/4 v0, 0x0

    .line 1
    :try_start_1
    iget-object v1, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->this$0:Lokhttp3/internal/http1/Http1Codec;

    iget-object v1, v1, Lokhttp3/internal/http1/Http1Codec;->source:Lokio/d;

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

    move-result-wide p1

    .line 2
    iget-boolean p3, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->invokeStartEvent:Z

    if-eqz p3, :cond_14

    .line 3
    iput-boolean v0, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->invokeStartEvent:Z

    .line 4
    iget-object p3, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->this$0:Lokhttp3/internal/http1/Http1Codec;

    # invokes: Lokhttp3/internal/http1/Http1Codec;->notifyResponseBodyStart()V
    invoke-static {p3}, Lokhttp3/internal/http1/Http1Codec;->access$000(Lokhttp3/internal/http1/Http1Codec;)V

    :cond_14
    const-wide/16 v1, 0x0

    cmp-long p3, p1, v1

    if-lez p3, :cond_1f

    .line 5
    iget-wide v1, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->bytesRead:J

    add-long/2addr v1, p1

    iput-wide v1, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->bytesRead:J

    .line 6
    :cond_1f
    invoke-direct {p0}, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->bytesLengthMetrics()V
    :try_end_22
    .catch Ljava/io/IOException; {:try_start_1 .. :try_end_22} :catch_23

    return-wide p1

    :catch_23
    move-exception p1

    .line 7
    invoke-virtual {p0, v0, p1}, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->endOfInput(ZLjava/io/IOException;)V

    .line 8
    throw p1
.end method

.method public timeout()Lokio/x;
    .registers 2

    iget-object v0, p0, Lokhttp3/internal/http1/Http1Codec$AbstractSource;->timeout:Lokio/h;

    return-object v0
.end method