DiskLruCache$Editor.smali 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  1. .class public final Lokhttp3/internal/cache/DiskLruCache$Editor;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # annotations
  5. .annotation system Ldalvik/annotation/EnclosingClass;
  6. value = Lokhttp3/internal/cache/DiskLruCache;
  7. .end annotation
  8. .annotation system Ldalvik/annotation/InnerClass;
  9. accessFlags = 0x11
  10. name = "Editor"
  11. .end annotation
  12. # instance fields
  13. .field private done:Z
  14. .field final entry:Lokhttp3/internal/cache/DiskLruCache$Entry;
  15. .field final synthetic this$0:Lokhttp3/internal/cache/DiskLruCache;
  16. .field final written:[Z
  17. # direct methods
  18. .method constructor <init>(Lokhttp3/internal/cache/DiskLruCache;Lokhttp3/internal/cache/DiskLruCache$Entry;)V
  19. .locals 0
  20. iput-object p1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->this$0:Lokhttp3/internal/cache/DiskLruCache;
  21. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  22. iput-object p2, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->entry:Lokhttp3/internal/cache/DiskLruCache$Entry;
  23. iget-boolean p2, p2, Lokhttp3/internal/cache/DiskLruCache$Entry;->readable:Z
  24. if-eqz p2, :cond_0
  25. const/4 p1, 0x0
  26. goto :goto_0
  27. :cond_0
  28. iget p1, p1, Lokhttp3/internal/cache/DiskLruCache;->valueCount:I
  29. new-array p1, p1, [Z
  30. :goto_0
  31. iput-object p1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->written:[Z
  32. return-void
  33. .end method
  34. # virtual methods
  35. .method public abort()V
  36. .locals 3
  37. .annotation system Ldalvik/annotation/Throws;
  38. value = {
  39. Ljava/io/IOException;
  40. }
  41. .end annotation
  42. iget-object v0, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->this$0:Lokhttp3/internal/cache/DiskLruCache;
  43. monitor-enter v0
  44. :try_start_0
  45. iget-boolean v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->done:Z
  46. if-nez v1, :cond_1
  47. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->entry:Lokhttp3/internal/cache/DiskLruCache$Entry;
  48. iget-object v1, v1, Lokhttp3/internal/cache/DiskLruCache$Entry;->currentEditor:Lokhttp3/internal/cache/DiskLruCache$Editor;
  49. if-ne v1, p0, :cond_0
  50. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->this$0:Lokhttp3/internal/cache/DiskLruCache;
  51. const/4 v2, 0x0
  52. invoke-virtual {v1, p0, v2}, Lokhttp3/internal/cache/DiskLruCache;->completeEdit(Lokhttp3/internal/cache/DiskLruCache$Editor;Z)V
  53. :cond_0
  54. const/4 v1, 0x1
  55. iput-boolean v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->done:Z
  56. monitor-exit v0
  57. return-void
  58. :cond_1
  59. new-instance v1, Ljava/lang/IllegalStateException;
  60. invoke-direct {v1}, Ljava/lang/IllegalStateException;-><init>()V
  61. throw v1
  62. :catchall_0
  63. move-exception v1
  64. monitor-exit v0
  65. :try_end_0
  66. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  67. throw v1
  68. .end method
  69. .method public abortUnlessCommitted()V
  70. .locals 3
  71. iget-object v0, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->this$0:Lokhttp3/internal/cache/DiskLruCache;
  72. monitor-enter v0
  73. :try_start_0
  74. iget-boolean v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->done:Z
  75. if-nez v1, :cond_0
  76. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->entry:Lokhttp3/internal/cache/DiskLruCache$Entry;
  77. iget-object v1, v1, Lokhttp3/internal/cache/DiskLruCache$Entry;->currentEditor:Lokhttp3/internal/cache/DiskLruCache$Editor;
  78. :try_end_0
  79. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  80. if-ne v1, p0, :cond_0
  81. :try_start_1
  82. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->this$0:Lokhttp3/internal/cache/DiskLruCache;
  83. const/4 v2, 0x0
  84. invoke-virtual {v1, p0, v2}, Lokhttp3/internal/cache/DiskLruCache;->completeEdit(Lokhttp3/internal/cache/DiskLruCache$Editor;Z)V
  85. :try_end_1
  86. .catch Ljava/io/IOException; {:try_start_1 .. :try_end_1} :catch_0
  87. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  88. :catch_0
  89. :cond_0
  90. :try_start_2
  91. monitor-exit v0
  92. return-void
  93. :catchall_0
  94. move-exception v1
  95. monitor-exit v0
  96. :try_end_2
  97. .catchall {:try_start_2 .. :try_end_2} :catchall_0
  98. throw v1
  99. .end method
  100. .method public commit()V
  101. .locals 3
  102. .annotation system Ldalvik/annotation/Throws;
  103. value = {
  104. Ljava/io/IOException;
  105. }
  106. .end annotation
  107. iget-object v0, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->this$0:Lokhttp3/internal/cache/DiskLruCache;
  108. monitor-enter v0
  109. :try_start_0
  110. iget-boolean v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->done:Z
  111. if-nez v1, :cond_1
  112. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->entry:Lokhttp3/internal/cache/DiskLruCache$Entry;
  113. iget-object v1, v1, Lokhttp3/internal/cache/DiskLruCache$Entry;->currentEditor:Lokhttp3/internal/cache/DiskLruCache$Editor;
  114. const/4 v2, 0x1
  115. if-ne v1, p0, :cond_0
  116. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->this$0:Lokhttp3/internal/cache/DiskLruCache;
  117. invoke-virtual {v1, p0, v2}, Lokhttp3/internal/cache/DiskLruCache;->completeEdit(Lokhttp3/internal/cache/DiskLruCache$Editor;Z)V
  118. :cond_0
  119. iput-boolean v2, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->done:Z
  120. monitor-exit v0
  121. return-void
  122. :cond_1
  123. new-instance v1, Ljava/lang/IllegalStateException;
  124. invoke-direct {v1}, Ljava/lang/IllegalStateException;-><init>()V
  125. throw v1
  126. :catchall_0
  127. move-exception v1
  128. monitor-exit v0
  129. :try_end_0
  130. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  131. throw v1
  132. .end method
  133. .method detach()V
  134. .locals 3
  135. iget-object v0, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->entry:Lokhttp3/internal/cache/DiskLruCache$Entry;
  136. iget-object v0, v0, Lokhttp3/internal/cache/DiskLruCache$Entry;->currentEditor:Lokhttp3/internal/cache/DiskLruCache$Editor;
  137. if-ne v0, p0, :cond_1
  138. const/4 v0, 0x0
  139. :goto_0
  140. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->this$0:Lokhttp3/internal/cache/DiskLruCache;
  141. iget v2, v1, Lokhttp3/internal/cache/DiskLruCache;->valueCount:I
  142. if-ge v0, v2, :cond_0
  143. :try_start_0
  144. iget-object v1, v1, Lokhttp3/internal/cache/DiskLruCache;->fileSystem:Lokhttp3/internal/io/FileSystem;
  145. iget-object v2, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->entry:Lokhttp3/internal/cache/DiskLruCache$Entry;
  146. iget-object v2, v2, Lokhttp3/internal/cache/DiskLruCache$Entry;->dirtyFiles:[Ljava/io/File;
  147. aget-object v2, v2, v0
  148. invoke-interface {v1, v2}, Lokhttp3/internal/io/FileSystem;->delete(Ljava/io/File;)V
  149. :try_end_0
  150. .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
  151. :catch_0
  152. add-int/lit8 v0, v0, 0x1
  153. goto :goto_0
  154. :cond_0
  155. iget-object v0, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->entry:Lokhttp3/internal/cache/DiskLruCache$Entry;
  156. const/4 v1, 0x0
  157. iput-object v1, v0, Lokhttp3/internal/cache/DiskLruCache$Entry;->currentEditor:Lokhttp3/internal/cache/DiskLruCache$Editor;
  158. :cond_1
  159. return-void
  160. .end method
  161. .method public newSink(I)Lokio/Sink;
  162. .locals 3
  163. iget-object v0, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->this$0:Lokhttp3/internal/cache/DiskLruCache;
  164. monitor-enter v0
  165. :try_start_0
  166. iget-boolean v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->done:Z
  167. if-nez v1, :cond_2
  168. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->entry:Lokhttp3/internal/cache/DiskLruCache$Entry;
  169. iget-object v1, v1, Lokhttp3/internal/cache/DiskLruCache$Entry;->currentEditor:Lokhttp3/internal/cache/DiskLruCache$Editor;
  170. if-eq v1, p0, :cond_0
  171. invoke-static {}, Lokio/Okio;->blackhole()Lokio/Sink;
  172. move-result-object p1
  173. monitor-exit v0
  174. return-object p1
  175. :cond_0
  176. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->entry:Lokhttp3/internal/cache/DiskLruCache$Entry;
  177. iget-boolean v1, v1, Lokhttp3/internal/cache/DiskLruCache$Entry;->readable:Z
  178. if-nez v1, :cond_1
  179. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->written:[Z
  180. const/4 v2, 0x1
  181. aput-boolean v2, v1, p1
  182. :cond_1
  183. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->entry:Lokhttp3/internal/cache/DiskLruCache$Entry;
  184. iget-object v1, v1, Lokhttp3/internal/cache/DiskLruCache$Entry;->dirtyFiles:[Ljava/io/File;
  185. aget-object p1, v1, p1
  186. :try_end_0
  187. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  188. :try_start_1
  189. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->this$0:Lokhttp3/internal/cache/DiskLruCache;
  190. iget-object v1, v1, Lokhttp3/internal/cache/DiskLruCache;->fileSystem:Lokhttp3/internal/io/FileSystem;
  191. invoke-interface {v1, p1}, Lokhttp3/internal/io/FileSystem;->sink(Ljava/io/File;)Lokio/Sink;
  192. move-result-object p1
  193. :try_end_1
  194. .catch Ljava/io/FileNotFoundException; {:try_start_1 .. :try_end_1} :catch_0
  195. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  196. :try_start_2
  197. new-instance v1, Lokhttp3/internal/cache/DiskLruCache$Editor$1;
  198. invoke-direct {v1, p0, p1}, Lokhttp3/internal/cache/DiskLruCache$Editor$1;-><init>(Lokhttp3/internal/cache/DiskLruCache$Editor;Lokio/Sink;)V
  199. monitor-exit v0
  200. return-object v1
  201. :catch_0
  202. invoke-static {}, Lokio/Okio;->blackhole()Lokio/Sink;
  203. move-result-object p1
  204. monitor-exit v0
  205. return-object p1
  206. :cond_2
  207. new-instance p1, Ljava/lang/IllegalStateException;
  208. invoke-direct {p1}, Ljava/lang/IllegalStateException;-><init>()V
  209. throw p1
  210. :catchall_0
  211. move-exception p1
  212. monitor-exit v0
  213. :try_end_2
  214. .catchall {:try_start_2 .. :try_end_2} :catchall_0
  215. throw p1
  216. .end method
  217. .method public newSource(I)Lokio/Source;
  218. .locals 4
  219. iget-object v0, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->this$0:Lokhttp3/internal/cache/DiskLruCache;
  220. monitor-enter v0
  221. :try_start_0
  222. iget-boolean v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->done:Z
  223. if-nez v1, :cond_2
  224. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->entry:Lokhttp3/internal/cache/DiskLruCache$Entry;
  225. iget-boolean v1, v1, Lokhttp3/internal/cache/DiskLruCache$Entry;->readable:Z
  226. const/4 v2, 0x0
  227. if-eqz v1, :cond_1
  228. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->entry:Lokhttp3/internal/cache/DiskLruCache$Entry;
  229. iget-object v1, v1, Lokhttp3/internal/cache/DiskLruCache$Entry;->currentEditor:Lokhttp3/internal/cache/DiskLruCache$Editor;
  230. :try_end_0
  231. .catchall {:try_start_0 .. :try_end_0} :catchall_0
  232. if-eq v1, p0, :cond_0
  233. goto :goto_0
  234. :cond_0
  235. :try_start_1
  236. iget-object v1, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->this$0:Lokhttp3/internal/cache/DiskLruCache;
  237. iget-object v1, v1, Lokhttp3/internal/cache/DiskLruCache;->fileSystem:Lokhttp3/internal/io/FileSystem;
  238. iget-object v3, p0, Lokhttp3/internal/cache/DiskLruCache$Editor;->entry:Lokhttp3/internal/cache/DiskLruCache$Entry;
  239. iget-object v3, v3, Lokhttp3/internal/cache/DiskLruCache$Entry;->cleanFiles:[Ljava/io/File;
  240. aget-object p1, v3, p1
  241. invoke-interface {v1, p1}, Lokhttp3/internal/io/FileSystem;->source(Ljava/io/File;)Lokio/Source;
  242. move-result-object p1
  243. :try_end_1
  244. .catch Ljava/io/FileNotFoundException; {:try_start_1 .. :try_end_1} :catch_0
  245. .catchall {:try_start_1 .. :try_end_1} :catchall_0
  246. :try_start_2
  247. monitor-exit v0
  248. return-object p1
  249. :catch_0
  250. monitor-exit v0
  251. return-object v2
  252. :cond_1
  253. :goto_0
  254. monitor-exit v0
  255. return-object v2
  256. :cond_2
  257. new-instance p1, Ljava/lang/IllegalStateException;
  258. invoke-direct {p1}, Ljava/lang/IllegalStateException;-><init>()V
  259. throw p1
  260. :catchall_0
  261. move-exception p1
  262. monitor-exit v0
  263. :try_end_2
  264. .catchall {:try_start_2 .. :try_end_2} :catchall_0
  265. throw p1
  266. .end method