android-components / mozilla.components.service.sync.logins / AsyncLoginsStorageAdapter


open class AsyncLoginsStorageAdapter<T : LoginsStorage> : AsyncLoginsStorage, AutoCloseable (source)

A helper class to wrap a synchronous LoginsStorage implementation and make it asynchronous.


Name Summary
<init> AsyncLoginsStorageAdapter(wrapped: T)
A helper class to wrap a synchronous LoginsStorage implementation and make it asynchronous.


Name Summary
add open fun add(login: ServerPassword): Deferred<String>
Inserts the provided login into the database, returning it’s id.
close open fun close(): Unit
delete open fun delete(id: String): Deferred<Boolean>
Deletes the password with the given ID.
ensureLocked open fun ensureLocked(): Deferred<Unit>
Equivalent to lock(), but does not throw in the case that the database is already unlocked. Never rejects.
ensureUnlocked open fun ensureUnlocked(encryptionKey: String): Deferred<Unit>
open fun ensureUnlocked(encryptionKey: ByteArray): Deferred<Unit>
Equivalent to unlock(encryptionKey), but does not throw in the case that the database is already unlocked.
ensureValid open fun ensureValid(login: ServerPassword): Deferred<Unit>
Checks if login already exists and is valid.
get open fun get(id: String): Deferred<ServerPassword?>
Fetches a password from the underlying storage layer by ID.
getByBaseDomain open fun getByBaseDomain(hostname: String): Deferred<List<ServerPassword>>
Fetch the list of passwords for some hostname from the underlying storage layer.
getHandle open fun getHandle(): Long
This should be removed. See:
importLoginsAsync open fun importLoginsAsync(logins: List<ServerPassword>): Deferred<<ERROR CLASS>>
Bulk-import of a list of ServerPassword. Storage must be empty, otherwise underlying implementation this will throw.
isLocked open fun isLocked(): Boolean
Returns true if the storage is locked, false otherwise.
list open fun list(): Deferred<List<ServerPassword>>
Fetches the full list of passwords from the underlying storage layer.
lock open fun lock(): Deferred<Unit>
Locks the logins storage.
sync open fun sync(syncInfo: SyncUnlockInfo): Deferred<SyncTelemetryPing>
Synchronizes the logins storage layer with a remote layer.
touch open fun touch(id: String): Deferred<Unit>
Marks the login with the given ID as in-use.
unlock open fun unlock(encryptionKey: String): Deferred<Unit>
Unlocks the logins storage using the provided fun unlock(encryptionKey: ByteArray): Deferred<Unit>
Unlock (open) the database, using a byte string as the key. This is equivalent to calling unlock() after hex-encoding the bytes (lower case hexadecimal characters are used).
update open fun update(login: ServerPassword): Deferred<Unit>
Updates the fields in the provided record.
wipe open fun wipe(): Deferred<Unit>
Delete all login records. These deletions will be synced to the server on the next call to sync.
wipeLocal open fun wipeLocal(): Deferred<Unit>
Clear out all local state, bringing us back to the state before the first write (or sync).

Inherited Functions

Name Summary
withUnlocked open suspend fun <T> withUnlocked(key: () -> Deferred<String>, block: suspend (AsyncLoginsStorage) -> T): T
Run some block which operates over an unlocked instance of AsyncLoginsStorage. Database is locked once block is done.

Companion Object Functions

Name Summary
forDatabase fun forDatabase(dbPath: String): AsyncLoginsStorageAdapter<DatabaseLoginsStorage>
Creates an AsyncLoginsStorage that is backed by a DatabaseLoginsStorage.

Extension Functions

Name Summary
loadResourceAsString fun Any.loadResourceAsString(path: String): String
Loads a file from the resources folder and returns its content as a string object.