Ping.smali 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. .class final Lokhttp3/internal/http2/Ping;
  2. .super Ljava/lang/Object;
  3. .source ""
  4. # instance fields
  5. .field private final latch:Ljava/util/concurrent/CountDownLatch;
  6. .field private received:J
  7. .field private sent:J
  8. # direct methods
  9. .method constructor <init>()V
  10. .locals 2
  11. invoke-direct {p0}, Ljava/lang/Object;-><init>()V
  12. new-instance v0, Ljava/util/concurrent/CountDownLatch;
  13. const/4 v1, 0x1
  14. invoke-direct {v0, v1}, Ljava/util/concurrent/CountDownLatch;-><init>(I)V
  15. iput-object v0, p0, Lokhttp3/internal/http2/Ping;->latch:Ljava/util/concurrent/CountDownLatch;
  16. const-wide/16 v0, -0x1
  17. iput-wide v0, p0, Lokhttp3/internal/http2/Ping;->sent:J
  18. iput-wide v0, p0, Lokhttp3/internal/http2/Ping;->received:J
  19. return-void
  20. .end method
  21. # virtual methods
  22. .method cancel()V
  23. .locals 5
  24. iget-wide v0, p0, Lokhttp3/internal/http2/Ping;->received:J
  25. const-wide/16 v2, -0x1
  26. cmp-long v4, v0, v2
  27. if-nez v4, :cond_0
  28. iget-wide v0, p0, Lokhttp3/internal/http2/Ping;->sent:J
  29. cmp-long v4, v0, v2
  30. if-eqz v4, :cond_0
  31. const-wide/16 v2, 0x1
  32. sub-long/2addr v0, v2
  33. iput-wide v0, p0, Lokhttp3/internal/http2/Ping;->received:J
  34. iget-object v0, p0, Lokhttp3/internal/http2/Ping;->latch:Ljava/util/concurrent/CountDownLatch;
  35. invoke-virtual {v0}, Ljava/util/concurrent/CountDownLatch;->countDown()V
  36. return-void
  37. :cond_0
  38. new-instance v0, Ljava/lang/IllegalStateException;
  39. invoke-direct {v0}, Ljava/lang/IllegalStateException;-><init>()V
  40. throw v0
  41. .end method
  42. .method receive()V
  43. .locals 5
  44. iget-wide v0, p0, Lokhttp3/internal/http2/Ping;->received:J
  45. const-wide/16 v2, -0x1
  46. cmp-long v4, v0, v2
  47. if-nez v4, :cond_0
  48. iget-wide v0, p0, Lokhttp3/internal/http2/Ping;->sent:J
  49. cmp-long v4, v0, v2
  50. if-eqz v4, :cond_0
  51. invoke-static {}, Ljava/lang/System;->nanoTime()J
  52. move-result-wide v0
  53. iput-wide v0, p0, Lokhttp3/internal/http2/Ping;->received:J
  54. iget-object v0, p0, Lokhttp3/internal/http2/Ping;->latch:Ljava/util/concurrent/CountDownLatch;
  55. invoke-virtual {v0}, Ljava/util/concurrent/CountDownLatch;->countDown()V
  56. return-void
  57. :cond_0
  58. new-instance v0, Ljava/lang/IllegalStateException;
  59. invoke-direct {v0}, Ljava/lang/IllegalStateException;-><init>()V
  60. throw v0
  61. .end method
  62. .method public roundTripTime()J
  63. .locals 4
  64. .annotation system Ldalvik/annotation/Throws;
  65. value = {
  66. Ljava/lang/InterruptedException;
  67. }
  68. .end annotation
  69. iget-object v0, p0, Lokhttp3/internal/http2/Ping;->latch:Ljava/util/concurrent/CountDownLatch;
  70. invoke-virtual {v0}, Ljava/util/concurrent/CountDownLatch;->await()V
  71. iget-wide v0, p0, Lokhttp3/internal/http2/Ping;->received:J
  72. iget-wide v2, p0, Lokhttp3/internal/http2/Ping;->sent:J
  73. sub-long/2addr v0, v2
  74. return-wide v0
  75. .end method
  76. .method public roundTripTime(JLjava/util/concurrent/TimeUnit;)J
  77. .locals 2
  78. .annotation system Ldalvik/annotation/Throws;
  79. value = {
  80. Ljava/lang/InterruptedException;
  81. }
  82. .end annotation
  83. iget-object v0, p0, Lokhttp3/internal/http2/Ping;->latch:Ljava/util/concurrent/CountDownLatch;
  84. invoke-virtual {v0, p1, p2, p3}, Ljava/util/concurrent/CountDownLatch;->await(JLjava/util/concurrent/TimeUnit;)Z
  85. move-result p1
  86. if-eqz p1, :cond_0
  87. iget-wide p1, p0, Lokhttp3/internal/http2/Ping;->received:J
  88. iget-wide v0, p0, Lokhttp3/internal/http2/Ping;->sent:J
  89. sub-long/2addr p1, v0
  90. return-wide p1
  91. :cond_0
  92. const-wide/16 p1, -0x2
  93. return-wide p1
  94. .end method
  95. .method send()V
  96. .locals 5
  97. iget-wide v0, p0, Lokhttp3/internal/http2/Ping;->sent:J
  98. const-wide/16 v2, -0x1
  99. cmp-long v4, v0, v2
  100. if-nez v4, :cond_0
  101. invoke-static {}, Ljava/lang/System;->nanoTime()J
  102. move-result-wide v0
  103. iput-wide v0, p0, Lokhttp3/internal/http2/Ping;->sent:J
  104. return-void
  105. :cond_0
  106. new-instance v0, Ljava/lang/IllegalStateException;
  107. invoke-direct {v0}, Ljava/lang/IllegalStateException;-><init>()V
  108. throw v0
  109. .end method