Commit b1f033a4 authored by Jan Krcal's avatar Jan Krcal Committed by Commit Bot

[PSS] Make the sync-requested pref false while stopping (and clearing)

This CL makes sure the sync-requested pref is set to false while the
individual data types are being stopped. This is needed by the Directory
version of the Wallet DTC (as revealed by a sync integration test for
wallet data Directory implementation that was temporarily disabled while
PSS code has changed).

Bug: 853688
Change-Id: If738c13ad1d8c8fe82439f47f6127508e7155a85
Reviewed-on: https://chromium-review.googlesource.com/c/1433624
Commit-Queue: Jan Krcal <jkrcal@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#625759}
parent 9abc0f76
......@@ -192,6 +192,7 @@ ProfileSyncService::ProfileSyncService(InitParams init_params)
std::make_unique<syncer::HttpBridgeNetworkResources>()),
start_behavior_(init_params.start_behavior),
passphrase_prompt_triggered_by_version_(false),
is_stopping_and_clearing_(false),
sync_enabled_weak_factory_(this),
weak_factory_(this) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
......@@ -1674,7 +1675,12 @@ void ProfileSyncService::OnSyncRequestedPrefChange(bool is_sync_requested) {
}
} else {
// This will notify the observers.
StopImpl(KEEP_DATA);
if (is_stopping_and_clearing_) {
is_stopping_and_clearing_ = false;
StopImpl(CLEAR_DATA);
} else {
StopImpl(KEEP_DATA);
}
// TODO(crbug.com/856179): Evaluate whether we can get away without a full
// restart (i.e. just reconfigure plus whatever cleanup is necessary).
......@@ -1912,7 +1918,11 @@ bool ProfileSyncService::IsSyncAllowedByFlag() {
void ProfileSyncService::StopAndClear() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
StopImpl(CLEAR_DATA);
DCHECK(!is_stopping_and_clearing_);
// We need to remember that clearing of data is needed when sync will be
// stopped. This flag is cleared in OnSyncRequestedPrefChange() where sync
// gets stopped.
is_stopping_and_clearing_ = true;
user_settings_->SetSyncRequested(false);
}
......
......@@ -634,6 +634,10 @@ class ProfileSyncService : public syncer::SyncService,
// IsPassphrasePrompted sync preference.
bool passphrase_prompt_triggered_by_version_;
// Used by StopAndClear() to remember that clearing of data is needed (as
// sync is stopped after a callback from |user_settings_|).
bool is_stopping_and_clearing_;
// This weak factory invalidates its issued pointers when Sync is disabled.
base::WeakPtrFactory<ProfileSyncService> sync_enabled_weak_factory_;
......
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