2022-08-14 13:25:28 +05:30
|
|
|
package com.github.libretube.api
|
2022-05-27 07:04:44 +05:30
|
|
|
|
|
|
|
import android.content.Context
|
2022-07-21 23:28:38 +05:30
|
|
|
import com.google.net.cronet.okhttptransport.CronetCallFactory
|
2022-05-27 07:04:44 +05:30
|
|
|
import org.chromium.net.CronetEngine
|
|
|
|
|
|
|
|
class CronetHelper {
|
|
|
|
companion object {
|
|
|
|
private lateinit var engine: CronetEngine
|
2022-07-21 23:28:38 +05:30
|
|
|
lateinit var callFactory: CronetCallFactory
|
2022-05-27 07:04:44 +05:30
|
|
|
|
|
|
|
fun initCronet(context: Context) {
|
2022-08-14 13:25:28 +05:30
|
|
|
engine = CronetEngine.Builder(context)
|
2022-09-10 23:05:05 +05:30
|
|
|
.enableHttp2(true)
|
|
|
|
.enableQuic(true)
|
2022-05-27 07:04:44 +05:30
|
|
|
.enableBrotli(true)
|
2022-09-10 23:05:05 +05:30
|
|
|
.enableHttpCache(CronetEngine.Builder.HTTP_CACHE_IN_MEMORY, 1024L * 1024L) // 1MiB
|
2022-05-27 07:04:44 +05:30
|
|
|
.build()
|
2022-09-10 23:05:05 +05:30
|
|
|
|
2022-08-14 13:25:28 +05:30
|
|
|
callFactory = CronetCallFactory.newBuilder(engine)
|
2022-07-21 23:28:38 +05:30
|
|
|
.build()
|
2022-05-27 07:04:44 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
fun getCronetEngine(): CronetEngine {
|
|
|
|
return engine
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|