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

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

Issue 6764024: [Sync] Fix ConfigureDataTypes bug that leads to extra nudge (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments Created 9 years, 9 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/sync_backend_host.cc
diff --git a/chrome/browser/sync/glue/sync_backend_host.cc b/chrome/browser/sync/glue/sync_backend_host.cc
index a69a12cdbac458162891c573f7d577a9848088a3..fe6e1b3384e9a99ef3f5cad318b0228fcfc6a25b 100644
--- a/chrome/browser/sync/glue/sync_backend_host.cc
+++ b/chrome/browser/sync/glue/sync_backend_host.cc
@@ -351,6 +351,38 @@ PendingConfigureDataTypesState() : deleted_type(false) {}
SyncBackendHost::PendingConfigureDataTypesState::
~PendingConfigureDataTypesState() {}
+// static
+SyncBackendHost::PendingConfigureDataTypesState*
+ SyncBackendHost::MakePendingConfigModeState(
+ const DataTypeController::TypeMap& data_type_controllers,
+ const syncable::ModelTypeSet& types,
+ CancelableTask* ready_task,
+ ModelSafeRoutingInfo* routing_info) {
+ PendingConfigureDataTypesState* state = new PendingConfigureDataTypesState();
+
+ for (DataTypeController::TypeMap::const_iterator it =
+ data_type_controllers.begin();
+ it != data_type_controllers.end(); ++it) {
+ syncable::ModelType type = it->first;
+
+ // If a type is not specified, remove it from the routing_info.
+ if (types.count(type) == 0) {
+ state->deleted_type = (routing_info->erase(type) > 0);
tim (not reviewing) 2011/04/19 18:07:05 this line is wrong. we need to just set deleted_t
+ } else {
+ // Add a newly specified data type as GROUP_PASSIVE into the
+ // routing_info, if it does not already exist.
+ if (routing_info->count(type) == 0) {
+ (*routing_info)[type] = GROUP_PASSIVE;
+ state->added_types.set(type);
+ }
+ }
+ }
+
+ state->ready_task.reset(ready_task);
+ state->initial_types = types;
+ return state;
+}
+
void SyncBackendHost::ConfigureDataTypes(
const DataTypeController::TypeMap& data_type_controllers,
const syncable::ModelTypeSet& types,
@@ -364,35 +396,13 @@ void SyncBackendHost::ConfigureDataTypes(
ConfigureAutofillMigration();
}
- scoped_ptr<PendingConfigureDataTypesState> state(new
- PendingConfigureDataTypesState());
-
{
base::AutoLock lock(registrar_lock_);
- for (DataTypeController::TypeMap::const_iterator it =
- data_type_controllers.begin();
- it != data_type_controllers.end(); ++it) {
- syncable::ModelType type = (*it).first;
-
- // If a type is not specified, remove it from the routing_info.
- if (types.count(type) == 0) {
- registrar_.routing_info.erase(type);
- state->deleted_type = true;
- } else {
- // Add a newly specified data type as GROUP_PASSIVE into the
- // routing_info, if it does not already exist.
- if (registrar_.routing_info.count(type) == 0) {
- registrar_.routing_info[type] = GROUP_PASSIVE;
- state->added_types.set(type);
- }
- }
- }
+ pending_config_mode_state_.reset(
+ MakePendingConfigModeState(data_type_controllers, types, ready_task,
+ &registrar_.routing_info));
}
- state->ready_task.reset(ready_task);
- state->initial_types = types;
- pending_config_mode_state_.reset(state.release());
-
// If we're doing the first configure (at startup) this is redundant as the
// syncer thread always must start in config mode.
if (using_new_syncer_thread_) {
« no previous file with comments | « chrome/browser/sync/glue/sync_backend_host.h ('k') | chrome/browser/sync/glue/sync_backend_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698