Chromium Code Reviews| Index: components/sync_driver/data_type_manager_impl.cc |
| diff --git a/components/sync_driver/data_type_manager_impl.cc b/components/sync_driver/data_type_manager_impl.cc |
| index 1d4a96e77e5a41395aef6d2ed27c39c378a0d158..aa2a94cccf21f588e61efe819a487cfbc97eaec5 100644 |
| --- a/components/sync_driver/data_type_manager_impl.cc |
| +++ b/components/sync_driver/data_type_manager_impl.cc |
| @@ -83,8 +83,26 @@ void DataTypeManagerImpl::Configure(syncer::ModelTypeSet desired_types, |
| syncer::ModelTypeSet filtered_desired_types; |
| for (syncer::ModelTypeSet::Iterator type = desired_types.First(); |
| type.Good(); type.Inc()) { |
| + DataTypeController::TypeMap::const_iterator iter = |
| + controllers_->find(type.Get()); |
| if (syncer::IsControlType(type.Get()) || |
| - controllers_->find(type.Get()) != controllers_->end()) { |
| + iter != controllers_->end()) { |
| + if (iter != controllers_->end()) { |
| + if (!iter->second->ReadyForStart()) { |
| + // Add the type to the unready types set to prevent purging it. It's |
| + // up to the datatype controller to, if necessary, explicitly |
| + // mark the type as broken to trigger a purge. |
| + syncer::SyncError error(FROM_HERE, |
| + syncer::SyncError::UNREADY_ERROR, |
| + "Datatype not ready at config time.", |
| + type.Get()); |
| + std::map<syncer::ModelType, syncer::SyncError> errors; |
| + errors[type.Get()] = error; |
| + failed_data_types_handler_->UpdateFailedDataTypes(errors); |
| + } else { |
| + failed_data_types_handler_->ResetUnreadyErrorFor(type.Get()); |
| + } |
| + } |
| filtered_desired_types.Put(type.Get()); |
| } |
| } |
| @@ -111,19 +129,9 @@ void DataTypeManagerImpl::ConfigureImpl( |
| return; |
| } |
| - if (state_ == CONFIGURED && |
| - last_requested_types_.Equals(desired_types) && |
| - reason == syncer::CONFIGURE_REASON_RECONFIGURATION && |
| - syncer::Intersection(failed_data_types_handler_->GetFailedTypes(), |
| - last_requested_types_).Empty()) { |
| - // If the set of enabled types hasn't changed and there are no failing |
| - // types, we can exit out early. |
| - DVLOG(1) << "Reconfigure with same types, bypassing confguration."; |
| - NotifyStart(); |
| - ConfigureResult result(OK, last_requested_types_); |
| - NotifyDone(result); |
| - return; |
| - } |
| + // TODO(zea): consider not performing a full configuration once there's a |
| + // reliable way to determine if the requested set of enabled types matches the |
| + // current set. |
| last_requested_types_ = desired_types; |
| last_configure_reason_ = reason; |
| @@ -141,18 +149,21 @@ void DataTypeManagerImpl::ConfigureImpl( |
| BackendDataTypeConfigurer::DataTypeConfigStateMap |
| DataTypeManagerImpl::BuildDataTypeConfigStateMap( |
| const syncer::ModelTypeSet& types_being_configured) const { |
| - // 1. Get the failed types (both due to fatal and crypto errors). |
| + // 1. Get the failed types (due to fatal, crypto, and unready errors). |
| // 2. Add the difference between last_requested_types_ and the failed types |
| // as CONFIGURE_INACTIVE. |
| // 3. Flip |types_being_configured| to CONFIGURE_ACTIVE. |
| // 4. Set non-enabled user types as DISABLED. |
| // 5. Set the fatal and crypto types to their respective states. |
| + // 6. Add the unready types to CONFIGURE_INACTIVE |
| syncer::ModelTypeSet error_types = |
| failed_data_types_handler_->GetFailedTypes(); |
| syncer::ModelTypeSet fatal_types = |
| failed_data_types_handler_->GetFatalErrorTypes(); |
| syncer::ModelTypeSet crypto_types = |
| failed_data_types_handler_->GetCryptoErrorTypes(); |
| + syncer::ModelTypeSet unready_types= |
| + failed_data_types_handler_->GetUnreadyErrorTypes(); |
| // Types with persistence errors are only purged/resynced when they're |
| // actively being configured. |
| @@ -160,6 +171,9 @@ DataTypeManagerImpl::BuildDataTypeConfigStateMap( |
| failed_data_types_handler_->GetPersistenceErrorTypes(); |
| persistence_types.RetainAll(types_being_configured); |
| + // Types with unready errors do not count as unready if they've been disabled. |
| + unready_types.RetainAll(last_requested_types_); |
| + |
| syncer::ModelTypeSet enabled_types = last_requested_types_; |
| enabled_types.RemoveAll(error_types); |
| syncer::ModelTypeSet disabled_types = |
| @@ -191,6 +205,9 @@ DataTypeManagerImpl::BuildDataTypeConfigStateMap( |
| BackendDataTypeConfigurer::SetDataTypesState( |
| BackendDataTypeConfigurer::CRYPTO, crypto_types, |
| &config_state_map); |
| + BackendDataTypeConfigurer::SetDataTypesState( |
| + BackendDataTypeConfigurer::UNREADY, unready_types, |
|
haitaol1
2014/06/19 18:14:35
This is different form the comment #6 above.
Nicolas Zea
2014/06/19 21:13:02
Done.
|
| + &config_state_map); |
| return config_state_map; |
| } |