LibreTube/app/src/main/java/com/github/libretube/api/CronetHelper.kt

29 lines
826 B
Kotlin
Raw Normal View History

2022-08-14 13:25:28 +05:30
package com.github.libretube.api
import android.content.Context
2022-07-21 23:28:38 +05:30
import com.google.net.cronet.okhttptransport.CronetCallFactory
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
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)
.enableBrotli(true)
2022-09-10 23:05:05 +05:30
.enableHttpCache(CronetEngine.Builder.HTTP_CACHE_IN_MEMORY, 1024L * 1024L) // 1MiB
.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()
}
fun getCronetEngine(): CronetEngine {
return engine
}
}
}