android-components / mozilla.components.browser.session.storage / DefaultSessionStorage

# DefaultSessionStorage

`class DefaultSessionStorage : SessionStorage` (source)

Default implementation of SessionStorage which persists browser and engine session states to a JSON file.

The JSON format used for persisting: { "version": version, "selectedSession": "session-uuid", "session-uuid": { "session": {} "engineSession": {} }, "session-uuid": { "session": {} "engineSession": {} } }

### Constructors

<init> | `DefaultSessionStorage(context: Context, savePeriodically: Boolean = true, saveIntervalInSeconds: Long = 300, scheduler: ScheduledExecutorService = Executors.newSingleThreadScheduledExecutor())` Default implementation of SessionStorage which persists browser and engine session states to a JSON file.

### Functions

persist | `fun persist(sessionManager: SessionManager): Boolean` Persists the session state of the provided SessionManager.
restore | `fun restore(sessionManager: SessionManager): Boolean` Restores the session state by reading from the latest persisted version.
start | `fun start(sessionManager: SessionManager): Unit` Starts persisting the state frequently and automatically.
stop | `fun stop(): Unit` Stops persisting the state automatically.