Relay$RelaySource.smali 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564
  1. .class Lokhttp3/internal/cache2/Relay$RelaySource;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # interfaces
  5. .implements Lokio/Source;
  6. # annotations
  7. .annotation system Ldalvik/annotation/EnclosingClass;
  8. value = Lokhttp3/internal/cache2/Relay;
  9. .end annotation
  10. .annotation system Ldalvik/annotation/InnerClass;
  11. accessFlags = 0x0
  12. name = "RelaySource"
  13. .end annotation
  14. # instance fields
  15. .field private fileOperator:Lokhttp3/internal/cache2/FileOperator;
  16. .field private sourcePos:J
  17. .field final synthetic this$0:Lokhttp3/internal/cache2/Relay;
  18. .field private final timeout:Lokio/Timeout;
  19. # direct methods
  20. .method constructor <init>(Lokhttp3/internal/cache2/Relay;)V
  21. .locals 1
  22. iput-object p1, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  23. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  24. new-instance p1, Lokio/Timeout;
  25. invoke-direct {p1}, Lokio/Timeout;-><init>()V
  26. iput-object p1, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->timeout:Lokio/Timeout;
  27. new-instance p1, Lokhttp3/internal/cache2/FileOperator;
  28. iget-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  29. iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
  30. invoke-virtual {v0}, Ljava/io/RandomAccessFile;->getChannel()Ljava/nio/channels/FileChannel;
  31. move-result-object v0
  32. invoke-direct {p1, v0}, Lokhttp3/internal/cache2/FileOperator;-><init>(Ljava/nio/channels/FileChannel;)V
  33. iput-object p1, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
  34. return-void
  35. .end method
  36. # virtual methods
  37. .method public close()V
  38. .locals 4
  39. .annotation system Ldalvik/annotation/Throws;
  40. value = {
  41. Ljava/io/IOException;
  42. }
  43. .end annotation
  44. iget-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
  45. if-nez v0, :cond_0
  46. return-void
  47. :cond_0
  48. const/4 v0, 0x0
  49. iput-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
  50. iget-object v1, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  51. monitor-enter v1
  52. :try_start_0
  53. iget-object v2, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  54. iget v3, v2, Lokhttp3/internal/cache2/Relay;->sourceCount:I
  55. add-int/lit8 v3, v3, -0x1
  56. iput v3, v2, Lokhttp3/internal/cache2/Relay;->sourceCount:I
  57. iget-object v2, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  58. iget v2, v2, Lokhttp3/internal/cache2/Relay;->sourceCount:I
  59. if-nez v2, :cond_1
  60. iget-object v2, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  61. iget-object v2, v2, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
  62. iget-object v3, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  63. iput-object v0, v3, Lokhttp3/internal/cache2/Relay;->file:Ljava/io/RandomAccessFile;
  64. move-object v0, v2
  65. :cond_1
  66. monitor-exit v1
  67. :try_end_0
  68. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  69. if-eqz v0, :cond_2
  70. invoke-static {v0}, Lokhttp3/internal/Util;->closeQuietly(Ljava/io/Closeable;)V
  71. :cond_2
  72. return-void
  73. :catchall_0
  74. move-exception v0
  75. :try_start_1
  76. monitor-exit v1
  77. :try_end_1
  78. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  79. throw v0
  80. .end method
  81. .method public read(Lokio/Buffer;J)J
  82. .locals 21
  83. .annotation system Ldalvik/annotation/Throws;
  84. value = {
  85. Ljava/io/IOException;
  86. }
  87. .end annotation
  88. move-object/from16 v1, p0
  89. move-wide/from16 v2, p2
  90. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
  91. if-eqz v0, :cond_7
  92. iget-object v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  93. monitor-enter v4
  94. :goto_0
  95. :try_start_0
  96. iget-wide v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
  97. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  98. iget-wide v7, v0, Lokhttp3/internal/cache2/Relay;->upstreamPos:J
  99. const/4 v0, 0x2
  100. const-wide/16 v9, -0x1
  101. cmp-long v11, v5, v7
  102. if-nez v11, :cond_2
  103. iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  104. iget-boolean v5, v5, Lokhttp3/internal/cache2/Relay;->complete:Z
  105. if-eqz v5, :cond_0
  106. monitor-exit v4
  107. return-wide v9
  108. :cond_0
  109. iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  110. iget-object v5, v5, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
  111. if-eqz v5, :cond_1
  112. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->timeout:Lokio/Timeout;
  113. iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  114. invoke-virtual {v0, v5}, Lokio/Timeout;->waitUntilNotified(Ljava/lang/Object;)V
  115. goto :goto_0
  116. :cond_1
  117. iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  118. invoke-static {}, Ljava/lang/Thread;->currentThread()Ljava/lang/Thread;
  119. move-result-object v6
  120. iput-object v6, v5, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
  121. const/4 v5, 0x1
  122. monitor-exit v4
  123. goto :goto_1
  124. :cond_2
  125. iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  126. iget-object v5, v5, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
  127. invoke-virtual {v5}, Lokio/Buffer;->size()J
  128. move-result-wide v5
  129. sub-long v5, v7, v5
  130. iget-wide v11, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
  131. cmp-long v13, v11, v5
  132. if-gez v13, :cond_6
  133. monitor-exit v4
  134. :try_end_0
  135. .catchall {:try_start_0 .. :try_end_0} :catchall_5
  136. const/4 v5, 0x2
  137. :goto_1
  138. const-wide/16 v11, 0x20
  139. if-ne v5, v0, :cond_3
  140. iget-wide v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
  141. sub-long/2addr v7, v4
  142. invoke-static {v2, v3, v7, v8}, Ljava/lang/Math;->min(JJ)J
  143. move-result-wide v2
  144. iget-object v13, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
  145. iget-wide v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
  146. add-long v14, v4, v11
  147. move-object/from16 v16, p1
  148. move-wide/from16 v17, v2
  149. invoke-virtual/range {v13 .. v18}, Lokhttp3/internal/cache2/FileOperator;->read(JLokio/Buffer;J)V
  150. iget-wide v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
  151. add-long/2addr v4, v2
  152. iput-wide v4, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
  153. return-wide v2
  154. :cond_3
  155. const/4 v4, 0x0
  156. :try_start_1
  157. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  158. iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->upstream:Lokio/Source;
  159. iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  160. iget-object v5, v5, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/Buffer;
  161. iget-object v6, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  162. iget-wide v13, v6, Lokhttp3/internal/cache2/Relay;->bufferMaxSize:J
  163. invoke-interface {v0, v5, v13, v14}, Lokio/Source;->read(Lokio/Buffer;J)J
  164. move-result-wide v5
  165. cmp-long v0, v5, v9
  166. if-nez v0, :cond_4
  167. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  168. invoke-virtual {v0, v7, v8}, Lokhttp3/internal/cache2/Relay;->commit(J)V
  169. :try_end_1
  170. .catchall {:try_start_1 .. :try_end_1} :catchall_3
  171. iget-object v2, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  172. monitor-enter v2
  173. :try_start_2
  174. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  175. iput-object v4, v0, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
  176. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  177. invoke-virtual {v0}, Ljava/lang/Object;->notifyAll()V
  178. monitor-exit v2
  179. return-wide v9
  180. :catchall_0
  181. move-exception v0
  182. monitor-exit v2
  183. :try_end_2
  184. .catchall {:try_start_2 .. :try_end_2} :catchall_0
  185. throw v0
  186. :cond_4
  187. :try_start_3
  188. invoke-static {v5, v6, v2, v3}, Ljava/lang/Math;->min(JJ)J
  189. move-result-wide v2
  190. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  191. iget-object v13, v0, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/Buffer;
  192. const-wide/16 v15, 0x0
  193. move-object/from16 v14, p1
  194. move-wide/from16 v17, v2
  195. invoke-virtual/range {v13 .. v18}, Lokio/Buffer;->copyTo(Lokio/Buffer;JJ)Lokio/Buffer;
  196. iget-wide v9, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
  197. add-long/2addr v9, v2
  198. iput-wide v9, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
  199. iget-object v15, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->fileOperator:Lokhttp3/internal/cache2/FileOperator;
  200. add-long v16, v7, v11
  201. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  202. iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/Buffer;
  203. invoke-virtual {v0}, Lokio/Buffer;->clone()Lokio/Buffer;
  204. move-result-object v18
  205. move-wide/from16 v19, v5
  206. invoke-virtual/range {v15 .. v20}, Lokhttp3/internal/cache2/FileOperator;->write(JLokio/Buffer;J)V
  207. iget-object v7, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  208. monitor-enter v7
  209. :try_end_3
  210. .catchall {:try_start_3 .. :try_end_3} :catchall_3
  211. :try_start_4
  212. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  213. iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
  214. iget-object v8, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  215. iget-object v8, v8, Lokhttp3/internal/cache2/Relay;->upstreamBuffer:Lokio/Buffer;
  216. invoke-virtual {v0, v8, v5, v6}, Lokio/Buffer;->write(Lokio/Buffer;J)V
  217. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  218. iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
  219. invoke-virtual {v0}, Lokio/Buffer;->size()J
  220. move-result-wide v8
  221. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  222. iget-wide v10, v0, Lokhttp3/internal/cache2/Relay;->bufferMaxSize:J
  223. cmp-long v0, v8, v10
  224. if-lez v0, :cond_5
  225. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  226. iget-object v0, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
  227. iget-object v8, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  228. iget-object v8, v8, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
  229. invoke-virtual {v8}, Lokio/Buffer;->size()J
  230. move-result-wide v8
  231. iget-object v10, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  232. iget-wide v10, v10, Lokhttp3/internal/cache2/Relay;->bufferMaxSize:J
  233. sub-long/2addr v8, v10
  234. invoke-virtual {v0, v8, v9}, Lokio/Buffer;->skip(J)V
  235. :cond_5
  236. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  237. iget-wide v8, v0, Lokhttp3/internal/cache2/Relay;->upstreamPos:J
  238. add-long/2addr v8, v5
  239. iput-wide v8, v0, Lokhttp3/internal/cache2/Relay;->upstreamPos:J
  240. monitor-exit v7
  241. :try_end_4
  242. .catchall {:try_start_4 .. :try_end_4} :catchall_2
  243. iget-object v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  244. monitor-enter v5
  245. :try_start_5
  246. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  247. iput-object v4, v0, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
  248. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  249. invoke-virtual {v0}, Ljava/lang/Object;->notifyAll()V
  250. monitor-exit v5
  251. return-wide v2
  252. :catchall_1
  253. move-exception v0
  254. monitor-exit v5
  255. :try_end_5
  256. .catchall {:try_start_5 .. :try_end_5} :catchall_1
  257. throw v0
  258. :catchall_2
  259. move-exception v0
  260. :try_start_6
  261. monitor-exit v7
  262. :try_end_6
  263. .catchall {:try_start_6 .. :try_end_6} :catchall_2
  264. :try_start_7
  265. throw v0
  266. :try_end_7
  267. .catchall {:try_start_7 .. :try_end_7} :catchall_3
  268. :catchall_3
  269. move-exception v0
  270. iget-object v2, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  271. monitor-enter v2
  272. :try_start_8
  273. iget-object v3, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  274. iput-object v4, v3, Lokhttp3/internal/cache2/Relay;->upstreamReader:Ljava/lang/Thread;
  275. iget-object v3, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  276. invoke-virtual {v3}, Ljava/lang/Object;->notifyAll()V
  277. monitor-exit v2
  278. :try_end_8
  279. .catchall {:try_start_8 .. :try_end_8} :catchall_4
  280. throw v0
  281. :catchall_4
  282. move-exception v0
  283. :try_start_9
  284. monitor-exit v2
  285. :try_end_9
  286. .catchall {:try_start_9 .. :try_end_9} :catchall_4
  287. throw v0
  288. :cond_6
  289. :try_start_a
  290. iget-wide v9, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
  291. sub-long/2addr v7, v9
  292. invoke-static {v2, v3, v7, v8}, Ljava/lang/Math;->min(JJ)J
  293. move-result-wide v2
  294. iget-object v0, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->this$0:Lokhttp3/internal/cache2/Relay;
  295. iget-object v9, v0, Lokhttp3/internal/cache2/Relay;->buffer:Lokio/Buffer;
  296. iget-wide v7, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
  297. sub-long v11, v7, v5
  298. move-object/from16 v10, p1
  299. move-wide v13, v2
  300. invoke-virtual/range {v9 .. v14}, Lokio/Buffer;->copyTo(Lokio/Buffer;JJ)Lokio/Buffer;
  301. iget-wide v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
  302. add-long/2addr v5, v2
  303. iput-wide v5, v1, Lokhttp3/internal/cache2/Relay$RelaySource;->sourcePos:J
  304. monitor-exit v4
  305. return-wide v2
  306. :catchall_5
  307. move-exception v0
  308. monitor-exit v4
  309. :try_end_a
  310. .catchall {:try_start_a .. :try_end_a} :catchall_5
  311. throw v0
  312. :cond_7
  313. new-instance v0, Ljava/lang/IllegalStateException;
  314. const-string v2, "closed"
  315. invoke-direct {v0, v2}, Ljava/lang/IllegalStateException;-><init>(Ljava/lang/String;)V
  316. goto :goto_3
  317. :goto_2
  318. throw v0
  319. :goto_3
  320. goto :goto_2
  321. .end method
  322. .method public timeout()Lokio/Timeout;
  323. .locals 1
  324. iget-object v0, p0, Lokhttp3/internal/cache2/Relay$RelaySource;->timeout:Lokio/Timeout;
  325. return-object v0
  326. .end method