Commit dda4ed23 authored by Maksim Moskvitin's avatar Maksim Moskvitin Committed by Commit Bot

[StopSyncInPausedState] Clear UserEvent data when sync is stopped

With disabled kStopSyncInPausedState UserEvent data isn't recorded due
to UserEventModelTypeController::GetPreconditionState(), but it doesn't
work if sync completely stopped.

This CL adds UserEventModelTypeController::Stop() similar to what we
have for autofill datatypes, which treats STOP_SYNC as DISABLE_SYNC.

The behavior already covered by
SingleClientUserEventsSyncTest.ShouldNotUploadInSyncPausedState.

Bug: 906995
Change-Id: I2a3e68ca91082a6933ca3bf673d225a9f93ceaa1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2091491Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Maksim Moskvitin <mmoskvitin@google.com>
Cr-Commit-Position: refs/heads/master@{#748182}
parent 9da8a3b5
......@@ -28,12 +28,28 @@ UserEventModelTypeController::~UserEventModelTypeController() {
sync_service_->RemoveObserver(this);
}
void UserEventModelTypeController::Stop(syncer::ShutdownReason shutdown_reason,
StopCallback callback) {
DCHECK(CalledOnValidThread());
switch (shutdown_reason) {
case syncer::STOP_SYNC:
// Special case: For USER_EVENT, we want to clear all data even when Sync
// is stopped temporarily.
shutdown_reason = syncer::DISABLE_SYNC;
break;
case syncer::DISABLE_SYNC:
case syncer::BROWSER_SHUTDOWN:
break;
}
ModelTypeController::Stop(shutdown_reason, std::move(callback));
}
DataTypeController::PreconditionState
UserEventModelTypeController::GetPreconditionState() const {
if (sync_service_->GetUserSettings()->IsUsingSecondaryPassphrase()) {
return PreconditionState::kMustStopAndClearData;
}
// TODO(crbug.com/906995): Remove the syncer::IsWebSignout() check once we
// TODO(crbug.com/938819): Remove the syncer::IsWebSignout() check once we
// stop sync in this state. Also remove the "+google_apis/gaia" include
// dependency and the "//google_apis" build dependency of sync_user_events.
if (syncer::IsWebSignout(sync_service_->GetAuthError())) {
......
......@@ -25,6 +25,7 @@ class UserEventModelTypeController : public syncer::ModelTypeController,
~UserEventModelTypeController() override;
// syncer::DataTypeController implementation.
void Stop(ShutdownReason shutdown_reason, StopCallback callback) override;
PreconditionState GetPreconditionState() const override;
// syncer::SyncServiceObserver implementation.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment