2
0
mirror of https://github.com/fork-maintainers/iceraven-browser synced 2024-11-11 13:11:01 +00:00

Perform storage warm-up after visual completeness

This commit is contained in:
Grisha Kruglov 2020-03-25 17:36:31 -07:00 committed by Grisha Kruglov
parent 20f8b97dcb
commit 9e324fa02a
2 changed files with 9 additions and 18 deletions

View File

@ -32,6 +32,7 @@ import mozilla.components.support.ktx.android.content.runOnlyInMainProcess
import mozilla.components.support.locale.LocaleAwareApplication
import mozilla.components.support.rusthttp.RustHttpConfig
import mozilla.components.support.rustlog.RustLog
import mozilla.components.support.utils.logElapsedTime
import mozilla.components.support.webextensions.WebExtensionSupport
import org.mozilla.fenix.FeatureFlags.webPushIntegration
import org.mozilla.fenix.components.Components
@ -155,9 +156,11 @@ open class FenixApplication : LocaleAwareApplication() {
components.performance.visualCompletenessTaskManager.add {
GlobalScope.launch(Dispatchers.IO) {
logger.info("Initializing storage after visual completeness...")
components.core.lazyHistoryStorage.value
components.core.lazyBookmarksStorage.value
components.core.lazyPasswordsStorage.value
logElapsedTime(logger, "Storage initialization") {
components.core.historyStorage.warmUp()
components.core.bookmarksStorage.warmUp()
components.core.passwordsStorage.warmUp()
}
}
}
}

View File

@ -38,7 +38,6 @@ import mozilla.components.feature.webnotifications.WebNotificationFeature
import mozilla.components.lib.dataprotect.SecureAbove22Preferences
import mozilla.components.lib.dataprotect.generateEncryptionKey
import mozilla.components.service.sync.logins.SyncableLoginsStorage
import mozilla.components.support.base.log.logger.Logger
import org.mozilla.fenix.AppRequestInterceptor
import org.mozilla.fenix.Config
import org.mozilla.fenix.FeatureFlags
@ -53,8 +52,6 @@ import java.util.concurrent.TimeUnit
*/
@Mockable
class Core(private val context: Context) {
private val logger = Logger("Core")
/**
* The browser engine component initialized based on the build
* configuration (see build variants).
@ -192,18 +189,9 @@ class Core(private val context: Context) {
// Use these for startup-path code, where we don't want to do any work that's not strictly necessary.
// For example, this is how the GeckoEngine delegates (history, logins) are configured.
// We can fully initialize GeckoEngine without initialized our storage.
val lazyHistoryStorage = lazy {
logger.info("Initializing history storage")
PlacesHistoryStorage(context)
}
val lazyBookmarksStorage = lazy {
logger.info("Initializing bookmarks storage")
PlacesBookmarksStorage(context)
}
val lazyPasswordsStorage = lazy {
logger.info("Initializing logins storage")
SyncableLoginsStorage(context, passwordsEncryptionKey)
}
val lazyHistoryStorage = lazy { PlacesHistoryStorage(context) }
val lazyBookmarksStorage = lazy { PlacesBookmarksStorage(context) }
val lazyPasswordsStorage = lazy { SyncableLoginsStorage(context, passwordsEncryptionKey) }
// For most other application code (non-startup), these wrappers are perfectly fine and more ergonomic.
val historyStorage by lazy { lazyHistoryStorage.value }