Commit 8b9c3e01 authored by Christian Sadilek's avatar Christian Sadilek Committed by Jonathan Almeida
Browse files

Fixes for A-C 57.0.20200826190111: Move EngineSession to BrowserState

parent df01d2e8
......@@ -22,6 +22,7 @@ import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import mozilla.appservices.Megazord
import mozilla.components.browser.session.Session
import mozilla.components.browser.state.action.SystemAction
import mozilla.components.concept.push.PushProcessor
import mozilla.components.feature.addons.update.GlobalAddonDependencyProvider
import mozilla.components.lib.crash.CrashReporter
......@@ -309,7 +310,7 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
runOnlyInMainProcess {
components.core.icons.onTrimMemory(level)
components.core.sessionManager.onTrimMemory(level)
components.core.store.dispatch(SystemAction.LowMemoryAction(level))
}
}
......
......@@ -61,7 +61,6 @@ import mozilla.components.feature.search.SearchFeature
import mozilla.components.feature.session.FullScreenFeature
import mozilla.components.feature.session.PictureInPictureFeature
import mozilla.components.feature.session.SessionFeature
import mozilla.components.feature.session.SessionUseCases
import mozilla.components.feature.session.SwipeRefreshFeature
import mozilla.components.feature.session.behavior.EngineViewBottomBehavior
import mozilla.components.feature.sitepermissions.SitePermissions
......@@ -497,7 +496,6 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
feature = SessionFeature(
requireComponents.core.store,
requireComponents.useCases.sessionUseCases.goBack,
requireComponents.useCases.engineSessionUseCases,
view.engineView,
customTabSessionId
),
......@@ -572,7 +570,7 @@ abstract class BaseBrowserFragment : Fragment(), UserInteractionHandler, Session
fullScreenFeature.set(
feature = FullScreenFeature(
requireComponents.core.store,
SessionUseCases(sessionManager),
requireComponents.useCases.sessionUseCases,
customTabSessionId,
::viewportFitChange,
::fullScreenChanged
......
......@@ -15,7 +15,9 @@ import kotlinx.coroutines.withContext
import mozilla.components.browser.engine.gecko.GeckoEngine
import mozilla.components.browser.engine.gecko.fetch.GeckoViewFetchClient
import mozilla.components.browser.icons.BrowserIcons
import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager
import mozilla.components.browser.session.engine.EngineMiddleware
import mozilla.components.browser.session.storage.SessionStorage
import mozilla.components.browser.state.state.BrowserState
import mozilla.components.browser.state.store.BrowserStore
......@@ -140,10 +142,14 @@ class Core(private val context: Context, private val crashReporter: CrashReporti
DownloadMiddleware(context, DownloadService::class.java),
ReaderViewMiddleware(),
ThumbnailsMiddleware(thumbnailStorage)
)
) + EngineMiddleware.create(engine, ::findSessionById)
)
}
private fun findSessionById(tabId: String): Session? {
return sessionManager.findSessionById(tabId)
}
/**
* The [CustomTabsServiceStore] holds global custom tabs related data.
*/
......@@ -190,7 +196,7 @@ class Core(private val context: Context, private val crashReporter: CrashReporti
// Now that we have restored our previous state (if there's one) let's setup auto saving the state while
// the app is used.
sessionStorage.autoSave(sessionManager)
sessionStorage.autoSave(store)
.periodicallyInForeground(interval = 30, unit = TimeUnit.SECONDS)
.whenGoingToBackground()
.whenSessionsChange()
......
......@@ -7,7 +7,6 @@ package org.mozilla.fenix.components
import android.content.Context
import mozilla.components.browser.search.SearchEngineManager
import mozilla.components.browser.session.SessionManager
import mozilla.components.browser.session.usecases.EngineSessionUseCases
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.concept.engine.Engine
import mozilla.components.feature.app.links.AppLinksUseCases
......@@ -42,7 +41,7 @@ class UseCases(
/**
* Use cases that provide engine interactions for a given browser session.
*/
val sessionUseCases by lazy { SessionUseCases(sessionManager) }
val sessionUseCases by lazy { SessionUseCases(store, sessionManager) }
/**
* Use cases that provide tab management.
......@@ -52,7 +51,7 @@ class UseCases(
/**
* Use cases that provide search engine integration.
*/
val searchUseCases by lazy { SearchUseCases(context, searchEngineManager, sessionManager) }
val searchUseCases by lazy { SearchUseCases(context, store, searchEngineManager, sessionManager) }
/**
* Use cases that provide settings management.
......@@ -69,8 +68,6 @@ class UseCases(
val contextMenuUseCases by lazy { ContextMenuUseCases(store) }
val engineSessionUseCases by lazy { EngineSessionUseCases(sessionManager) }
val trackingProtectionUseCases by lazy { TrackingProtectionUseCases(store, engine) }
/**
......
......@@ -8,15 +8,17 @@ import androidx.navigation.NavController
import io.mockk.mockk
import io.mockk.verify
import mozilla.components.browser.session.SessionManager
import mozilla.components.browser.state.store.BrowserStore
import mozilla.components.feature.session.SessionUseCases
import org.junit.Test
import org.mozilla.fenix.R
class TabHistoryControllerTest {
private val store: BrowserStore = mockk(relaxed = true)
private val sessionManager: SessionManager = mockk(relaxed = true)
private val navController: NavController = mockk(relaxed = true)
private val sessionUseCases = SessionUseCases(sessionManager)
private val sessionUseCases = SessionUseCases(store, sessionManager)
private val goToHistoryIndexUseCase = sessionUseCases.goToHistoryIndex
private val controller = DefaultTabHistoryController(
navController = navController,
......
......@@ -3,5 +3,5 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
object AndroidComponents {
const val VERSION = "57.0.20200826130107"
const val VERSION = "57.0.20200826190111"
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment