Commit 9e324fa0 authored by Grisha Kruglov's avatar Grisha Kruglov Committed by Grisha Kruglov
Browse files

Perform storage warm-up after visual completeness

parent 20f8b97d
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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()
                }
            }
        }
    }
+3 −15
Original line number Diff line number Diff line
@@ -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 }