Dev Console Ok Http Event Listener Factory
Bridges OkHttp's EventListener callbacks -- the only place DNS/connect/TLS/wait/download phase boundaries are observable -- into the NetworkTimingPhases that DevConsoleOkHttpInterceptor attaches to a recorded transaction.
Install alongside the interceptor and hand the same instance to both, since DevConsoleOkHttpInterceptor reads phase state back out of this factory:
val listenerFactory = DevConsoleOkHttpEventListenerFactory()
val client = OkHttpClient.Builder()
.eventListenerFactory(listenerFactory)
.addInterceptor(DevConsoleOkHttpInterceptor(DevConsole.networkRecorder(), listenerFactory))
.build()OkHttp only allows one eventListenerFactory per client. Pass an existing one as delegate to chain it -- every callback still reaches it, in addition to being tracked here.
State is keyed by the OkHttp Call instance, which is identity-equal per call and never reused, so concurrent calls never cross-talk. Entries are removed once DevConsoleOkHttpInterceptor has read them and, as a safety net for a call this factory tracks but the interceptor never sees (for example this factory installed without the interceptor, or a chain that throws before reaching it), on callEnd/callFailed as well -- so nothing is retained past the call's lifetime.