|
| 1 | +package com.bugsnag.android.okhttp.util |
| 2 | + |
| 3 | +import okhttp3.Call |
| 4 | +import okhttp3.Connection |
| 5 | +import okhttp3.EventListener |
| 6 | +import okhttp3.Handshake |
| 7 | +import okhttp3.HttpUrl |
| 8 | +import okhttp3.Protocol |
| 9 | +import okhttp3.Request |
| 10 | +import okhttp3.Response |
| 11 | +import java.io.IOException |
| 12 | +import java.net.InetAddress |
| 13 | +import java.net.InetSocketAddress |
| 14 | +import java.net.Proxy |
| 15 | + |
| 16 | +open class DelegateEventListener( |
| 17 | + protected val delegateEventListener: EventListener? |
| 18 | +) : EventListener() { |
| 19 | + override fun callStart(call: Call) { |
| 20 | + delegateEventListener?.callStart(call) |
| 21 | + } |
| 22 | + |
| 23 | + override fun callEnd(call: Call) { |
| 24 | + delegateEventListener?.callEnd(call) |
| 25 | + } |
| 26 | + |
| 27 | + override fun callFailed(call: Call, ioe: IOException) { |
| 28 | + delegateEventListener?.callFailed(call, ioe) |
| 29 | + } |
| 30 | + |
| 31 | + override fun canceled(call: Call) { |
| 32 | + delegateEventListener?.canceled(call) |
| 33 | + } |
| 34 | + |
| 35 | + override fun cacheConditionalHit(call: Call, cachedResponse: Response) { |
| 36 | + delegateEventListener?.cacheConditionalHit(call, cachedResponse) |
| 37 | + } |
| 38 | + |
| 39 | + override fun cacheHit(call: Call, response: Response) { |
| 40 | + delegateEventListener?.cacheHit(call, response) |
| 41 | + } |
| 42 | + |
| 43 | + override fun cacheMiss(call: Call) { |
| 44 | + delegateEventListener?.cacheMiss(call) |
| 45 | + } |
| 46 | + |
| 47 | + override fun connectEnd( |
| 48 | + call: Call, |
| 49 | + inetSocketAddress: InetSocketAddress, |
| 50 | + proxy: Proxy, |
| 51 | + protocol: Protocol? |
| 52 | + ) { |
| 53 | + delegateEventListener?.connectEnd(call, inetSocketAddress, proxy, protocol) |
| 54 | + } |
| 55 | + |
| 56 | + override fun connectFailed( |
| 57 | + call: Call, |
| 58 | + inetSocketAddress: InetSocketAddress, |
| 59 | + proxy: Proxy, |
| 60 | + protocol: Protocol?, |
| 61 | + ioe: IOException |
| 62 | + ) { |
| 63 | + delegateEventListener?.connectFailed(call, inetSocketAddress, proxy, protocol, ioe) |
| 64 | + } |
| 65 | + |
| 66 | + override fun connectStart( |
| 67 | + call: Call, |
| 68 | + inetSocketAddress: InetSocketAddress, |
| 69 | + proxy: Proxy |
| 70 | + ) { |
| 71 | + delegateEventListener?.connectStart(call, inetSocketAddress, proxy) |
| 72 | + } |
| 73 | + |
| 74 | + override fun connectionAcquired(call: Call, connection: Connection) { |
| 75 | + delegateEventListener?.connectionAcquired(call, connection) |
| 76 | + } |
| 77 | + |
| 78 | + override fun connectionReleased(call: Call, connection: Connection) { |
| 79 | + delegateEventListener?.connectionReleased(call, connection) |
| 80 | + } |
| 81 | + |
| 82 | + override fun dnsEnd( |
| 83 | + call: Call, |
| 84 | + domainName: String, |
| 85 | + inetAddressList: List<@JvmSuppressWildcards InetAddress> |
| 86 | + ) { |
| 87 | + delegateEventListener?.dnsEnd(call, domainName, inetAddressList) |
| 88 | + } |
| 89 | + |
| 90 | + override fun dnsStart(call: Call, domainName: String) { |
| 91 | + delegateEventListener?.dnsStart(call, domainName) |
| 92 | + } |
| 93 | + |
| 94 | + override fun proxySelectEnd( |
| 95 | + call: Call, |
| 96 | + url: HttpUrl, |
| 97 | + proxies: List<@JvmSuppressWildcards Proxy> |
| 98 | + ) { |
| 99 | + delegateEventListener?.proxySelectEnd(call, url, proxies) |
| 100 | + } |
| 101 | + |
| 102 | + override fun proxySelectStart(call: Call, url: HttpUrl) { |
| 103 | + delegateEventListener?.proxySelectStart(call, url) |
| 104 | + } |
| 105 | + |
| 106 | + override fun requestBodyStart(call: Call) { |
| 107 | + delegateEventListener?.requestBodyStart(call) |
| 108 | + } |
| 109 | + |
| 110 | + override fun requestFailed(call: Call, ioe: IOException) { |
| 111 | + delegateEventListener?.requestFailed(call, ioe) |
| 112 | + } |
| 113 | + |
| 114 | + override fun requestHeadersEnd(call: Call, request: Request) { |
| 115 | + delegateEventListener?.requestHeadersEnd(call, request) |
| 116 | + } |
| 117 | + |
| 118 | + override fun requestHeadersStart(call: Call) { |
| 119 | + delegateEventListener?.requestHeadersStart(call) |
| 120 | + } |
| 121 | + |
| 122 | + override fun responseBodyStart(call: Call) { |
| 123 | + delegateEventListener?.responseBodyStart(call) |
| 124 | + } |
| 125 | + |
| 126 | + override fun responseFailed(call: Call, ioe: IOException) { |
| 127 | + delegateEventListener?.responseFailed(call, ioe) |
| 128 | + } |
| 129 | + |
| 130 | + override fun responseHeadersStart(call: Call) { |
| 131 | + delegateEventListener?.responseHeadersStart(call) |
| 132 | + } |
| 133 | + |
| 134 | + override fun satisfactionFailure(call: Call, response: Response) { |
| 135 | + delegateEventListener?.satisfactionFailure(call, response) |
| 136 | + } |
| 137 | + |
| 138 | + override fun secureConnectEnd(call: Call, handshake: Handshake?) { |
| 139 | + delegateEventListener?.secureConnectEnd(call, handshake) |
| 140 | + } |
| 141 | + |
| 142 | + override fun secureConnectStart(call: Call) { |
| 143 | + delegateEventListener?.secureConnectStart(call) |
| 144 | + } |
| 145 | +} |
0 commit comments