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

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: Add TODO 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 302724f2e499733c71eca1d57c3e6155c201278a..7d69997c3544be8658a07077be443a6738841ad5 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 */
tim (not reviewing) 2011/04/05 04:56:01 style typically "// static" Also, I'd call this '
akalin 2011/04/05 09:55:45 Done.
+SyncBackendHost::PendingConfigureDataTypesState*
+ SyncBackendHost::GetPendingConfigModeState(
+ 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);
+ } 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(
+ GetPendingConfigModeState(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_) {

Powered by Google App Engine
This is Rietveld 408576698