Skip to content

Commit c2551be

Browse files
committed
Closes mozilla-mobile#2314: feature-session-bundling: No longer allow accessing SessionBundleStorage from the main thread.
1 parent ab634b8 commit c2551be

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

components/feature/session-bundling/src/main/java/mozilla/components/feature/session/bundling/SessionBundleStorage.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import android.arch.paging.DataSource
1111
import android.content.Context
1212
import android.support.annotation.CheckResult
1313
import android.support.annotation.VisibleForTesting
14+
import android.support.annotation.WorkerThread
1415
import mozilla.components.browser.session.Session
1516
import mozilla.components.browser.session.SessionManager
1617
import mozilla.components.browser.session.storage.AutoSave
@@ -44,6 +45,7 @@ class SessionBundleStorage(
4445
* Restores the last [SessionBundle] if there is one without expired lifetime.
4546
*/
4647
@Synchronized
48+
@WorkerThread
4749
fun restore(): SessionBundle? {
4850
val since = now() - bundleLifetime.second.toMillis(bundleLifetime.first)
4951

@@ -60,6 +62,7 @@ class SessionBundleStorage(
6062
* updated with the data from the snapshot. If no bundle was restored a new bundle will be created.
6163
*/
6264
@Synchronized
65+
@WorkerThread
6366
override fun save(snapshot: SessionManager.Snapshot): Boolean {
6467
val bundle = lastBundle
6568

@@ -77,6 +80,7 @@ class SessionBundleStorage(
7780
* next time a [SessionManager.Snapshot] is saved.
7881
*/
7982
@Synchronized
83+
@WorkerThread
8084
fun remove(bundle: SessionBundle) {
8185
if (bundle !is SessionBundleAdapter) {
8286
throw IllegalArgumentException("Unexpected bundle type")
@@ -93,6 +97,7 @@ class SessionBundleStorage(
9397
* Removes all saved [SessionBundle] instances permanently.
9498
*/
9599
@Synchronized
100+
@WorkerThread
96101
fun removeAll() {
97102
lastBundle = null
98103
database.clearAllTables()

components/feature/session-bundling/src/main/java/mozilla/components/feature/session/bundling/db/BundleDatabase.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ internal abstract class BundleDatabase : RoomDatabase() {
3030
context,
3131
BundleDatabase::class.java,
3232
"bundle_database"
33-
).allowMainThreadQueries().build().also { instance = it }
33+
).build().also { instance = it }
3434
}
3535
}
3636
}

0 commit comments

Comments
 (0)