diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-12 23:47:37 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-02-12 23:47:37 +0000 |
commit | b99f548508aa6ae45b0f215cf2f8c8679c7d7cdd (patch) | |
tree | 4053c5a4da94b3d6f6366c39fae4277be806a72f /sync/engine | |
parent | cc25dd0cd7c0a18d6abe7f0dcf0f4b31e45cd3fb (diff) | |
download | chromium_src-b99f548508aa6ae45b0f215cf2f8c8679c7d7cdd.zip chromium_src-b99f548508aa6ae45b0f215cf2f8c8679c7d7cdd.tar.gz chromium_src-b99f548508aa6ae45b0f215cf2f8c8679c7d7cdd.tar.bz2 |
sync: Move migration signal out of snapshot
A sync data migration request is signalled by the server during a normal
GetUpdates or Commit request. The signal is then forwarded to the UI thread,
which actually performs the migration.
Traditionally, the signal has been sent through the SyncSessionSnapshot, which
is delivered to the UI thread at the end of the current sync cycle. This CL
introduces new code to pass the signal through the SyncSession::Delegate and
SyncManagerObserverInterfaces.
This CL should not change the syncer's behavior.
BUG=339984
Review URL: https://codereview.chromium.org/158953004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@250849 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/engine')
-rw-r--r-- | sync/engine/all_status.cc | 2 | ||||
-rw-r--r-- | sync/engine/all_status.h | 1 | ||||
-rw-r--r-- | sync/engine/sync_engine_event_listener.h | 3 | ||||
-rw-r--r-- | sync/engine/sync_scheduler_impl.cc | 6 | ||||
-rw-r--r-- | sync/engine/sync_scheduler_impl.h | 1 | ||||
-rw-r--r-- | sync/engine/syncer_proto_util.cc | 5 | ||||
-rw-r--r-- | sync/engine/syncer_unittest.cc | 2 |
7 files changed, 17 insertions, 3 deletions
diff --git a/sync/engine/all_status.cc b/sync/engine/all_status.cc index e5840f3..6fa98d3 100644 --- a/sync/engine/all_status.cc +++ b/sync/engine/all_status.cc @@ -122,6 +122,8 @@ void AllStatus::OnThrottledTypesChanged(ModelTypeSet throttled_types) { status_.throttled_types = throttled_types; } +void AllStatus::OnMigrationRequested(ModelTypeSet) {} + SyncStatus AllStatus::status() const { base::AutoLock lock(mutex_); return status_; diff --git a/sync/engine/all_status.h b/sync/engine/all_status.h index b30d2ae..add42e5 100644 --- a/sync/engine/all_status.h +++ b/sync/engine/all_status.h @@ -45,6 +45,7 @@ class AllStatus : public SyncEngineEventListener { virtual void OnActionableError(const SyncProtocolError& error) OVERRIDE; virtual void OnRetryTimeChanged(base::Time retry_time) OVERRIDE; virtual void OnThrottledTypesChanged(ModelTypeSet throttled_types) OVERRIDE; + virtual void OnMigrationRequested(ModelTypeSet types) OVERRIDE; SyncStatus status() const; diff --git a/sync/engine/sync_engine_event_listener.h b/sync/engine/sync_engine_event_listener.h index 8e5c3d5..35fc05e 100644 --- a/sync/engine/sync_engine_event_listener.h +++ b/sync/engine/sync_engine_event_listener.h @@ -33,6 +33,9 @@ class SYNC_EXPORT_PRIVATE SyncEngineEventListener { // This event is sent when types are throttled or unthrottled. virtual void OnThrottledTypesChanged(ModelTypeSet throttled_types) = 0; + // This event is sent when the server requests a migration. + virtual void OnMigrationRequested(ModelTypeSet migration_types) = 0; + protected: virtual ~SyncEngineEventListener(); }; diff --git a/sync/engine/sync_scheduler_impl.cc b/sync/engine/sync_scheduler_impl.cc index 928dff4..ddd5baa 100644 --- a/sync/engine/sync_scheduler_impl.cc +++ b/sync/engine/sync_scheduler_impl.cc @@ -908,6 +908,12 @@ void SyncSchedulerImpl::OnReceivedGuRetryDelay(const base::TimeDelta& delay) { &SyncSchedulerImpl::RetryTimerCallback); } +void SyncSchedulerImpl::OnReceivedMigrationRequest(ModelTypeSet types) { + FOR_EACH_OBSERVER(SyncEngineEventListener, + *session_context_->listeners(), + OnMigrationRequested(types)); +} + void SyncSchedulerImpl::SetNotificationsEnabled(bool notifications_enabled) { DCHECK(CalledOnValidThread()); session_context_->set_notifications_enabled(notifications_enabled); diff --git a/sync/engine/sync_scheduler_impl.h b/sync/engine/sync_scheduler_impl.h index 1c190c8..7cbf324f 100644 --- a/sync/engine/sync_scheduler_impl.h +++ b/sync/engine/sync_scheduler_impl.h @@ -90,6 +90,7 @@ class SYNC_EXPORT_PRIVATE SyncSchedulerImpl virtual void OnSyncProtocolError( const SyncProtocolError& sync_protocol_error) OVERRIDE; virtual void OnReceivedGuRetryDelay(const base::TimeDelta& delay) OVERRIDE; + virtual void OnReceivedMigrationRequest(syncer::ModelTypeSet types) OVERRIDE; // Returns true if the client is currently in exponential backoff. bool IsBackingOff() const; diff --git a/sync/engine/syncer_proto_util.cc b/sync/engine/syncer_proto_util.cc index 62fec65..d6fb8d5 100644 --- a/sync/engine/syncer_proto_util.cc +++ b/sync/engine/syncer_proto_util.cc @@ -462,9 +462,8 @@ SyncerError SyncerProtoUtil::PostClientToServerMessage( case MIGRATION_DONE: LOG_IF(ERROR, 0 >= response->migrated_data_type_id_size()) << "MIGRATION_DONE but no types specified."; - // TODO(akalin): This should be a set union. - session->mutable_status_controller()-> - set_types_needing_local_migration(GetTypesToMigrate(*response)); + session->delegate()->OnReceivedMigrationRequest( + GetTypesToMigrate(*response)); return SERVER_RETURN_MIGRATION_DONE; case CLEAR_PENDING: return SERVER_RETURN_CLEAR_PENDING; diff --git a/sync/engine/syncer_unittest.cc b/sync/engine/syncer_unittest.cc index 3cff01d..2be9dab 100644 --- a/sync/engine/syncer_unittest.cc +++ b/sync/engine/syncer_unittest.cc @@ -151,6 +151,7 @@ class SyncerTest : public testing::Test, last_client_invalidation_hint_buffer_size_ = size; } virtual void OnReceivedGuRetryDelay(const base::TimeDelta& delay) OVERRIDE {} + virtual void OnReceivedMigrationRequest(ModelTypeSet types) OVERRIDE {} virtual void OnSyncProtocolError(const SyncProtocolError& error) OVERRIDE {} void GetModelSafeRoutingInfo(ModelSafeRoutingInfo* out) { @@ -179,6 +180,7 @@ class SyncerTest : public testing::Test, virtual void OnActionableError(const SyncProtocolError& error) OVERRIDE {} virtual void OnRetryTimeChanged(base::Time retry_time) OVERRIDE {} virtual void OnThrottledTypesChanged(ModelTypeSet throttled_types) OVERRIDE {} + virtual void OnMigrationRequested(ModelTypeSet types) OVERRIDE {} void ResetSession() { session_.reset(SyncSession::Build(context_.get(), this)); |