WebSocketWriter$FrameSink.smali 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  1. .class final Lokhttp3/internal/ws/WebSocketWriter$FrameSink;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # interfaces
  5. .implements Lokio/Sink;
  6. # annotations
  7. .annotation system Ldalvik/annotation/EnclosingClass;
  8. value = Lokhttp3/internal/ws/WebSocketWriter;
  9. .end annotation
  10. .annotation system Ldalvik/annotation/InnerClass;
  11. accessFlags = 0x10
  12. name = "FrameSink"
  13. .end annotation
  14. # instance fields
  15. .field closed:Z
  16. .field contentLength:J
  17. .field formatOpcode:I
  18. .field isFirstFrame:Z
  19. .field final synthetic this$0:Lokhttp3/internal/ws/WebSocketWriter;
  20. # direct methods
  21. .method constructor <init>(Lokhttp3/internal/ws/WebSocketWriter;)V
  22. .locals 0
  23. iput-object p1, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->this$0:Lokhttp3/internal/ws/WebSocketWriter;
  24. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  25. return-void
  26. .end method
  27. # virtual methods
  28. .method public close()V
  29. .locals 7
  30. .annotation system Ldalvik/annotation/Throws;
  31. value = {
  32. Ljava/io/IOException;
  33. }
  34. .end annotation
  35. iget-boolean v0, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->closed:Z
  36. if-nez v0, :cond_0
  37. iget-object v1, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->this$0:Lokhttp3/internal/ws/WebSocketWriter;
  38. iget v2, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->formatOpcode:I
  39. iget-object v0, v1, Lokhttp3/internal/ws/WebSocketWriter;->buffer:Lokio/Buffer;
  40. invoke-virtual {v0}, Lokio/Buffer;->size()J
  41. move-result-wide v3
  42. iget-boolean v5, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->isFirstFrame:Z
  43. const/4 v6, 0x1
  44. invoke-virtual/range {v1 .. v6}, Lokhttp3/internal/ws/WebSocketWriter;->writeMessageFrame(IJZZ)V
  45. const/4 v0, 0x1
  46. iput-boolean v0, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->closed:Z
  47. iget-object v0, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->this$0:Lokhttp3/internal/ws/WebSocketWriter;
  48. const/4 v1, 0x0
  49. iput-boolean v1, v0, Lokhttp3/internal/ws/WebSocketWriter;->activeWriter:Z
  50. return-void
  51. :cond_0
  52. new-instance v0, Ljava/io/IOException;
  53. const-string v1, "closed"
  54. invoke-direct {v0, v1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
  55. throw v0
  56. .end method
  57. .method public flush()V
  58. .locals 7
  59. .annotation system Ldalvik/annotation/Throws;
  60. value = {
  61. Ljava/io/IOException;
  62. }
  63. .end annotation
  64. iget-boolean v0, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->closed:Z
  65. if-nez v0, :cond_0
  66. iget-object v1, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->this$0:Lokhttp3/internal/ws/WebSocketWriter;
  67. iget v2, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->formatOpcode:I
  68. iget-object v0, v1, Lokhttp3/internal/ws/WebSocketWriter;->buffer:Lokio/Buffer;
  69. invoke-virtual {v0}, Lokio/Buffer;->size()J
  70. move-result-wide v3
  71. iget-boolean v5, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->isFirstFrame:Z
  72. const/4 v6, 0x0
  73. invoke-virtual/range {v1 .. v6}, Lokhttp3/internal/ws/WebSocketWriter;->writeMessageFrame(IJZZ)V
  74. const/4 v0, 0x0
  75. iput-boolean v0, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->isFirstFrame:Z
  76. return-void
  77. :cond_0
  78. new-instance v0, Ljava/io/IOException;
  79. const-string v1, "closed"
  80. invoke-direct {v0, v1}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
  81. throw v0
  82. .end method
  83. .method public timeout()Lokio/Timeout;
  84. .locals 1
  85. iget-object v0, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->this$0:Lokhttp3/internal/ws/WebSocketWriter;
  86. iget-object v0, v0, Lokhttp3/internal/ws/WebSocketWriter;->sink:Lokio/BufferedSink;
  87. invoke-interface {v0}, Lokio/Sink;->timeout()Lokio/Timeout;
  88. move-result-object v0
  89. return-object v0
  90. .end method
  91. .method public write(Lokio/Buffer;J)V
  92. .locals 6
  93. .annotation system Ldalvik/annotation/Throws;
  94. value = {
  95. Ljava/io/IOException;
  96. }
  97. .end annotation
  98. iget-boolean v0, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->closed:Z
  99. if-nez v0, :cond_2
  100. iget-object v0, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->this$0:Lokhttp3/internal/ws/WebSocketWriter;
  101. iget-object v0, v0, Lokhttp3/internal/ws/WebSocketWriter;->buffer:Lokio/Buffer;
  102. invoke-virtual {v0, p1, p2, p3}, Lokio/Buffer;->write(Lokio/Buffer;J)V
  103. iget-boolean p1, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->isFirstFrame:Z
  104. const/4 p2, 0x0
  105. if-eqz p1, :cond_0
  106. iget-wide v0, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->contentLength:J
  107. const-wide/16 v2, -0x1
  108. cmp-long p1, v0, v2
  109. if-eqz p1, :cond_0
  110. iget-object p1, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->this$0:Lokhttp3/internal/ws/WebSocketWriter;
  111. iget-object p1, p1, Lokhttp3/internal/ws/WebSocketWriter;->buffer:Lokio/Buffer;
  112. invoke-virtual {p1}, Lokio/Buffer;->size()J
  113. move-result-wide v0
  114. iget-wide v2, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->contentLength:J
  115. const-wide/16 v4, 0x2000
  116. sub-long/2addr v2, v4
  117. cmp-long p1, v0, v2
  118. if-lez p1, :cond_0
  119. const/4 p1, 0x1
  120. goto :goto_0
  121. :cond_0
  122. const/4 p1, 0x0
  123. :goto_0
  124. iget-object p3, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->this$0:Lokhttp3/internal/ws/WebSocketWriter;
  125. iget-object p3, p3, Lokhttp3/internal/ws/WebSocketWriter;->buffer:Lokio/Buffer;
  126. invoke-virtual {p3}, Lokio/Buffer;->completeSegmentByteCount()J
  127. move-result-wide v2
  128. const-wide/16 v0, 0x0
  129. cmp-long p3, v2, v0
  130. if-lez p3, :cond_1
  131. if-nez p1, :cond_1
  132. iget-object v0, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->this$0:Lokhttp3/internal/ws/WebSocketWriter;
  133. iget v1, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->formatOpcode:I
  134. iget-boolean v4, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->isFirstFrame:Z
  135. const/4 v5, 0x0
  136. invoke-virtual/range {v0 .. v5}, Lokhttp3/internal/ws/WebSocketWriter;->writeMessageFrame(IJZZ)V
  137. iput-boolean p2, p0, Lokhttp3/internal/ws/WebSocketWriter$FrameSink;->isFirstFrame:Z
  138. :cond_1
  139. return-void
  140. :cond_2
  141. new-instance p1, Ljava/io/IOException;
  142. const-string p2, "closed"
  143. invoke-direct {p1, p2}, Ljava/io/IOException;-><init>(Ljava/lang/String;)V
  144. throw p1
  145. .end method