CacheStrategy$Factory.smali 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803
  1. .class public Lokhttp3/internal/cache/CacheStrategy$Factory;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # annotations
  5. .annotation system Ldalvik/annotation/EnclosingClass;
  6. value = Lokhttp3/internal/cache/CacheStrategy;
  7. .end annotation
  8. .annotation system Ldalvik/annotation/InnerClass;
  9. accessFlags = 0x9
  10. name = "Factory"
  11. .end annotation
  12. # instance fields
  13. .field private ageSeconds:I
  14. .field final cacheResponse:Lokhttp3/Response;
  15. .field private etag:Ljava/lang/String;
  16. .field private expires:Ljava/util/Date;
  17. .field private lastModified:Ljava/util/Date;
  18. .field private lastModifiedString:Ljava/lang/String;
  19. .field final nowMillis:J
  20. .field private receivedResponseMillis:J
  21. .field final request:Lokhttp3/Request;
  22. .field private sentRequestMillis:J
  23. .field private servedDate:Ljava/util/Date;
  24. .field private servedDateString:Ljava/lang/String;
  25. # direct methods
  26. .method public constructor <init>(JLokhttp3/Request;Lokhttp3/Response;)V
  27. .locals 3
  28. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  29. const/4 v0, -0x1
  30. iput v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->ageSeconds:I
  31. iput-wide p1, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->nowMillis:J
  32. iput-object p3, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->request:Lokhttp3/Request;
  33. iput-object p4, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->cacheResponse:Lokhttp3/Response;
  34. if-eqz p4, :cond_5
  35. invoke-virtual {p4}, Lokhttp3/Response;->sentRequestAtMillis()J
  36. move-result-wide p1
  37. iput-wide p1, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->sentRequestMillis:J
  38. invoke-virtual {p4}, Lokhttp3/Response;->receivedResponseAtMillis()J
  39. move-result-wide p1
  40. iput-wide p1, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->receivedResponseMillis:J
  41. invoke-virtual {p4}, Lokhttp3/Response;->headers()Lokhttp3/Headers;
  42. move-result-object p1
  43. const/4 p2, 0x0
  44. invoke-virtual {p1}, Lokhttp3/Headers;->size()I
  45. move-result p3
  46. :goto_0
  47. if-ge p2, p3, :cond_5
  48. invoke-virtual {p1, p2}, Lokhttp3/Headers;->name(I)Ljava/lang/String;
  49. move-result-object p4
  50. invoke-virtual {p1, p2}, Lokhttp3/Headers;->value(I)Ljava/lang/String;
  51. move-result-object v1
  52. const-string v2, "Date"
  53. invoke-virtual {v2, p4}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
  54. move-result v2
  55. if-eqz v2, :cond_0
  56. invoke-static {v1}, Lokhttp3/internal/http/HttpDate;->parse(Ljava/lang/String;)Ljava/util/Date;
  57. move-result-object p4
  58. iput-object p4, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->servedDate:Ljava/util/Date;
  59. iput-object v1, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->servedDateString:Ljava/lang/String;
  60. goto :goto_1
  61. :cond_0
  62. const-string v2, "Expires"
  63. invoke-virtual {v2, p4}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
  64. move-result v2
  65. if-eqz v2, :cond_1
  66. invoke-static {v1}, Lokhttp3/internal/http/HttpDate;->parse(Ljava/lang/String;)Ljava/util/Date;
  67. move-result-object p4
  68. iput-object p4, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->expires:Ljava/util/Date;
  69. goto :goto_1
  70. :cond_1
  71. const-string v2, "Last-Modified"
  72. invoke-virtual {v2, p4}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
  73. move-result v2
  74. if-eqz v2, :cond_2
  75. invoke-static {v1}, Lokhttp3/internal/http/HttpDate;->parse(Ljava/lang/String;)Ljava/util/Date;
  76. move-result-object p4
  77. iput-object p4, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->lastModified:Ljava/util/Date;
  78. iput-object v1, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->lastModifiedString:Ljava/lang/String;
  79. goto :goto_1
  80. :cond_2
  81. const-string v2, "ETag"
  82. invoke-virtual {v2, p4}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
  83. move-result v2
  84. if-eqz v2, :cond_3
  85. iput-object v1, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->etag:Ljava/lang/String;
  86. goto :goto_1
  87. :cond_3
  88. const-string v2, "Age"
  89. invoke-virtual {v2, p4}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z
  90. move-result p4
  91. if-eqz p4, :cond_4
  92. invoke-static {v1, v0}, Lokhttp3/internal/http/HttpHeaders;->parseSeconds(Ljava/lang/String;I)I
  93. move-result p4
  94. iput p4, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->ageSeconds:I
  95. :cond_4
  96. :goto_1
  97. add-int/lit8 p2, p2, 0x1
  98. goto :goto_0
  99. :cond_5
  100. return-void
  101. .end method
  102. .method private cacheResponseAge()J
  103. .locals 9
  104. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->servedDate:Ljava/util/Date;
  105. const-wide/16 v1, 0x0
  106. if-eqz v0, :cond_0
  107. iget-wide v3, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->receivedResponseMillis:J
  108. invoke-virtual {v0}, Ljava/util/Date;->getTime()J
  109. move-result-wide v5
  110. sub-long/2addr v3, v5
  111. invoke-static {v1, v2, v3, v4}, Ljava/lang/Math;->max(JJ)J
  112. move-result-wide v1
  113. :cond_0
  114. iget v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->ageSeconds:I
  115. const/4 v3, -0x1
  116. if-eq v0, v3, :cond_1
  117. sget-object v3, Ljava/util/concurrent/TimeUnit;->SECONDS:Ljava/util/concurrent/TimeUnit;
  118. int-to-long v4, v0
  119. invoke-virtual {v3, v4, v5}, Ljava/util/concurrent/TimeUnit;->toMillis(J)J
  120. move-result-wide v3
  121. invoke-static {v1, v2, v3, v4}, Ljava/lang/Math;->max(JJ)J
  122. move-result-wide v1
  123. :cond_1
  124. iget-wide v3, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->receivedResponseMillis:J
  125. iget-wide v5, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->sentRequestMillis:J
  126. sub-long v5, v3, v5
  127. iget-wide v7, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->nowMillis:J
  128. sub-long/2addr v7, v3
  129. add-long/2addr v1, v5
  130. add-long/2addr v1, v7
  131. return-wide v1
  132. .end method
  133. .method private computeFreshnessLifetime()J
  134. .locals 7
  135. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->cacheResponse:Lokhttp3/Response;
  136. invoke-virtual {v0}, Lokhttp3/Response;->cacheControl()Lokhttp3/CacheControl;
  137. move-result-object v0
  138. invoke-virtual {v0}, Lokhttp3/CacheControl;->maxAgeSeconds()I
  139. move-result v1
  140. const/4 v2, -0x1
  141. if-eq v1, v2, :cond_0
  142. sget-object v1, Ljava/util/concurrent/TimeUnit;->SECONDS:Ljava/util/concurrent/TimeUnit;
  143. invoke-virtual {v0}, Lokhttp3/CacheControl;->maxAgeSeconds()I
  144. move-result v0
  145. int-to-long v2, v0
  146. invoke-virtual {v1, v2, v3}, Ljava/util/concurrent/TimeUnit;->toMillis(J)J
  147. move-result-wide v0
  148. return-wide v0
  149. :cond_0
  150. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->expires:Ljava/util/Date;
  151. const-wide/16 v1, 0x0
  152. if-eqz v0, :cond_3
  153. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->servedDate:Ljava/util/Date;
  154. if-eqz v0, :cond_1
  155. invoke-virtual {v0}, Ljava/util/Date;->getTime()J
  156. move-result-wide v3
  157. goto :goto_0
  158. :cond_1
  159. iget-wide v3, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->receivedResponseMillis:J
  160. :goto_0
  161. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->expires:Ljava/util/Date;
  162. invoke-virtual {v0}, Ljava/util/Date;->getTime()J
  163. move-result-wide v5
  164. sub-long v3, v5, v3
  165. cmp-long v0, v3, v1
  166. if-lez v0, :cond_2
  167. move-wide v1, v3
  168. :cond_2
  169. return-wide v1
  170. :cond_3
  171. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->lastModified:Ljava/util/Date;
  172. if-eqz v0, :cond_5
  173. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->cacheResponse:Lokhttp3/Response;
  174. invoke-virtual {v0}, Lokhttp3/Response;->request()Lokhttp3/Request;
  175. move-result-object v0
  176. invoke-virtual {v0}, Lokhttp3/Request;->url()Lokhttp3/HttpUrl;
  177. move-result-object v0
  178. invoke-virtual {v0}, Lokhttp3/HttpUrl;->query()Ljava/lang/String;
  179. move-result-object v0
  180. if-nez v0, :cond_5
  181. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->servedDate:Ljava/util/Date;
  182. if-eqz v0, :cond_4
  183. invoke-virtual {v0}, Ljava/util/Date;->getTime()J
  184. move-result-wide v3
  185. goto :goto_1
  186. :cond_4
  187. iget-wide v3, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->sentRequestMillis:J
  188. :goto_1
  189. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->lastModified:Ljava/util/Date;
  190. invoke-virtual {v0}, Ljava/util/Date;->getTime()J
  191. move-result-wide v5
  192. sub-long/2addr v3, v5
  193. cmp-long v0, v3, v1
  194. if-lez v0, :cond_5
  195. const-wide/16 v0, 0xa
  196. div-long v1, v3, v0
  197. :cond_5
  198. return-wide v1
  199. .end method
  200. .method private getCandidate()Lokhttp3/internal/cache/CacheStrategy;
  201. .locals 13
  202. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->cacheResponse:Lokhttp3/Response;
  203. const/4 v1, 0x0
  204. if-nez v0, :cond_0
  205. new-instance v0, Lokhttp3/internal/cache/CacheStrategy;
  206. iget-object v2, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->request:Lokhttp3/Request;
  207. invoke-direct {v0, v2, v1}, Lokhttp3/internal/cache/CacheStrategy;-><init>(Lokhttp3/Request;Lokhttp3/Response;)V
  208. return-object v0
  209. :cond_0
  210. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->request:Lokhttp3/Request;
  211. invoke-virtual {v0}, Lokhttp3/Request;->isHttps()Z
  212. move-result v0
  213. if-eqz v0, :cond_1
  214. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->cacheResponse:Lokhttp3/Response;
  215. invoke-virtual {v0}, Lokhttp3/Response;->handshake()Lokhttp3/Handshake;
  216. move-result-object v0
  217. if-nez v0, :cond_1
  218. new-instance v0, Lokhttp3/internal/cache/CacheStrategy;
  219. iget-object v2, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->request:Lokhttp3/Request;
  220. invoke-direct {v0, v2, v1}, Lokhttp3/internal/cache/CacheStrategy;-><init>(Lokhttp3/Request;Lokhttp3/Response;)V
  221. return-object v0
  222. :cond_1
  223. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->cacheResponse:Lokhttp3/Response;
  224. iget-object v2, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->request:Lokhttp3/Request;
  225. invoke-static {v0, v2}, Lokhttp3/internal/cache/CacheStrategy;->isCacheable(Lokhttp3/Response;Lokhttp3/Request;)Z
  226. move-result v0
  227. if-nez v0, :cond_2
  228. new-instance v0, Lokhttp3/internal/cache/CacheStrategy;
  229. iget-object v2, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->request:Lokhttp3/Request;
  230. invoke-direct {v0, v2, v1}, Lokhttp3/internal/cache/CacheStrategy;-><init>(Lokhttp3/Request;Lokhttp3/Response;)V
  231. return-object v0
  232. :cond_2
  233. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->request:Lokhttp3/Request;
  234. invoke-virtual {v0}, Lokhttp3/Request;->cacheControl()Lokhttp3/CacheControl;
  235. move-result-object v0
  236. invoke-virtual {v0}, Lokhttp3/CacheControl;->noCache()Z
  237. move-result v2
  238. if-nez v2, :cond_e
  239. iget-object v2, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->request:Lokhttp3/Request;
  240. invoke-static {v2}, Lokhttp3/internal/cache/CacheStrategy$Factory;->hasConditions(Lokhttp3/Request;)Z
  241. move-result v2
  242. if-eqz v2, :cond_3
  243. goto/16 :goto_2
  244. :cond_3
  245. iget-object v2, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->cacheResponse:Lokhttp3/Response;
  246. invoke-virtual {v2}, Lokhttp3/Response;->cacheControl()Lokhttp3/CacheControl;
  247. move-result-object v2
  248. invoke-virtual {v2}, Lokhttp3/CacheControl;->immutable()Z
  249. move-result v3
  250. if-eqz v3, :cond_4
  251. new-instance v0, Lokhttp3/internal/cache/CacheStrategy;
  252. iget-object v2, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->cacheResponse:Lokhttp3/Response;
  253. invoke-direct {v0, v1, v2}, Lokhttp3/internal/cache/CacheStrategy;-><init>(Lokhttp3/Request;Lokhttp3/Response;)V
  254. return-object v0
  255. :cond_4
  256. invoke-direct {p0}, Lokhttp3/internal/cache/CacheStrategy$Factory;->cacheResponseAge()J
  257. move-result-wide v3
  258. invoke-direct {p0}, Lokhttp3/internal/cache/CacheStrategy$Factory;->computeFreshnessLifetime()J
  259. move-result-wide v5
  260. invoke-virtual {v0}, Lokhttp3/CacheControl;->maxAgeSeconds()I
  261. move-result v7
  262. const/4 v8, -0x1
  263. if-eq v7, v8, :cond_5
  264. sget-object v7, Ljava/util/concurrent/TimeUnit;->SECONDS:Ljava/util/concurrent/TimeUnit;
  265. invoke-virtual {v0}, Lokhttp3/CacheControl;->maxAgeSeconds()I
  266. move-result v9
  267. int-to-long v9, v9
  268. invoke-virtual {v7, v9, v10}, Ljava/util/concurrent/TimeUnit;->toMillis(J)J
  269. move-result-wide v9
  270. invoke-static {v5, v6, v9, v10}, Ljava/lang/Math;->min(JJ)J
  271. move-result-wide v5
  272. :cond_5
  273. invoke-virtual {v0}, Lokhttp3/CacheControl;->minFreshSeconds()I
  274. move-result v7
  275. const-wide/16 v9, 0x0
  276. if-eq v7, v8, :cond_6
  277. sget-object v7, Ljava/util/concurrent/TimeUnit;->SECONDS:Ljava/util/concurrent/TimeUnit;
  278. invoke-virtual {v0}, Lokhttp3/CacheControl;->minFreshSeconds()I
  279. move-result v11
  280. int-to-long v11, v11
  281. invoke-virtual {v7, v11, v12}, Ljava/util/concurrent/TimeUnit;->toMillis(J)J
  282. move-result-wide v11
  283. goto :goto_0
  284. :cond_6
  285. move-wide v11, v9
  286. :goto_0
  287. invoke-virtual {v2}, Lokhttp3/CacheControl;->mustRevalidate()Z
  288. move-result v7
  289. if-nez v7, :cond_7
  290. invoke-virtual {v0}, Lokhttp3/CacheControl;->maxStaleSeconds()I
  291. move-result v7
  292. if-eq v7, v8, :cond_7
  293. sget-object v7, Ljava/util/concurrent/TimeUnit;->SECONDS:Ljava/util/concurrent/TimeUnit;
  294. invoke-virtual {v0}, Lokhttp3/CacheControl;->maxStaleSeconds()I
  295. move-result v0
  296. int-to-long v8, v0
  297. invoke-virtual {v7, v8, v9}, Ljava/util/concurrent/TimeUnit;->toMillis(J)J
  298. move-result-wide v9
  299. :cond_7
  300. invoke-virtual {v2}, Lokhttp3/CacheControl;->noCache()Z
  301. move-result v0
  302. if-nez v0, :cond_a
  303. add-long/2addr v11, v3
  304. add-long/2addr v9, v5
  305. cmp-long v0, v11, v9
  306. if-gez v0, :cond_a
  307. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->cacheResponse:Lokhttp3/Response;
  308. invoke-virtual {v0}, Lokhttp3/Response;->newBuilder()Lokhttp3/Response$Builder;
  309. move-result-object v0
  310. const-string v2, "Warning"
  311. cmp-long v7, v11, v5
  312. if-ltz v7, :cond_8
  313. const-string v5, "110 HttpURLConnection \"Response is stale\""
  314. invoke-virtual {v0, v2, v5}, Lokhttp3/Response$Builder;->addHeader(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Response$Builder;
  315. :cond_8
  316. const-wide/32 v5, 0x5265c00
  317. cmp-long v7, v3, v5
  318. if-lez v7, :cond_9
  319. invoke-direct {p0}, Lokhttp3/internal/cache/CacheStrategy$Factory;->isFreshnessLifetimeHeuristic()Z
  320. move-result v3
  321. if-eqz v3, :cond_9
  322. const-string v3, "113 HttpURLConnection \"Heuristic expiration\""
  323. invoke-virtual {v0, v2, v3}, Lokhttp3/Response$Builder;->addHeader(Ljava/lang/String;Ljava/lang/String;)Lokhttp3/Response$Builder;
  324. :cond_9
  325. new-instance v2, Lokhttp3/internal/cache/CacheStrategy;
  326. invoke-virtual {v0}, Lokhttp3/Response$Builder;->build()Lokhttp3/Response;
  327. move-result-object v0
  328. invoke-direct {v2, v1, v0}, Lokhttp3/internal/cache/CacheStrategy;-><init>(Lokhttp3/Request;Lokhttp3/Response;)V
  329. return-object v2
  330. :cond_a
  331. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->etag:Ljava/lang/String;
  332. const-string v2, "If-Modified-Since"
  333. if-eqz v0, :cond_b
  334. const-string v2, "If-None-Match"
  335. goto :goto_1
  336. :cond_b
  337. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->lastModified:Ljava/util/Date;
  338. if-eqz v0, :cond_c
  339. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->lastModifiedString:Ljava/lang/String;
  340. goto :goto_1
  341. :cond_c
  342. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->servedDate:Ljava/util/Date;
  343. if-eqz v0, :cond_d
  344. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->servedDateString:Ljava/lang/String;
  345. :goto_1
  346. iget-object v1, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->request:Lokhttp3/Request;
  347. invoke-virtual {v1}, Lokhttp3/Request;->headers()Lokhttp3/Headers;
  348. move-result-object v1
  349. invoke-virtual {v1}, Lokhttp3/Headers;->newBuilder()Lokhttp3/Headers$Builder;
  350. move-result-object v1
  351. sget-object v3, Lokhttp3/internal/Internal;->instance:Lokhttp3/internal/Internal;
  352. invoke-virtual {v3, v1, v2, v0}, Lokhttp3/internal/Internal;->addLenient(Lokhttp3/Headers$Builder;Ljava/lang/String;Ljava/lang/String;)V
  353. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->request:Lokhttp3/Request;
  354. invoke-virtual {v0}, Lokhttp3/Request;->newBuilder()Lokhttp3/Request$Builder;
  355. move-result-object v0
  356. invoke-virtual {v1}, Lokhttp3/Headers$Builder;->build()Lokhttp3/Headers;
  357. move-result-object v1
  358. invoke-virtual {v0, v1}, Lokhttp3/Request$Builder;->headers(Lokhttp3/Headers;)Lokhttp3/Request$Builder;
  359. move-result-object v0
  360. invoke-virtual {v0}, Lokhttp3/Request$Builder;->build()Lokhttp3/Request;
  361. move-result-object v0
  362. new-instance v1, Lokhttp3/internal/cache/CacheStrategy;
  363. iget-object v2, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->cacheResponse:Lokhttp3/Response;
  364. invoke-direct {v1, v0, v2}, Lokhttp3/internal/cache/CacheStrategy;-><init>(Lokhttp3/Request;Lokhttp3/Response;)V
  365. return-object v1
  366. :cond_d
  367. new-instance v0, Lokhttp3/internal/cache/CacheStrategy;
  368. iget-object v2, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->request:Lokhttp3/Request;
  369. invoke-direct {v0, v2, v1}, Lokhttp3/internal/cache/CacheStrategy;-><init>(Lokhttp3/Request;Lokhttp3/Response;)V
  370. return-object v0
  371. :cond_e
  372. :goto_2
  373. new-instance v0, Lokhttp3/internal/cache/CacheStrategy;
  374. iget-object v2, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->request:Lokhttp3/Request;
  375. invoke-direct {v0, v2, v1}, Lokhttp3/internal/cache/CacheStrategy;-><init>(Lokhttp3/Request;Lokhttp3/Response;)V
  376. return-object v0
  377. .end method
  378. .method private static hasConditions(Lokhttp3/Request;)Z
  379. .locals 1
  380. const-string v0, "If-Modified-Since"
  381. invoke-virtual {p0, v0}, Lokhttp3/Request;->header(Ljava/lang/String;)Ljava/lang/String;
  382. move-result-object v0
  383. if-nez v0, :cond_1
  384. const-string v0, "If-None-Match"
  385. invoke-virtual {p0, v0}, Lokhttp3/Request;->header(Ljava/lang/String;)Ljava/lang/String;
  386. move-result-object p0
  387. if-eqz p0, :cond_0
  388. goto :goto_0
  389. :cond_0
  390. const/4 p0, 0x0
  391. goto :goto_1
  392. :cond_1
  393. :goto_0
  394. const/4 p0, 0x1
  395. :goto_1
  396. return p0
  397. .end method
  398. .method private isFreshnessLifetimeHeuristic()Z
  399. .locals 2
  400. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->cacheResponse:Lokhttp3/Response;
  401. invoke-virtual {v0}, Lokhttp3/Response;->cacheControl()Lokhttp3/CacheControl;
  402. move-result-object v0
  403. invoke-virtual {v0}, Lokhttp3/CacheControl;->maxAgeSeconds()I
  404. move-result v0
  405. const/4 v1, -0x1
  406. if-ne v0, v1, :cond_0
  407. iget-object v0, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->expires:Ljava/util/Date;
  408. if-nez v0, :cond_0
  409. const/4 v0, 0x1
  410. goto :goto_0
  411. :cond_0
  412. const/4 v0, 0x0
  413. :goto_0
  414. return v0
  415. .end method
  416. # virtual methods
  417. .method public get()Lokhttp3/internal/cache/CacheStrategy;
  418. .locals 2
  419. invoke-direct {p0}, Lokhttp3/internal/cache/CacheStrategy$Factory;->getCandidate()Lokhttp3/internal/cache/CacheStrategy;
  420. move-result-object v0
  421. iget-object v1, v0, Lokhttp3/internal/cache/CacheStrategy;->networkRequest:Lokhttp3/Request;
  422. if-eqz v1, :cond_0
  423. iget-object v1, p0, Lokhttp3/internal/cache/CacheStrategy$Factory;->request:Lokhttp3/Request;
  424. invoke-virtual {v1}, Lokhttp3/Request;->cacheControl()Lokhttp3/CacheControl;
  425. move-result-object v1
  426. invoke-virtual {v1}, Lokhttp3/CacheControl;->onlyIfCached()Z
  427. move-result v1
  428. if-eqz v1, :cond_0
  429. new-instance v0, Lokhttp3/internal/cache/CacheStrategy;
  430. const/4 v1, 0x0
  431. invoke-direct {v0, v1, v1}, Lokhttp3/internal/cache/CacheStrategy;-><init>(Lokhttp3/Request;Lokhttp3/Response;)V
  432. :cond_0
  433. return-object v0
  434. .end method