Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 344 return; | 344 return; |
| 345 } | 345 } |
| 346 } | 346 } |
| 347 | 347 |
| 348 SyncBackendHost::PendingConfigureDataTypesState:: | 348 SyncBackendHost::PendingConfigureDataTypesState:: |
| 349 PendingConfigureDataTypesState() : deleted_type(false) {} | 349 PendingConfigureDataTypesState() : deleted_type(false) {} |
| 350 | 350 |
| 351 SyncBackendHost::PendingConfigureDataTypesState:: | 351 SyncBackendHost::PendingConfigureDataTypesState:: |
| 352 ~PendingConfigureDataTypesState() {} | 352 ~PendingConfigureDataTypesState() {} |
| 353 | 353 |
| 354 /* 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.
| |
| 355 SyncBackendHost::PendingConfigureDataTypesState* | |
| 356 SyncBackendHost::GetPendingConfigModeState( | |
| 357 const DataTypeController::TypeMap& data_type_controllers, | |
| 358 const syncable::ModelTypeSet& types, | |
| 359 CancelableTask* ready_task, | |
| 360 ModelSafeRoutingInfo* routing_info) { | |
| 361 PendingConfigureDataTypesState* state = new PendingConfigureDataTypesState(); | |
| 362 | |
| 363 for (DataTypeController::TypeMap::const_iterator it = | |
| 364 data_type_controllers.begin(); | |
| 365 it != data_type_controllers.end(); ++it) { | |
| 366 syncable::ModelType type = it->first; | |
| 367 | |
| 368 // If a type is not specified, remove it from the routing_info. | |
| 369 if (types.count(type) == 0) { | |
| 370 state->deleted_type = (routing_info->erase(type) > 0); | |
| 371 } else { | |
| 372 // Add a newly specified data type as GROUP_PASSIVE into the | |
| 373 // routing_info, if it does not already exist. | |
| 374 if (routing_info->count(type) == 0) { | |
| 375 (*routing_info)[type] = GROUP_PASSIVE; | |
| 376 state->added_types.set(type); | |
| 377 } | |
| 378 } | |
| 379 } | |
| 380 | |
| 381 state->ready_task.reset(ready_task); | |
| 382 state->initial_types = types; | |
| 383 return state; | |
| 384 } | |
| 385 | |
| 354 void SyncBackendHost::ConfigureDataTypes( | 386 void SyncBackendHost::ConfigureDataTypes( |
| 355 const DataTypeController::TypeMap& data_type_controllers, | 387 const DataTypeController::TypeMap& data_type_controllers, |
| 356 const syncable::ModelTypeSet& types, | 388 const syncable::ModelTypeSet& types, |
| 357 CancelableTask* ready_task) { | 389 CancelableTask* ready_task) { |
| 358 // Only one configure is allowed at a time. | 390 // Only one configure is allowed at a time. |
| 359 DCHECK(!pending_config_mode_state_.get()); | 391 DCHECK(!pending_config_mode_state_.get()); |
| 360 DCHECK(!pending_download_state_.get()); | 392 DCHECK(!pending_download_state_.get()); |
| 361 DCHECK(syncapi_initialized_); | 393 DCHECK(syncapi_initialized_); |
| 362 | 394 |
| 363 if (types.count(syncable::AUTOFILL_PROFILE) != 0) { | 395 if (types.count(syncable::AUTOFILL_PROFILE) != 0) { |
| 364 ConfigureAutofillMigration(); | 396 ConfigureAutofillMigration(); |
| 365 } | 397 } |
| 366 | 398 |
| 367 scoped_ptr<PendingConfigureDataTypesState> state(new | |
| 368 PendingConfigureDataTypesState()); | |
| 369 | |
| 370 { | 399 { |
| 371 base::AutoLock lock(registrar_lock_); | 400 base::AutoLock lock(registrar_lock_); |
| 372 for (DataTypeController::TypeMap::const_iterator it = | 401 pending_config_mode_state_.reset( |
| 373 data_type_controllers.begin(); | 402 GetPendingConfigModeState(data_type_controllers, types, ready_task, |
| 374 it != data_type_controllers.end(); ++it) { | 403 ®istrar_.routing_info)); |
| 375 syncable::ModelType type = (*it).first; | |
| 376 | |
| 377 // If a type is not specified, remove it from the routing_info. | |
| 378 if (types.count(type) == 0) { | |
| 379 registrar_.routing_info.erase(type); | |
| 380 state->deleted_type = true; | |
| 381 } else { | |
| 382 // Add a newly specified data type as GROUP_PASSIVE into the | |
| 383 // routing_info, if it does not already exist. | |
| 384 if (registrar_.routing_info.count(type) == 0) { | |
| 385 registrar_.routing_info[type] = GROUP_PASSIVE; | |
| 386 state->added_types.set(type); | |
| 387 } | |
| 388 } | |
| 389 } | |
| 390 } | 404 } |
| 391 | 405 |
| 392 state->ready_task.reset(ready_task); | |
| 393 state->initial_types = types; | |
| 394 pending_config_mode_state_.reset(state.release()); | |
| 395 | |
| 396 // If we're doing the first configure (at startup) this is redundant as the | 406 // If we're doing the first configure (at startup) this is redundant as the |
| 397 // syncer thread always must start in config mode. | 407 // syncer thread always must start in config mode. |
| 398 if (using_new_syncer_thread_) { | 408 if (using_new_syncer_thread_) { |
| 399 core_->syncapi()->StartConfigurationMode(NewCallback(core_.get(), | 409 core_->syncapi()->StartConfigurationMode(NewCallback(core_.get(), |
| 400 &SyncBackendHost::Core::FinishConfigureDataTypes)); | 410 &SyncBackendHost::Core::FinishConfigureDataTypes)); |
| 401 } else { | 411 } else { |
| 402 FinishConfigureDataTypesOnFrontendLoop(); | 412 FinishConfigureDataTypesOnFrontendLoop(); |
| 403 } | 413 } |
| 404 } | 414 } |
| 405 | 415 |
| (...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1185 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); | 1195 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); |
| 1186 syncapi_->GetJsBackend()->ProcessMessage(name, args, sender); | 1196 syncapi_->GetJsBackend()->ProcessMessage(name, args, sender); |
| 1187 } | 1197 } |
| 1188 | 1198 |
| 1189 void SyncBackendHost::Core::DeferNudgeForCleanup() { | 1199 void SyncBackendHost::Core::DeferNudgeForCleanup() { |
| 1190 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); | 1200 DCHECK_EQ(MessageLoop::current(), host_->core_thread_.message_loop()); |
| 1191 deferred_nudge_for_cleanup_requested_ = true; | 1201 deferred_nudge_for_cleanup_requested_ = true; |
| 1192 } | 1202 } |
| 1193 | 1203 |
| 1194 } // namespace browser_sync | 1204 } // namespace browser_sync |
| OLD | NEW |