Closes #1350: Use GeckoView fetch client for service-fretboard / kinto
parent
5de1678e65
commit
b91895a81c
|
@ -17,7 +17,6 @@ import kotlinx.coroutines.GlobalScope
|
||||||
import kotlinx.coroutines.async
|
import kotlinx.coroutines.async
|
||||||
import kotlinx.coroutines.runBlocking
|
import kotlinx.coroutines.runBlocking
|
||||||
import mozilla.components.concept.fetch.Client
|
import mozilla.components.concept.fetch.Client
|
||||||
import mozilla.components.lib.fetch.httpurlconnection.HttpURLConnectionClient
|
|
||||||
import mozilla.components.service.fretboard.Fretboard
|
import mozilla.components.service.fretboard.Fretboard
|
||||||
import mozilla.components.service.fretboard.source.kinto.KintoExperimentSource
|
import mozilla.components.service.fretboard.source.kinto.KintoExperimentSource
|
||||||
import mozilla.components.service.fretboard.storage.flatfile.FlatFileExperimentStorage
|
import mozilla.components.service.fretboard.storage.flatfile.FlatFileExperimentStorage
|
||||||
|
@ -47,25 +46,25 @@ open class FenixApplication : Application() {
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun setupApplication() {
|
open fun setupApplication() {
|
||||||
// loadExperiments does things that run in parallel with the rest of setup.
|
setupCrashReporting()
|
||||||
// Call the function as early as possible so there's maximum overlap.
|
|
||||||
experimentLoader = loadExperiments()
|
|
||||||
|
|
||||||
setDayNightTheme()
|
setDayNightTheme()
|
||||||
val megazordEnabled = setupMegazord()
|
val megazordEnabled = setupMegazord()
|
||||||
setupLogging(megazordEnabled)
|
setupLogging(megazordEnabled)
|
||||||
registerRxExceptionHandling()
|
registerRxExceptionHandling()
|
||||||
setupCrashReporting()
|
|
||||||
enableStrictMode()
|
enableStrictMode()
|
||||||
|
|
||||||
if (!isMainProcess()) {
|
if (!isMainProcess()) {
|
||||||
// If this is not the main process then do not continue with the initialization here. Everything that
|
// If this is not the main process then do not continue with the initialization here. Everything that
|
||||||
// follows only needs to be done in our app's main process and should not be done in other processes like
|
// follows only needs to be done in our app's main process and should not be done in other processes like
|
||||||
// a GeckoView child process or the crash handling process. Most importantly we never want to end up in a
|
// a GeckoView child process or the crash handling process. Most importantly we never want to end up in a
|
||||||
// situation where we create a GeckoRuntime from the Gecko child process (
|
// situation where we create a GeckoRuntime from the Gecko child process.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We want to call this function as early as possible, but only once and
|
||||||
|
// on the main process, as it uses Gecko to fetch experiments from the server.
|
||||||
|
experimentLoader = loadExperiments()
|
||||||
|
|
||||||
setupLeakCanary()
|
setupLeakCanary()
|
||||||
if (Settings.getInstance(this).isTelemetryEnabled) {
|
if (Settings.getInstance(this).isTelemetryEnabled) {
|
||||||
components.analytics.metrics.start()
|
components.analytics.metrics.start()
|
||||||
|
@ -132,17 +131,17 @@ open class FenixApplication : Application() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadExperiments(): Deferred<Boolean> {
|
private fun loadExperiments(): Deferred<Boolean> {
|
||||||
|
val experimentsFile = File(filesDir, EXPERIMENTS_JSON_FILENAME)
|
||||||
|
val experimentSource = KintoExperimentSource(
|
||||||
|
EXPERIMENTS_BASE_URL,
|
||||||
|
EXPERIMENTS_BUCKET_NAME,
|
||||||
|
EXPERIMENTS_COLLECTION_NAME,
|
||||||
|
components.core.client
|
||||||
|
)
|
||||||
|
// TODO add ValueProvider to keep clientID in sync with Glean when ready
|
||||||
|
fretboard = Fretboard(experimentSource, FlatFileExperimentStorage(experimentsFile))
|
||||||
|
|
||||||
return GlobalScope.async(Dispatchers.IO) {
|
return GlobalScope.async(Dispatchers.IO) {
|
||||||
val experimentsFile = File(filesDir, EXPERIMENTS_JSON_FILENAME)
|
|
||||||
val experimentSource = KintoExperimentSource(
|
|
||||||
EXPERIMENTS_BASE_URL,
|
|
||||||
EXPERIMENTS_BUCKET_NAME,
|
|
||||||
EXPERIMENTS_COLLECTION_NAME,
|
|
||||||
// TODO Switch back to components.core.client (see https://github.com/mozilla-mobile/fenix/issues/1329)
|
|
||||||
HttpURLConnectionClient()
|
|
||||||
)
|
|
||||||
// TODO add ValueProvider to keep clientID in sync with Glean when ready
|
|
||||||
fretboard = Fretboard(experimentSource, FlatFileExperimentStorage(experimentsFile))
|
|
||||||
fretboard.loadExperiments()
|
fretboard.loadExperiments()
|
||||||
Logger.debug("Bucket is ${fretboard.getUserBucket(this@FenixApplication)}")
|
Logger.debug("Bucket is ${fretboard.getUserBucket(this@FenixApplication)}")
|
||||||
Logger.debug("Experiments active: ${fretboard.getExperimentsMap(this@FenixApplication)}")
|
Logger.debug("Experiments active: ${fretboard.getExperimentsMap(this@FenixApplication)}")
|
||||||
|
|
Loading…
Reference in New Issue