Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4260)

Unified Diff: chrome/browser/sync/profile_sync_service_harness.h

Issue 7655055: [Sync] Make BackendMigrator not wait for full sync cycles (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address more comments Created 9 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | chrome/browser/sync/profile_sync_service_harness.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/sync/profile_sync_service_harness.h
diff --git a/chrome/browser/sync/profile_sync_service_harness.h b/chrome/browser/sync/profile_sync_service_harness.h
index 5ec8a444deb00c7ee0e4e9d85378ca9423dc605f..fcaa603d9d2b463ee2598e706e993b312148ff46 100644
--- a/chrome/browser/sync/profile_sync_service_harness.h
+++ b/chrome/browser/sync/profile_sync_service_harness.h
@@ -10,6 +10,8 @@
#include <vector>
#include "base/basictypes.h"
+#include "base/compiler_specific.h"
+#include "chrome/browser/sync/backend_migrator.h"
#include "chrome/browser/sync/profile_sync_service.h"
#include "chrome/browser/sync/profile_sync_service_observer.h"
#include "chrome/browser/sync/retry_verifier.h"
@@ -28,7 +30,9 @@ namespace browser_sync {
// profile passed to it on construction and automates certain things like setup
// and authentication. It provides ways to "wait" adequate periods of time for
// several clients to get to the same state.
-class ProfileSyncServiceHarness : public ProfileSyncServiceObserver {
+class ProfileSyncServiceHarness
+ : public ProfileSyncServiceObserver,
+ public browser_sync::MigrationObserver {
public:
ProfileSyncServiceHarness(Profile* profile,
const std::string& username,
@@ -58,7 +62,10 @@ class ProfileSyncServiceHarness : public ProfileSyncServiceObserver {
bool SetupSync(const syncable::ModelTypeSet& synced_datatypes);
// ProfileSyncServiceObserver implementation.
- virtual void OnStateChanged();
+ virtual void OnStateChanged() OVERRIDE;
+
+ // MigrationObserver implementation.
+ virtual void OnMigrationStateChange() OVERRIDE;
// Blocks the caller until the sync backend host associated with this harness
// has been initialized. Returns true if the wait was successful.
@@ -73,15 +80,6 @@ class ProfileSyncServiceHarness : public ProfileSyncServiceObserver {
// since the previous one. Returns true if a sync cycle has completed.
bool AwaitSyncCycleCompletion(const std::string& reason);
- // Blocks the caller until this harness has completed a single sync
- // cycle, even if we're already synced. Returns true if a sync
- // cycle has completed.
- //
- // TODO(akalin): This is only used by some migration tests, pending
- // the fix for http://crbug.com/92928. Remove this once that is
- // fixed.
- bool AwaitNextSyncCycleCompletion(const std::string& reason);
-
// Blocks the caller until the sync has been disabled for this client. Returns
// true if sync is disabled.
bool AwaitSyncDisabled(const std::string& reason);
@@ -89,6 +87,9 @@ class ProfileSyncServiceHarness : public ProfileSyncServiceObserver {
// Blocks the caller until exponential backoff has been verified to happen.
bool AwaitExponentialBackoffVerification();
+ // Blocks until the given set of data types are migrated.
+ bool AwaitMigration(const syncable::ModelTypeSet& expected_migrated_types);
+
// Blocks the caller until this harness has observed that the sync engine
// has downloaded all the changes seen by the |partner| harness's client.
bool WaitUntilTimestampMatches(
@@ -213,6 +214,12 @@ class ProfileSyncServiceHarness : public ProfileSyncServiceObserver {
// backoffs are triggered correctly.
WAITING_FOR_EXPONENTIAL_BACKOFF_VERIFICATION,
+ // The sync client is waiting for migration to start.
+ WAITING_FOR_MIGRATION_TO_START,
+
+ // The sync client is waiting for migration to finish.
+ WAITING_FOR_MIGRATION_TO_FINISH,
+
// The client verification is complete. We don't care about the state of
// the syncer any more.
WAITING_FOR_NOTHING,
@@ -232,6 +239,11 @@ class ProfileSyncServiceHarness : public ProfileSyncServiceObserver {
NUMBER_OF_STATES,
};
+ // Listen to migration events if the migrator has been initialized
+ // and we're not already listening. Returns true if we started
+ // listening.
+ bool TryListeningToMigrationEvents();
+
// Called from the observer when the current wait state has been completed.
void SignalStateCompleteWithNextState(WaitState next_state);
@@ -246,13 +258,12 @@ class ProfileSyncServiceHarness : public ProfileSyncServiceObserver {
bool AwaitStatusChangeWithTimeout(int timeout_milliseconds,
const std::string& reason);
- // Used by AwaitSyncCycleCompletion() and
- // AwaitNextSyncCycleCompletion().
- bool AwaitSyncCycleCompletionHelper(const std::string& reason);
-
// Returns true if the sync client has no unsynced items.
bool IsSynced();
+ // Returns true if there is a backend migration in progress.
+ bool HasPendingBackendMigration();
+
// Returns true if this client has downloaded all the items that the
// other client has.
bool MatchesOtherClient(ProfileSyncServiceHarness* partner);
@@ -290,6 +301,14 @@ class ProfileSyncServiceHarness : public ProfileSyncServiceObserver {
std::string username_;
std::string password_;
+ // The current set of data types pending migration. Used by
+ // AwaitMigration().
+ syncable::ModelTypeSet pending_migration_types_;
+
+ // The set of data types that have undergone migration. Used by
+ // AwaitMigration().
+ syncable::ModelTypeSet migrated_types_;
+
// Used for logging.
const std::string profile_debug_name_;
« no previous file with comments | « chrome/browser/sync/profile_sync_service.cc ('k') | chrome/browser/sync/profile_sync_service_harness.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698