mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 995157 - Specify default profile when syncing tabs and remote clients. r=rnewman
========7fd50fef23
Author: Nick Alexander <nalexander@mozilla.com> Date: Fri Apr 18 13:11:34 2014 -0700 Bug 995157 - Part 2: Specify default profile when syncing tabs and remote clients. ========79da665d74
Author: Nick Alexander <nalexander@mozilla.com> Date: Fri Apr 18 15:22:02 2014 -0700 Bug 995157 - Part 1: Use FORM_HISTORY_AUTHORITY_URI.
This commit is contained in:
parent
8fc9b5107f
commit
f8f54927e9
@ -38,6 +38,8 @@ public class BrowserContractHelpers extends BrowserContract {
|
||||
public static final Uri DELETED_PASSWORDS_CONTENT_URI = withSyncAndDeletedAndProfile(DeletedPasswords.CONTENT_URI);
|
||||
public static final Uri FORM_HISTORY_CONTENT_URI = withSyncAndProfile(FormHistory.CONTENT_URI);
|
||||
public static final Uri DELETED_FORM_HISTORY_CONTENT_URI = withSyncAndProfile(DeletedFormHistory.CONTENT_URI);
|
||||
public static final Uri TABS_CONTENT_URI = withSyncAndProfile(Tabs.CONTENT_URI);
|
||||
public static final Uri CLIENTS_CONTENT_URI = withSyncAndProfile(Clients.CONTENT_URI);
|
||||
|
||||
public static final String[] PasswordColumns = new String[] {
|
||||
Passwords.ID,
|
||||
|
@ -73,9 +73,9 @@ public class FennecTabsRepository extends Repository {
|
||||
|
||||
public FennecTabsRepositorySession(Repository repository, Context context) throws NoContentProviderException {
|
||||
super(repository);
|
||||
clientsProvider = getContentProvider(context, BrowserContract.Clients.CONTENT_URI);
|
||||
clientsProvider = getContentProvider(context, BrowserContractHelpers.CLIENTS_CONTENT_URI);
|
||||
try {
|
||||
tabsProvider = getContentProvider(context, BrowserContract.Tabs.CONTENT_URI);
|
||||
tabsProvider = getContentProvider(context, BrowserContractHelpers.TABS_CONTENT_URI);
|
||||
} catch (NoContentProviderException e) {
|
||||
clientsProvider.release();
|
||||
throw e;
|
||||
@ -85,7 +85,7 @@ public class FennecTabsRepository extends Repository {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
tabsHelper = new RepoUtils.QueryHelper(context, BrowserContract.Tabs.CONTENT_URI, LOG_TAG);
|
||||
tabsHelper = new RepoUtils.QueryHelper(context, BrowserContractHelpers.TABS_CONTENT_URI, LOG_TAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -225,7 +225,7 @@ public class FennecTabsRepository extends Repository {
|
||||
if (tabsRecord.deleted) {
|
||||
try {
|
||||
Logger.debug(LOG_TAG, "Clearing entry for client " + tabsRecord.guid);
|
||||
clientsProvider.delete(BrowserContract.Clients.CONTENT_URI,
|
||||
clientsProvider.delete(BrowserContractHelpers.CLIENTS_CONTENT_URI,
|
||||
CLIENT_GUID_IS,
|
||||
selectionArgs);
|
||||
delegate.onRecordStoreSucceeded(record.guid);
|
||||
@ -239,20 +239,20 @@ public class FennecTabsRepository extends Repository {
|
||||
final ContentValues clientsCV = tabsRecord.getClientsContentValues();
|
||||
|
||||
Logger.debug(LOG_TAG, "Updating clients provider.");
|
||||
final int updated = clientsProvider.update(BrowserContract.Clients.CONTENT_URI,
|
||||
final int updated = clientsProvider.update(BrowserContractHelpers.CLIENTS_CONTENT_URI,
|
||||
clientsCV,
|
||||
CLIENT_GUID_IS,
|
||||
selectionArgs);
|
||||
if (0 == updated) {
|
||||
clientsProvider.insert(BrowserContract.Clients.CONTENT_URI, clientsCV);
|
||||
clientsProvider.insert(BrowserContractHelpers.CLIENTS_CONTENT_URI, clientsCV);
|
||||
}
|
||||
|
||||
// Now insert tabs.
|
||||
final ContentValues[] tabsArray = tabsRecord.getTabsContentValues();
|
||||
Logger.debug(LOG_TAG, "Inserting " + tabsArray.length + " tabs for client " + tabsRecord.guid);
|
||||
|
||||
tabsProvider.delete(BrowserContract.Tabs.CONTENT_URI, TABS_CLIENT_GUID_IS, selectionArgs);
|
||||
final int inserted = tabsProvider.bulkInsert(BrowserContract.Tabs.CONTENT_URI, tabsArray);
|
||||
tabsProvider.delete(BrowserContractHelpers.TABS_CONTENT_URI, TABS_CLIENT_GUID_IS, selectionArgs);
|
||||
final int inserted = tabsProvider.bulkInsert(BrowserContractHelpers.TABS_CONTENT_URI, tabsArray);
|
||||
Logger.trace(LOG_TAG, "Inserted: " + inserted);
|
||||
|
||||
delegate.onRecordStoreSucceeded(record.guid);
|
||||
@ -269,8 +269,8 @@ public class FennecTabsRepository extends Repository {
|
||||
@Override
|
||||
public void wipe(RepositorySessionWipeDelegate delegate) {
|
||||
try {
|
||||
tabsProvider.delete(BrowserContract.Tabs.CONTENT_URI, null, null);
|
||||
clientsProvider.delete(BrowserContract.Clients.CONTENT_URI, null, null);
|
||||
tabsProvider.delete(BrowserContractHelpers.TABS_CONTENT_URI, null, null);
|
||||
clientsProvider.delete(BrowserContractHelpers.CLIENTS_CONTENT_URI, null, null);
|
||||
} catch (RemoteException e) {
|
||||
Logger.warn(LOG_TAG, "Got RemoteException in wipe.", e);
|
||||
delegate.onWipeFailed(e);
|
||||
|
@ -10,6 +10,7 @@ import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.mozilla.gecko.background.common.log.Logger;
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
import org.mozilla.gecko.db.BrowserContract.DeletedFormHistory;
|
||||
import org.mozilla.gecko.db.BrowserContract.FormHistory;
|
||||
import org.mozilla.gecko.sync.repositories.InactiveSessionException;
|
||||
@ -75,7 +76,7 @@ public class FormHistoryRepositorySession extends
|
||||
*/
|
||||
public static ContentProviderClient acquireContentProvider(final Context context)
|
||||
throws NoContentProviderException {
|
||||
Uri uri = FormHistory.CONTENT_URI;
|
||||
Uri uri = BrowserContract.FORM_HISTORY_AUTHORITY_URI;
|
||||
ContentProviderClient client = context.getContentResolver().acquireContentProviderClient(uri);
|
||||
if (client == null) {
|
||||
throw new NoContentProviderException(uri);
|
||||
@ -123,6 +124,7 @@ public class FormHistoryRepositorySession extends
|
||||
@Override
|
||||
public void guidsSince(final long timestamp, final RepositorySessionGuidsSinceDelegate delegate) {
|
||||
Runnable command = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isActive()) {
|
||||
delegate.onGuidsSinceFailed(new InactiveSessionException(null));
|
||||
@ -703,6 +705,7 @@ public class FormHistoryRepositorySession extends
|
||||
@Override
|
||||
public void wipe(final RepositorySessionWipeDelegate delegate) {
|
||||
Runnable command = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isActive()) {
|
||||
delegate.onWipeFailed(new InactiveSessionException(null));
|
||||
|
@ -10,6 +10,7 @@ import org.mozilla.gecko.background.sync.helpers.SessionTestHelper;
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
import org.mozilla.gecko.sync.repositories.NoContentProviderException;
|
||||
import org.mozilla.gecko.sync.repositories.RepositorySession;
|
||||
import org.mozilla.gecko.sync.repositories.android.BrowserContractHelpers;
|
||||
import org.mozilla.gecko.sync.repositories.android.FennecTabsRepository;
|
||||
import org.mozilla.gecko.sync.repositories.android.FennecTabsRepository.FennecTabsRepositorySession;
|
||||
import org.mozilla.gecko.sync.repositories.delegates.RepositorySessionCreationDelegate;
|
||||
@ -34,13 +35,14 @@ public class TestFennecTabsRepositorySession extends AndroidSyncTestCase {
|
||||
|
||||
protected ContentProviderClient getTabsClient() {
|
||||
final ContentResolver cr = getApplicationContext().getContentResolver();
|
||||
return cr.acquireContentProviderClient(BrowserContract.Tabs.CONTENT_URI);
|
||||
return cr.acquireContentProviderClient(BrowserContractHelpers.TABS_CONTENT_URI);
|
||||
}
|
||||
|
||||
public TestFennecTabsRepositorySession() throws NoContentProviderException {
|
||||
super();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() {
|
||||
if (tabsClient == null) {
|
||||
tabsClient = getTabsClient();
|
||||
@ -51,10 +53,11 @@ public class TestFennecTabsRepositorySession extends AndroidSyncTestCase {
|
||||
if (tabsClient == null) {
|
||||
return -1;
|
||||
}
|
||||
return tabsClient.delete(BrowserContract.Tabs.CONTENT_URI,
|
||||
return tabsClient.delete(BrowserContractHelpers.TABS_CONTENT_URI,
|
||||
TEST_TABS_CLIENT_GUID_IS_LOCAL_SELECTION, TEST_TABS_CLIENT_GUID_IS_LOCAL_SELECTION_ARGS);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
if (tabsClient != null) {
|
||||
deleteAllTestTabs(tabsClient);
|
||||
@ -148,9 +151,9 @@ public class TestFennecTabsRepositorySession extends AndroidSyncTestCase {
|
||||
history3.add("http://test.com/test3.html#2");
|
||||
testTab3 = new Tab("test title 3", "http://test.com/test3.png", history3, 3000);
|
||||
|
||||
tabsClient.insert(BrowserContract.Tabs.CONTENT_URI, testTab1.toContentValues(TEST_CLIENT_GUID, 0));
|
||||
tabsClient.insert(BrowserContract.Tabs.CONTENT_URI, testTab2.toContentValues(TEST_CLIENT_GUID, 1));
|
||||
tabsClient.insert(BrowserContract.Tabs.CONTENT_URI, testTab3.toContentValues(TEST_CLIENT_GUID, 2));
|
||||
tabsClient.insert(BrowserContractHelpers.TABS_CONTENT_URI, testTab1.toContentValues(TEST_CLIENT_GUID, 0));
|
||||
tabsClient.insert(BrowserContractHelpers.TABS_CONTENT_URI, testTab2.toContentValues(TEST_CLIENT_GUID, 1));
|
||||
tabsClient.insert(BrowserContractHelpers.TABS_CONTENT_URI, testTab3.toContentValues(TEST_CLIENT_GUID, 2));
|
||||
}
|
||||
|
||||
protected TabsRecord insertTestTabsAndExtractTabsRecord() throws RemoteException {
|
||||
@ -159,7 +162,7 @@ public class TestFennecTabsRepositorySession extends AndroidSyncTestCase {
|
||||
final String positionAscending = BrowserContract.Tabs.POSITION + " ASC";
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = tabsClient.query(BrowserContract.Tabs.CONTENT_URI, null,
|
||||
cursor = tabsClient.query(BrowserContractHelpers.TABS_CONTENT_URI, null,
|
||||
TEST_TABS_CLIENT_GUID_IS_LOCAL_SELECTION, TEST_TABS_CLIENT_GUID_IS_LOCAL_SELECTION_ARGS, positionAscending);
|
||||
CursorDumper.dumpCursor(cursor);
|
||||
|
||||
|
@ -5,6 +5,7 @@ package org.mozilla.gecko.background.db;
|
||||
|
||||
import org.json.simple.JSONArray;
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
import org.mozilla.gecko.sync.repositories.android.BrowserContractHelpers;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ContentProviderClient;
|
||||
@ -37,21 +38,22 @@ public class TestFennecTabsStorage extends ActivityInstrumentationTestCase2<Acti
|
||||
|
||||
protected ContentProviderClient getClientsClient() {
|
||||
final ContentResolver cr = getInstrumentation().getTargetContext().getApplicationContext().getContentResolver();
|
||||
return cr.acquireContentProviderClient(BrowserContract.Clients.CONTENT_URI);
|
||||
return cr.acquireContentProviderClient(BrowserContractHelpers.CLIENTS_CONTENT_URI);
|
||||
}
|
||||
|
||||
protected ContentProviderClient getTabsClient() {
|
||||
final ContentResolver cr = getInstrumentation().getTargetContext().getApplicationContext().getContentResolver();
|
||||
return cr.acquireContentProviderClient(BrowserContract.Tabs.CONTENT_URI);
|
||||
return cr.acquireContentProviderClient(BrowserContractHelpers.TABS_CONTENT_URI);
|
||||
}
|
||||
|
||||
protected int deleteAllTestTabs(final ContentProviderClient tabsClient) throws RemoteException {
|
||||
if (tabsClient == null) {
|
||||
return -1;
|
||||
}
|
||||
return tabsClient.delete(BrowserContract.Tabs.CONTENT_URI, TABS_CLIENT_GUID_IS, new String[] { TEST_CLIENT_GUID });
|
||||
return tabsClient.delete(BrowserContractHelpers.TABS_CONTENT_URI, TABS_CLIENT_GUID_IS, new String[] { TEST_CLIENT_GUID });
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
deleteAllTestTabs(getTabsClient());
|
||||
}
|
||||
@ -73,9 +75,9 @@ public class TestFennecTabsStorage extends ActivityInstrumentationTestCase2<Acti
|
||||
history3.add("http://test.com/test3.html#2");
|
||||
testTab3 = new Tab("test title 3", "http://test.com/test3.png", history3, 3000);
|
||||
|
||||
tabsClient.insert(BrowserContract.Tabs.CONTENT_URI, testTab1.toContentValues(TEST_CLIENT_GUID, 0));
|
||||
tabsClient.insert(BrowserContract.Tabs.CONTENT_URI, testTab2.toContentValues(TEST_CLIENT_GUID, 1));
|
||||
tabsClient.insert(BrowserContract.Tabs.CONTENT_URI, testTab3.toContentValues(TEST_CLIENT_GUID, 2));
|
||||
tabsClient.insert(BrowserContractHelpers.TABS_CONTENT_URI, testTab1.toContentValues(TEST_CLIENT_GUID, 0));
|
||||
tabsClient.insert(BrowserContractHelpers.TABS_CONTENT_URI, testTab2.toContentValues(TEST_CLIENT_GUID, 1));
|
||||
tabsClient.insert(BrowserContractHelpers.TABS_CONTENT_URI, testTab3.toContentValues(TEST_CLIENT_GUID, 2));
|
||||
}
|
||||
|
||||
// Sanity.
|
||||
@ -90,7 +92,7 @@ public class TestFennecTabsStorage extends ActivityInstrumentationTestCase2<Acti
|
||||
}
|
||||
|
||||
public void testWipeClients() throws RemoteException {
|
||||
final Uri uri = BrowserContract.Clients.CONTENT_URI;
|
||||
final Uri uri = BrowserContractHelpers.CLIENTS_CONTENT_URI;
|
||||
final ContentProviderClient clientsClient = getClientsClient();
|
||||
|
||||
// Have to ensure that it's empty…
|
||||
@ -111,7 +113,7 @@ public class TestFennecTabsStorage extends ActivityInstrumentationTestCase2<Acti
|
||||
}
|
||||
|
||||
public void testStoreAndRetrieveClients() throws RemoteException {
|
||||
final Uri uri = BrowserContract.Clients.CONTENT_URI;
|
||||
final Uri uri = BrowserContractHelpers.CLIENTS_CONTENT_URI;
|
||||
final ContentProviderClient clientsClient = getClientsClient();
|
||||
|
||||
// Have to ensure that it's empty…
|
||||
@ -174,7 +176,7 @@ public class TestFennecTabsStorage extends ActivityInstrumentationTestCase2<Acti
|
||||
final String positionAscending = BrowserContract.Tabs.POSITION + " ASC";
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = tabsClient.query(BrowserContract.Tabs.CONTENT_URI, null, TABS_CLIENT_GUID_IS, new String[] { TEST_CLIENT_GUID }, positionAscending);
|
||||
cursor = tabsClient.query(BrowserContractHelpers.TABS_CONTENT_URI, null, TABS_CLIENT_GUID_IS, new String[] { TEST_CLIENT_GUID }, positionAscending);
|
||||
assertEquals(3, cursor.getCount());
|
||||
|
||||
cursor.moveToFirst();
|
||||
|
@ -6,6 +6,7 @@ package org.mozilla.gecko.background.sync;
|
||||
import org.mozilla.gecko.background.db.CursorDumper;
|
||||
import org.mozilla.gecko.background.db.TestFennecTabsStorage;
|
||||
import org.mozilla.gecko.db.BrowserContract;
|
||||
import org.mozilla.gecko.sync.repositories.android.BrowserContractHelpers;
|
||||
import org.mozilla.gecko.sync.repositories.android.FennecTabsRepository;
|
||||
import org.mozilla.gecko.sync.repositories.domain.TabsRecord;
|
||||
|
||||
@ -22,7 +23,7 @@ public class TestTabsRecord extends TestFennecTabsStorage {
|
||||
final String positionAscending = BrowserContract.Tabs.POSITION + " ASC";
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = tabsClient.query(BrowserContract.Tabs.CONTENT_URI, null, TABS_CLIENT_GUID_IS, new String[] { TEST_CLIENT_GUID }, positionAscending);
|
||||
cursor = tabsClient.query(BrowserContractHelpers.TABS_CONTENT_URI, null, TABS_CLIENT_GUID_IS, new String[] { TEST_CLIENT_GUID }, positionAscending);
|
||||
assertEquals(3, cursor.getCount());
|
||||
|
||||
cursor.moveToPosition(1);
|
||||
@ -55,7 +56,7 @@ public class TestTabsRecord extends TestFennecTabsStorage {
|
||||
final String positionAscending = BrowserContract.Tabs.POSITION + " ASC";
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
cursor = tabsClient.query(BrowserContract.Tabs.CONTENT_URI, null, TABS_CLIENT_GUID_IS, new String[] { TEST_CLIENT_GUID }, positionAscending);
|
||||
cursor = tabsClient.query(BrowserContractHelpers.TABS_CONTENT_URI, null, TABS_CLIENT_GUID_IS, new String[] { TEST_CLIENT_GUID }, positionAscending);
|
||||
assertEquals(0, cursor.getCount());
|
||||
|
||||
final TabsRecord tabsRecord = FennecTabsRepository.tabsRecordFromCursor(cursor, TEST_CLIENT_GUID, TEST_CLIENT_NAME);
|
||||
@ -81,7 +82,7 @@ public class TestTabsRecord extends TestFennecTabsStorage {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
// Keep this in sync with the Fennec schema.
|
||||
cursor = tabsClient.query(BrowserContract.Tabs.CONTENT_URI, null, BrowserContract.Tabs.CLIENT_GUID + " IS NULL", null, positionAscending);
|
||||
cursor = tabsClient.query(BrowserContractHelpers.TABS_CONTENT_URI, null, BrowserContract.Tabs.CLIENT_GUID + " IS NULL", null, positionAscending);
|
||||
CursorDumper.dumpCursor(cursor);
|
||||
|
||||
final TabsRecord tabsRecord = FennecTabsRepository.tabsRecordFromCursor(cursor, TEST_CLIENT_GUID, TEST_CLIENT_NAME);
|
||||
|
Loading…
Reference in New Issue
Block a user