From 9e324fa02a6c3811165707e4210fa5a9c1690fda Mon Sep 17 00:00:00 2001 From: Grisha Kruglov Date: Wed, 25 Mar 2020 17:36:31 -0700 Subject: [PATCH] Perform storage warm-up after visual completeness --- .../java/org/mozilla/fenix/FenixApplication.kt | 9 ++++++--- .../java/org/mozilla/fenix/components/Core.kt | 18 +++--------------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt index eb1ec59fc..0b91a4e47 100644 --- a/app/src/main/java/org/mozilla/fenix/FenixApplication.kt +++ b/app/src/main/java/org/mozilla/fenix/FenixApplication.kt @@ -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() + } } } } diff --git a/app/src/main/java/org/mozilla/fenix/components/Core.kt b/app/src/main/java/org/mozilla/fenix/components/Core.kt index 49ab1d226..e1557cfec 100644 --- a/app/src/main/java/org/mozilla/fenix/components/Core.kt +++ b/app/src/main/java/org/mozilla/fenix/components/Core.kt @@ -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 }