In addition to the selected tab, we are now keeping 3 more tabs (based on LRU). This prevents switching between
tabs to feel slow if the "unselected" tab gets suspended immediately.
* For `PurgeHistoryUseCase` I decided to not introduce a "tab ID" parameter and instead have
it purge the history of all tabs. It seems like this is what we need and individual tab
history removal is not needed for now.
* Some tabs may not have an `EngineSession` assigned. Creating one just to call purgeHistory()
seems excessive. Instead I am dropping an attached `EngineSessionState` which will cause
those tabs to just reload the URL with not back/forward history when they get restored.
Again, multiple things in this PR:
* Migrated WebAppIntentProcessor and TrustedWebActivityIntentProcessor to use TabsUseCases instead of
SessionManager directly.
* Migrated one LoadUrlUseCase to take a session ID instead of a `Session` instance as parameter
* Extended TabsUseCases to optionally accept a CustomTabConfig and/or WebAppManifest
I think with that we may even be able to remove WebAppManifest from `Session`. I'll look into this next.
Multiple things are happening in this patch:
* `TabsUseCases` now returns the ID of new tabs instead of `Session` instances.
* `SearchUseCases` now delegates to a `TabsUseCases` instance to create tabs instead of using `SessionManager`
* Search terms have been removed from `Session` and are now only accessible on `ContentState`
* `CaptureActionsMiddleware` is a new helper to inspect actions dispatched on a `Store` in unit tests.
Running ./gradlew ktlint locally reports a lot of stuff like:
/home/emilio/src/moz/android-components/components/support/migration/src/test/java/mozilla/components/support/migration/MigrationIntentProcessorTest.kt:1:1: File must end with a newline (\n)
This fixes it with:
for f in $(cat files | cut -d : -f 1); do echo "" >> $f; done
Making ./gradlew ktlint pass.
This is not the fancy version yet since we still need to restore into SessionManager. Once it is gone and
we rely on BrowserStore only, then we can make this better.
However moving this functionality into AC now helps us:
- It will be easier to migrate to a better undo functionality since this code is already in AC.
- Other code can interact with the "undo" actions. For example "recently closed tabs" now will
only contain a tab if the removal was not undone.
* Instead of keeping the EngineSessionState inside EngineSession, we now always attach it to EngineState and also do not
clear it anymore.
* If the content process gets killed we now just suspend affected EngineSession instances. They will automatically and
lazily get restored from the last EngineSessionState once needed.
* On a content process crash we now mark the EngineState as crashed and suspend the EngineSession. We will not restore
the EngineSession until explicitly restored by the application.
Co-authored-by: Christian Sadilek <christian.sadilek@gmail.com>
Issue https://github.com/mozilla-mobile/android-components/pull/8121: Replace MigrationStore with MigrationContext and prevent usage outside of a Middleware.
* Before executing the reducer chain we now verify that we are on the store thread and throw if we are on a different thread.
* MigrationContext now provides a store property that returns the underlying Store instance. This can be used to pass it to
other components and threads that are not part of the Middleware.
* Fixed existing Middleware implementations to use the MiddlewareContext or pass the actual Store instance around.