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": Int, "selectedSessionIndex": Int, "sessionStateTuples": {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

clear | `fun clear(engine: Engine): Unit` Erases persisted SessionsSnapshot (if present) for a given Engine.
persist | `fun persist(engine: Engine, snapshot: SessionsSnapshot): Boolean` Persists the provided SessionsSnapshot for a given Engine. SessionsSnapshot may be obtained using SessionManager.createSnapshot. Throws if snapshot is empty or otherwise incoherent.
read | `fun read(engine: Engine): SessionsSnapshot?` Returns the latest persisted sessions snapshot that may be used to read sessions. Resulting SessionsSnapshot may be restored via SessionManager.restore.
start | `fun start(sessionManager: SessionManager): Unit` Starts persisting the state frequently and automatically.
stop | `fun stop(): Unit` Stops persisting the state automatically.