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

Unified Diff: chrome/browser/sync/glue/data_type_manager_impl.cc

Issue 7511004: [Sync] Refactor data type configuration/activation/deactivation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix tests, address comments Created 9 years, 4 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: chrome/browser/sync/glue/data_type_manager_impl.cc
diff --git a/chrome/browser/sync/glue/data_type_manager_impl.cc b/chrome/browser/sync/glue/data_type_manager_impl.cc
index 4a957e6651316babf42d6f4465f9217f62299fd0..fed43192061cc454bff3bfb6470be044951c8ee5 100644
--- a/chrome/browser/sync/glue/data_type_manager_impl.cc
+++ b/chrome/browser/sync/glue/data_type_manager_impl.cc
@@ -209,9 +209,26 @@ void DataTypeManagerImpl::Restart(sync_api::ConfigureReason reason,
// Tell the backend about the new set of data types we wish to sync.
// The task will be invoked when updates are downloaded.
state_ = DOWNLOAD_PENDING;
+ // Hopefully http://crbug.com/79970 will make this less verbose.
+ syncable::ModelTypeSet all_types;
+ const syncable::ModelTypeSet& types_to_add = last_requested_types_;
+ syncable::ModelTypeSet types_to_remove;
+ for (DataTypeController::TypeMap::const_iterator it =
+ controllers_.begin(); it != controllers_.end(); ++it) {
+ all_types.insert(it->first);
+ }
+ // Check that types_to_add \subseteq all_types.
+ DCHECK(std::includes(all_types.begin(), all_types.end(),
+ types_to_add.begin(), types_to_add.end()));
+ // Set types_to_remove to all_types \setminus types_to_add.
+ ignore_result(
+ std::set_difference(
+ all_types.begin(), all_types.end(),
+ types_to_add.begin(), types_to_add.end(),
+ std::inserter(types_to_remove, types_to_remove.end())));
backend_->ConfigureDataTypes(
- controllers_,
- last_requested_types_,
+ types_to_add,
+ types_to_remove,
reason,
base::Bind(&DataTypeManagerImpl::DownloadReady,
weak_ptr_factory_.GetWeakPtr()),

Powered by Google App Engine
This is Rietveld 408576698