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

Unified Diff: sync/internal_api/sync_manager_impl.cc

Issue 10829086: Reland 148792 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/syncapi_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/internal_api/sync_manager_impl.cc
diff --git a/sync/internal_api/sync_manager_impl.cc b/sync/internal_api/sync_manager_impl.cc
index 24d614e84438ea13711c6717fcd5d47b92ee3d09..7e173d15fa2f7de34acda28501b7d6db394abba1 100644
--- a/sync/internal_api/sync_manager_impl.cc
+++ b/sync/internal_api/sync_manager_impl.cc
@@ -338,6 +338,19 @@ void SyncManagerImpl::ConfigureSyncer(
DCHECK(!ready_task.is_null());
DCHECK(!retry_task.is_null());
+ // Cleanup any types that might have just been disabled.
+ ModelTypeSet previous_types = ModelTypeSet::All();
+ if (!session_context_->routing_info().empty())
+ previous_types = GetRoutingInfoTypes(session_context_->routing_info());
+ if (!PurgeDisabledTypes(previous_types,
+ GetRoutingInfoTypes(new_routing_info))) {
+ // We failed to cleanup the types. Invoke the ready task without actually
+ // configuring any types. The caller should detect this as a configuration
+ // failure and act appropriately.
+ ready_task.Run();
+ return;
+ }
+
// TODO(zea): set this based on whether cryptographer has keystore
// encryption key or not (requires opening a transaction). crbug.com/129665.
ConfigurationParams::KeystoreKeyStatus keystore_key_status =
@@ -689,6 +702,19 @@ bool SyncManagerImpl::PurgePartiallySyncedTypes() {
return directory()->PurgeEntriesWithTypeIn(partially_synced_types);
}
+bool SyncManagerImpl::PurgeDisabledTypes(
+ ModelTypeSet previously_enabled_types,
+ ModelTypeSet currently_enabled_types) {
+ ModelTypeSet disabled_types = Difference(previously_enabled_types,
+ currently_enabled_types);
+ if (disabled_types.Empty())
+ return true;
+
+ DVLOG(1) << "Purging disabled types "
+ << ModelTypeSetToString(disabled_types);
+ return directory()->PurgeEntriesWithTypeIn(disabled_types);
+}
+
void SyncManagerImpl::UpdateCredentials(
const SyncCredentials& credentials) {
DCHECK(thread_checker_.CalledOnValidThread());
« no previous file with comments | « sync/internal_api/sync_manager_impl.h ('k') | sync/internal_api/syncapi_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698