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

Unified Diff: components/sync/device_info/device_info_service.cc

Issue 2455693002: [Sync] On disabling sync, device info records are removed. (Closed)
Patch Set: Updates for Max. Created 4 years, 2 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
Index: components/sync/device_info/device_info_service.cc
diff --git a/components/sync/device_info/device_info_service.cc b/components/sync/device_info/device_info_service.cc
index a5fb849eb0e5e0b6dc3fbe586a0ffa75b38136ce..12403981068cf94ffc01537e1943ce26fa37a9f1 100644
--- a/components/sync/device_info/device_info_service.cc
+++ b/components/sync/device_info/device_info_service.cc
@@ -180,6 +180,31 @@ std::string DeviceInfoService::GetStorageKey(const EntityData& entity_data) {
return entity_data.specifics.device_info().cache_guid();
}
+void DeviceInfoService::DisableSync() {
+ // TODO(skym, crbug.com/659263): Would it be reasonable to pulse_timer_.Stop()
+ // or subscription_.reset() here?
+
+ // Allow deletion of metadata to happen before the deletion of data below. If
+ // we crash after removing metadata but not regular data, then merge can
+ // handle pairing everything back up.
+ ModelTypeService::DisableSync();
+
+ // Remove all local data, if sync is being disabled, the user has expressed
+ // their desire to not have knowledge about other devices.
+ if (!all_data_.empty()) {
+ std::unique_ptr<WriteBatch> batch = store_->CreateWriteBatch();
+ for (const auto& kv : all_data_) {
+ store_->DeleteData(batch.get(), kv.first);
+ }
+ store_->CommitWriteBatch(
+ std::move(batch),
+ base::Bind(&DeviceInfoService::OnCommit, base::AsWeakPtr(this)));
+
+ all_data_.clear();
+ NotifyObservers();
+ }
+}
+
bool DeviceInfoService::IsSyncing() const {
return !all_data_.empty();
}
« no previous file with comments | « components/sync/device_info/device_info_service.h ('k') | components/sync/device_info/device_info_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698