From 0605da33e7fb70d21ffbf4537ddddee70dbecc78 Mon Sep 17 00:00:00 2001 From: Nick Alexander Date: Mon, 26 May 2014 10:06:11 -0700 Subject: [PATCH] Bug 1014150 - Sync clients and tabs when refreshing Remote Tabs and when Sending Tab to Device. r=rnewman Both collections impact the state of your remote tabs, so we should update both when we want your tabs. --- .../sync/setup/activities/SendTabActivity.java | 18 ++++++++++-------- .../sync/stage/SyncClientsEngineStage.java | 2 ++ .../tabspanel/RemoteTabsContainerPanel.java | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/mobile/android/base/sync/setup/activities/SendTabActivity.java b/mobile/android/base/sync/setup/activities/SendTabActivity.java index c2f5dafce9e2..e35cae344362 100644 --- a/mobile/android/base/sync/setup/activities/SendTabActivity.java +++ b/mobile/android/base/sync/setup/activities/SendTabActivity.java @@ -25,6 +25,8 @@ import org.mozilla.gecko.sync.SyncConfiguration; import org.mozilla.gecko.sync.SyncConstants; import org.mozilla.gecko.sync.repositories.NullCursorException; import org.mozilla.gecko.sync.repositories.android.ClientsDatabaseAccessor; +import org.mozilla.gecko.sync.repositories.android.FennecTabsRepository; +import org.mozilla.gecko.sync.repositories.android.FennecTabsRepository.FennecTabsRepositorySession; import org.mozilla.gecko.sync.repositories.domain.ClientRecord; import org.mozilla.gecko.sync.setup.SyncAccounts; import org.mozilla.gecko.sync.setup.activities.LocaleAware.LocaleAwareActivity; @@ -46,7 +48,7 @@ import android.widget.Toast; public class SendTabActivity extends LocaleAwareActivity { private interface TabSender { - static final String[] CLIENTS_STAGE = new String[] { SyncClientsEngineStage.COLLECTION_NAME }; + public static final String[] STAGES_TO_SYNC = new String[] { "clients", "tabs" }; /** * @return Return null if the account isn't correctly initialized. Return @@ -55,9 +57,9 @@ public class SendTabActivity extends LocaleAwareActivity { String getAccountGUID(); /** - * Sync this account, specifying only clients as the engine to sync. + * Sync this account, specifying only clients and tabs as the engines to sync. */ - void syncClientsStage(); + void sync(); } private static class FxAccountTabSender implements TabSender { @@ -79,8 +81,8 @@ public class SendTabActivity extends LocaleAwareActivity { } @Override - public void syncClientsStage() { - fxAccount.requestSync(FirefoxAccounts.FORCE, CLIENTS_STAGE, null); + public void sync() { + fxAccount.requestSync(FirefoxAccounts.FORCE, STAGES_TO_SYNC, null); } } @@ -107,8 +109,8 @@ public class SendTabActivity extends LocaleAwareActivity { } @Override - public void syncClientsStage() { - SyncAdapter.requestImmediateSync(this.account, CLIENTS_STAGE); + public void sync() { + SyncAdapter.requestImmediateSync(this.account, STAGES_TO_SYNC); } } @@ -302,7 +304,7 @@ public class SendTabActivity extends LocaleAwareActivity { } Logger.info(LOG_TAG, "Requesting immediate clients stage sync."); - sender.syncClientsStage(); + sender.sync(); return true; } diff --git a/mobile/android/base/sync/stage/SyncClientsEngineStage.java b/mobile/android/base/sync/stage/SyncClientsEngineStage.java index a4a66cb35d36..3fd9a4d8d89b 100644 --- a/mobile/android/base/sync/stage/SyncClientsEngineStage.java +++ b/mobile/android/base/sync/stage/SyncClientsEngineStage.java @@ -319,7 +319,9 @@ public class SyncClientsEngineStage extends AbstractSessionManagingSyncStage { // We can be disabled just for this sync. boolean enabledThisSync = session.isEngineLocallyEnabled(STAGE_NAME); if (!enabledThisSync) { + // These log messages look best when they match the messages in ServerSyncStage. Logger.debug(LOG_TAG, "Stage " + STAGE_NAME + " disabled just for this sync."); + Logger.info(LOG_TAG, "Skipping stage " + STAGE_NAME + "."); session.advance(); return; } diff --git a/mobile/android/base/tabspanel/RemoteTabsContainerPanel.java b/mobile/android/base/tabspanel/RemoteTabsContainerPanel.java index ace65130a344..ae09d36084e5 100644 --- a/mobile/android/base/tabspanel/RemoteTabsContainerPanel.java +++ b/mobile/android/base/tabspanel/RemoteTabsContainerPanel.java @@ -28,7 +28,7 @@ import android.view.ViewGroup; */ public class RemoteTabsContainerPanel extends GeckoSwipeRefreshLayout implements TabsPanel.PanelView { - private static final String[] STAGES_TO_SYNC_ON_REFRESH = new String[] { "tabs" }; + private static final String[] STAGES_TO_SYNC_ON_REFRESH = new String[] { "clients", "tabs" }; /** * Refresh indicators (the swipe-to-refresh "laser show" and the spinning