Http2Stream$FramingSink.smali 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  1. .class final Lokhttp3/internal/http2/Http2Stream$FramingSink;
  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/http2/Http2Stream;
  9. .end annotation
  10. .annotation system Ldalvik/annotation/InnerClass;
  11. accessFlags = 0x10
  12. name = "FramingSink"
  13. .end annotation
  14. # static fields
  15. .field static final synthetic $assertionsDisabled:Z = false
  16. .field private static final EMIT_BUFFER_SIZE:J = 0x4000L
  17. # instance fields
  18. .field closed:Z
  19. .field finished:Z
  20. .field private final sendBuffer:Lokio/Buffer;
  21. .field final synthetic this$0:Lokhttp3/internal/http2/Http2Stream;
  22. # direct methods
  23. .method static constructor <clinit>()V
  24. .locals 0
  25. return-void
  26. .end method
  27. .method constructor <init>(Lokhttp3/internal/http2/Http2Stream;)V
  28. .locals 0
  29. iput-object p1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  30. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  31. new-instance p1, Lokio/Buffer;
  32. invoke-direct {p1}, Lokio/Buffer;-><init>()V
  33. iput-object p1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->sendBuffer:Lokio/Buffer;
  34. return-void
  35. .end method
  36. .method private emitFrame(Z)V
  37. .locals 11
  38. .annotation system Ldalvik/annotation/Throws;
  39. value = {
  40. Ljava/io/IOException;
  41. }
  42. .end annotation
  43. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  44. monitor-enter v0
  45. :try_start_0
  46. iget-object v1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  47. iget-object v1, v1, Lokhttp3/internal/http2/Http2Stream;->writeTimeout:Lokhttp3/internal/http2/Http2Stream$StreamTimeout;
  48. invoke-virtual {v1}, Lokio/AsyncTimeout;->enter()V
  49. :try_end_0
  50. .catchall {:try_start_0 .. :try_end_0} :catchall_2
  51. :goto_0
  52. :try_start_1
  53. iget-object v1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  54. iget-wide v1, v1, Lokhttp3/internal/http2/Http2Stream;->bytesLeftInWriteWindow:J
  55. const-wide/16 v3, 0x0
  56. cmp-long v5, v1, v3
  57. if-gtz v5, :cond_0
  58. iget-boolean v1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->finished:Z
  59. if-nez v1, :cond_0
  60. iget-boolean v1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->closed:Z
  61. if-nez v1, :cond_0
  62. iget-object v1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  63. iget-object v1, v1, Lokhttp3/internal/http2/Http2Stream;->errorCode:Lokhttp3/internal/http2/ErrorCode;
  64. if-nez v1, :cond_0
  65. iget-object v1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  66. invoke-virtual {v1}, Lokhttp3/internal/http2/Http2Stream;->waitForIo()V
  67. :try_end_1
  68. .catchall {:try_start_1 .. :try_end_1} :catchall_1
  69. goto :goto_0
  70. :cond_0
  71. :try_start_2
  72. iget-object v1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  73. iget-object v1, v1, Lokhttp3/internal/http2/Http2Stream;->writeTimeout:Lokhttp3/internal/http2/Http2Stream$StreamTimeout;
  74. invoke-virtual {v1}, Lokhttp3/internal/http2/Http2Stream$StreamTimeout;->exitAndThrowIfTimedOut()V
  75. iget-object v1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  76. invoke-virtual {v1}, Lokhttp3/internal/http2/Http2Stream;->checkOutNotClosed()V
  77. iget-object v1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  78. iget-wide v1, v1, Lokhttp3/internal/http2/Http2Stream;->bytesLeftInWriteWindow:J
  79. iget-object v3, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->sendBuffer:Lokio/Buffer;
  80. invoke-virtual {v3}, Lokio/Buffer;->size()J
  81. move-result-wide v3
  82. invoke-static {v1, v2, v3, v4}, Ljava/lang/Math;->min(JJ)J
  83. move-result-wide v9
  84. iget-object v1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  85. iget-wide v2, v1, Lokhttp3/internal/http2/Http2Stream;->bytesLeftInWriteWindow:J
  86. sub-long/2addr v2, v9
  87. iput-wide v2, v1, Lokhttp3/internal/http2/Http2Stream;->bytesLeftInWriteWindow:J
  88. monitor-exit v0
  89. :try_end_2
  90. .catchall {:try_start_2 .. :try_end_2} :catchall_2
  91. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  92. iget-object v0, v0, Lokhttp3/internal/http2/Http2Stream;->writeTimeout:Lokhttp3/internal/http2/Http2Stream$StreamTimeout;
  93. invoke-virtual {v0}, Lokio/AsyncTimeout;->enter()V
  94. :try_start_3
  95. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  96. iget-object v5, v0, Lokhttp3/internal/http2/Http2Stream;->connection:Lokhttp3/internal/http2/Http2Connection;
  97. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  98. iget v6, v0, Lokhttp3/internal/http2/Http2Stream;->id:I
  99. if-eqz p1, :cond_1
  100. iget-object p1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->sendBuffer:Lokio/Buffer;
  101. invoke-virtual {p1}, Lokio/Buffer;->size()J
  102. move-result-wide v0
  103. cmp-long p1, v9, v0
  104. if-nez p1, :cond_1
  105. const/4 p1, 0x1
  106. const/4 v7, 0x1
  107. goto :goto_1
  108. :cond_1
  109. const/4 p1, 0x0
  110. const/4 v7, 0x0
  111. :goto_1
  112. iget-object v8, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->sendBuffer:Lokio/Buffer;
  113. invoke-virtual/range {v5 .. v10}, Lokhttp3/internal/http2/Http2Connection;->writeData(IZLokio/Buffer;J)V
  114. :try_end_3
  115. .catchall {:try_start_3 .. :try_end_3} :catchall_0
  116. iget-object p1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  117. iget-object p1, p1, Lokhttp3/internal/http2/Http2Stream;->writeTimeout:Lokhttp3/internal/http2/Http2Stream$StreamTimeout;
  118. invoke-virtual {p1}, Lokhttp3/internal/http2/Http2Stream$StreamTimeout;->exitAndThrowIfTimedOut()V
  119. return-void
  120. :catchall_0
  121. move-exception p1
  122. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  123. iget-object v0, v0, Lokhttp3/internal/http2/Http2Stream;->writeTimeout:Lokhttp3/internal/http2/Http2Stream$StreamTimeout;
  124. invoke-virtual {v0}, Lokhttp3/internal/http2/Http2Stream$StreamTimeout;->exitAndThrowIfTimedOut()V
  125. throw p1
  126. :catchall_1
  127. move-exception p1
  128. :try_start_4
  129. iget-object v1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  130. iget-object v1, v1, Lokhttp3/internal/http2/Http2Stream;->writeTimeout:Lokhttp3/internal/http2/Http2Stream$StreamTimeout;
  131. invoke-virtual {v1}, Lokhttp3/internal/http2/Http2Stream$StreamTimeout;->exitAndThrowIfTimedOut()V
  132. throw p1
  133. :catchall_2
  134. move-exception p1
  135. monitor-exit v0
  136. :try_end_4
  137. .catchall {:try_start_4 .. :try_end_4} :catchall_2
  138. goto :goto_3
  139. :goto_2
  140. throw p1
  141. :goto_3
  142. goto :goto_2
  143. .end method
  144. # virtual methods
  145. .method public close()V
  146. .locals 8
  147. .annotation system Ldalvik/annotation/Throws;
  148. value = {
  149. Ljava/io/IOException;
  150. }
  151. .end annotation
  152. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  153. monitor-enter v0
  154. :try_start_0
  155. iget-boolean v1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->closed:Z
  156. if-eqz v1, :cond_0
  157. monitor-exit v0
  158. return-void
  159. :cond_0
  160. monitor-exit v0
  161. :try_end_0
  162. .catchall {:try_start_0 .. :try_end_0} :catchall_1
  163. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  164. iget-object v0, v0, Lokhttp3/internal/http2/Http2Stream;->sink:Lokhttp3/internal/http2/Http2Stream$FramingSink;
  165. iget-boolean v0, v0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->finished:Z
  166. const/4 v1, 0x1
  167. if-nez v0, :cond_2
  168. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->sendBuffer:Lokio/Buffer;
  169. invoke-virtual {v0}, Lokio/Buffer;->size()J
  170. move-result-wide v2
  171. const-wide/16 v4, 0x0
  172. cmp-long v0, v2, v4
  173. if-lez v0, :cond_1
  174. :goto_0
  175. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->sendBuffer:Lokio/Buffer;
  176. invoke-virtual {v0}, Lokio/Buffer;->size()J
  177. move-result-wide v2
  178. cmp-long v0, v2, v4
  179. if-lez v0, :cond_2
  180. invoke-direct {p0, v1}, Lokhttp3/internal/http2/Http2Stream$FramingSink;->emitFrame(Z)V
  181. goto :goto_0
  182. :cond_1
  183. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  184. iget-object v2, v0, Lokhttp3/internal/http2/Http2Stream;->connection:Lokhttp3/internal/http2/Http2Connection;
  185. iget v3, v0, Lokhttp3/internal/http2/Http2Stream;->id:I
  186. const/4 v4, 0x1
  187. const/4 v5, 0x0
  188. const-wide/16 v6, 0x0
  189. invoke-virtual/range {v2 .. v7}, Lokhttp3/internal/http2/Http2Connection;->writeData(IZLokio/Buffer;J)V
  190. :cond_2
  191. iget-object v2, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  192. monitor-enter v2
  193. :try_start_1
  194. iput-boolean v1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->closed:Z
  195. monitor-exit v2
  196. :try_end_1
  197. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  198. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  199. iget-object v0, v0, Lokhttp3/internal/http2/Http2Stream;->connection:Lokhttp3/internal/http2/Http2Connection;
  200. invoke-virtual {v0}, Lokhttp3/internal/http2/Http2Connection;->flush()V
  201. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  202. invoke-virtual {v0}, Lokhttp3/internal/http2/Http2Stream;->cancelStreamIfNecessary()V
  203. return-void
  204. :catchall_0
  205. move-exception v0
  206. :try_start_2
  207. monitor-exit v2
  208. :try_end_2
  209. .catchall {:try_start_2 .. :try_end_2} :catchall_0
  210. throw v0
  211. :catchall_1
  212. move-exception v1
  213. :try_start_3
  214. monitor-exit v0
  215. :try_end_3
  216. .catchall {:try_start_3 .. :try_end_3} :catchall_1
  217. goto :goto_2
  218. :goto_1
  219. throw v1
  220. :goto_2
  221. goto :goto_1
  222. .end method
  223. .method public flush()V
  224. .locals 5
  225. .annotation system Ldalvik/annotation/Throws;
  226. value = {
  227. Ljava/io/IOException;
  228. }
  229. .end annotation
  230. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  231. monitor-enter v0
  232. :try_start_0
  233. iget-object v1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  234. invoke-virtual {v1}, Lokhttp3/internal/http2/Http2Stream;->checkOutNotClosed()V
  235. monitor-exit v0
  236. :try_end_0
  237. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  238. :goto_0
  239. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->sendBuffer:Lokio/Buffer;
  240. invoke-virtual {v0}, Lokio/Buffer;->size()J
  241. move-result-wide v0
  242. const-wide/16 v2, 0x0
  243. cmp-long v4, v0, v2
  244. if-lez v4, :cond_0
  245. const/4 v0, 0x0
  246. invoke-direct {p0, v0}, Lokhttp3/internal/http2/Http2Stream$FramingSink;->emitFrame(Z)V
  247. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  248. iget-object v0, v0, Lokhttp3/internal/http2/Http2Stream;->connection:Lokhttp3/internal/http2/Http2Connection;
  249. invoke-virtual {v0}, Lokhttp3/internal/http2/Http2Connection;->flush()V
  250. goto :goto_0
  251. :cond_0
  252. return-void
  253. :catchall_0
  254. move-exception v1
  255. :try_start_1
  256. monitor-exit v0
  257. :try_end_1
  258. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  259. goto :goto_2
  260. :goto_1
  261. throw v1
  262. :goto_2
  263. goto :goto_1
  264. .end method
  265. .method public timeout()Lokio/Timeout;
  266. .locals 1
  267. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->this$0:Lokhttp3/internal/http2/Http2Stream;
  268. iget-object v0, v0, Lokhttp3/internal/http2/Http2Stream;->writeTimeout:Lokhttp3/internal/http2/Http2Stream$StreamTimeout;
  269. return-object v0
  270. .end method
  271. .method public write(Lokio/Buffer;J)V
  272. .locals 2
  273. .annotation system Ldalvik/annotation/Throws;
  274. value = {
  275. Ljava/io/IOException;
  276. }
  277. .end annotation
  278. iget-object v0, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->sendBuffer:Lokio/Buffer;
  279. invoke-virtual {v0, p1, p2, p3}, Lokio/Buffer;->write(Lokio/Buffer;J)V
  280. :goto_0
  281. iget-object p1, p0, Lokhttp3/internal/http2/Http2Stream$FramingSink;->sendBuffer:Lokio/Buffer;
  282. invoke-virtual {p1}, Lokio/Buffer;->size()J
  283. move-result-wide p1
  284. const-wide/16 v0, 0x4000
  285. cmp-long p3, p1, v0
  286. if-ltz p3, :cond_0
  287. const/4 p1, 0x0
  288. invoke-direct {p0, p1}, Lokhttp3/internal/http2/Http2Stream$FramingSink;->emitFrame(Z)V
  289. goto :goto_0
  290. :cond_0
  291. return-void
  292. .end method