Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
android-components
Commits
348b02c7
Commit
348b02c7
authored
Aug 04, 2020
by
Gabriel Luong
Browse files
Issue #7978: Part 1 - Rename TopSiteStorage to PinnedSitesStorage
parent
5713f81b
Changes
4
Hide whitespace changes
Inline
Side-by-side
components/feature/top-sites/src/androidTest/java/mozilla/components/feature/top/sites/
Top
SiteStorageTest.kt
→
components/feature/top-sites/src/androidTest/java/mozilla/components/feature/top/sites/
Pinned
Site
s
StorageTest.kt
View file @
348b02c7
...
...
@@ -30,9 +30,9 @@ import java.util.concurrent.Executors
private
const
val
MIGRATION_TEST_DB
=
"migration-test"
@Suppress
(
"LargeClass"
)
class
Top
SiteStorageTest
{
class
Pinned
Site
s
StorageTest
{
private
lateinit
var
context
:
Context
private
lateinit
var
storage
:
Top
SiteStorage
private
lateinit
var
storage
:
Pinned
SiteStorage
private
lateinit
var
executor
:
ExecutorService
@
get
:
Rule
...
...
@@ -52,7 +52,7 @@ class TopSiteStorageTest {
context
=
ApplicationProvider
.
getApplicationContext
()
val
database
=
Room
.
inMemoryDatabaseBuilder
(
context
,
TopSiteDatabase
::
class
.
java
).
build
()
storage
=
Top
SiteStorage
(
context
)
storage
=
Pinned
SiteStorage
(
context
)
storage
.
database
=
lazy
{
database
}
}
...
...
components/feature/top-sites/src/main/java/mozilla/components/feature/top/sites/
Top
SiteStorage.kt
→
components/feature/top-sites/src/main/java/mozilla/components/feature/top/sites/
Pinned
SiteStorage.kt
View file @
348b02c7
...
...
@@ -15,7 +15,7 @@ import mozilla.components.feature.top.sites.db.TopSiteEntity
/**
* A storage implementation for organizing top sites.
*/
class
Top
SiteStorage
(
class
Pinned
SiteStorage
(
context
:
Context
)
{
internal
var
database
:
Lazy
<
TopSiteDatabase
>
=
lazy
{
TopSiteDatabase
.
get
(
context
)
}
...
...
components/support/migration/src/main/java/mozilla/components/support/migration/FennecMigrator.kt
View file @
348b02c7
...
...
@@ -23,7 +23,7 @@ import mozilla.components.browser.storage.sync.PlacesHistoryStorage
import
mozilla.components.concept.engine.Engine
import
mozilla.components.feature.addons.amo.AddonCollectionProvider
import
mozilla.components.feature.addons.update.AddonUpdater
import
mozilla.components.feature.top.sites.
Top
SiteStorage
import
mozilla.components.feature.top.sites.
Pinned
SiteStorage
import
mozilla.components.service.fxa.manager.FxaAccountManager
import
mozilla.components.service.glean.Glean
import
mozilla.components.service.sync.logins.SyncableLoginsStorage
...
...
@@ -217,7 +217,7 @@ sealed class FennecMigratorException(cause: Exception) : Exception(cause) {
* @param bookmarksStorage An optional instance of [PlacesBookmarksStorage] used to store migrated bookmarks data.
* @param coroutineContext An instance of [CoroutineContext] used for executing async migration tasks.
*/
@Suppress
(
"LargeClass"
,
"TooManyFunctions"
)
@Suppress
(
"LargeClass"
,
"TooManyFunctions"
,
"LongParameterList"
)
class
FennecMigrator
private
constructor
(
private
val
context
:
Context
,
private
val
crashReporter
:
CrashReporting
,
...
...
@@ -237,7 +237,7 @@ class FennecMigrator private constructor(
private
val
signonsDbName
:
String
,
private
val
key4DbName
:
String
,
private
val
coroutineContext
:
CoroutineContext
,
private
val
top
SiteStorage
:
Top
SiteStorage
?
private
val
pinned
Site
s
Storage
:
Pinned
SiteStorage
?
)
{
/**
* Data migration builder. Allows configuring which migrations to run, their versions and relative order.
...
...
@@ -266,7 +266,7 @@ class FennecMigrator private constructor(
private
var
signonsDbName
=
"signons.sqlite"
private
var
key4DbName
=
"key4.db"
private
var
masterPassword
=
FennecLoginsMigration
.
DEFAULT_MASTER_PASSWORD
private
var
top
SiteStorage
:
Top
SiteStorage
?
=
null
private
var
pinned
Site
s
Storage
:
Pinned
SiteStorage
?
=
null
/**
* Enable history migration.
...
...
@@ -288,16 +288,16 @@ class FennecMigrator private constructor(
/**
* Enable bookmarks migration. Must be called after [migrateHistory].
* Optionally, enable top sites migration, if [
top
SiteStorage] is specified.
* Optionally, enable top sites migration, if [
pinned
Site
s
Storage] is specified.
* In Fennec, pinned sites are stored as special type of a bookmark, hence this coupling.
*
* @param storage An instance of [PlacesBookmarksStorage], used for storing data.
* @param
top
SiteStorage An instance of [
Top
SiteStorage], used for storing pinned sites.
* @param
pinned
Site
s
Storage An instance of [
Pinned
SiteStorage], used for storing pinned sites.
* @param version Version of the migration; defaults to the current version.
*/
fun
migrateBookmarks
(
storage
:
Lazy
<
PlacesBookmarksStorage
>,
top
SiteStorage
:
Top
SiteStorage
?
=
null
,
pinned
Site
s
Storage
:
Pinned
SiteStorage
?
=
null
,
version
:
Int
=
Migration
.
Bookmarks
.
currentVersion
):
Builder
{
check
(
migrations
.
find
{
it
.
migration
is
Migration
.
FxA
}
==
null
)
{
...
...
@@ -312,8 +312,8 @@ class FennecMigrator private constructor(
// Allowing enabling pinned sites migration only when bookmarks migration is enabled is a conscious
// choice. We currently don't have a requirement to only migrate pinned sites, and not bookmarks,
// and so this is done to keep things a bit simpler.
top
SiteStorage
?.
let
{
this
.
top
SiteStorage
=
it
pinned
Site
s
Storage
?.
let
{
this
.
pinned
Site
s
Storage
=
it
migrations
.
add
(
VersionedMigration
(
Migration
.
PinnedSites
,
version
))
}
...
...
@@ -448,7 +448,7 @@ class FennecMigrator private constructor(
signonsDbName
,
key4DbName
,
coroutineContext
,
top
SiteStorage
pinned
Site
s
Storage
)
}
...
...
@@ -1263,7 +1263,7 @@ class FennecMigrator private constructor(
@Suppress
(
"ComplexMethod"
,
"TooGenericExceptionCaught"
,
"ReturnCount"
,
"NestedBlockDepth"
)
private
fun
migratePinnedSites
():
Result
<
Unit
>
{
checkNotNull
(
bookmarksStorage
)
{
"Bookmarks storage must be configured to migrate pinned sites"
}
checkNotNull
(
top
SiteStorage
)
{
"
Top
SiteStorage must be configured to migrate pinned sites"
}
checkNotNull
(
pinned
Site
s
Storage
)
{
"
Pinned
SiteStorage must be configured to migrate pinned sites"
}
// There's no dbPath without a profile, but if a profile is present we expect dbPath to be also present.
if
(
profile
!=
null
&&
browserDbPath
==
null
)
{
...
...
@@ -1305,7 +1305,7 @@ class FennecMigrator private constructor(
// Reversed, so that first pinned site in Fennec ends up as the first one in Fenix, as well.
pinnedSitesWithUrl
.
reversed
().
forEach
{
pinnedSite
->
try
{
top
SiteStorage
.
addTopSite
(
pinnedSite
.
title
?:
""
,
pinnedSite
.
url
!!
)
pinned
Site
s
Storage
.
addTopSite
(
pinnedSite
.
title
?:
""
,
pinnedSite
.
url
!!
)
}
catch
(
e
:
Exception
)
{
failedToImport
++
// Let's not spam Sentry and submit the same exception multiple times
...
...
components/support/migration/src/test/java/mozilla/components/support/migration/FennecMigratorTest.kt
View file @
348b02c7
...
...
@@ -34,7 +34,7 @@ import mozilla.components.concept.engine.Engine
import
mozilla.components.concept.engine.webextension.WebExtension
import
mozilla.components.feature.addons.amo.AddonCollectionProvider
import
mozilla.components.feature.addons.update.AddonUpdater
import
mozilla.components.feature.top.sites.
Top
SiteStorage
import
mozilla.components.feature.top.sites.
Pinned
SiteStorage
import
mozilla.components.service.fxa.manager.SignInWithShareableAccountResult
import
mozilla.components.service.fxa.sharing.ShareableAccount
import
mozilla.components.service.sync.logins.SyncableLoginsStorage
...
...
@@ -160,7 +160,7 @@ class FennecMigratorTest {
fun
`migrations
versioning
basics`
()
=
runBlocking
{
val
historyStore
=
PlacesHistoryStorage
(
testContext
)
val
bookmarksStore
=
PlacesBookmarksStorage
(
testContext
)
val
topSiteStorage
=
mock
<
Top
SiteStorage
>()
val
topSiteStorage
=
mock
<
Pinned
SiteStorage
>()
// Clear-up storage layers between test runs.
historyStore
.
deleteEverything
()
...
...
@@ -257,7 +257,7 @@ class FennecMigratorTest {
fun
`pinned
sites
migration`
()
=
runBlocking
{
val
historyStore
=
PlacesHistoryStorage
(
testContext
)
val
bookmarksStore
=
PlacesBookmarksStorage
(
testContext
)
val
topSiteStorage
=
mock
<
Top
SiteStorage
>()
val
topSiteStorage
=
mock
<
Pinned
SiteStorage
>()
val
migrator
=
FennecMigrator
.
Builder
(
testContext
,
mock
())
.
setCoroutineContext
(
this
.
coroutineContext
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment