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

Unified Diff: components/sync_driver/data_type_manager_impl.cc

Issue 312163004: [Sync] Add support for dynamically enabling/disabling types (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 6 years, 6 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: 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..e6491644022f349e3337fea2d04a5937d6dcaad8 100644
--- a/components/sync_driver/data_type_manager_impl.cc
+++ b/components/sync_driver/data_type_manager_impl.cc
@@ -83,8 +83,24 @@ 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 the controller itself is not ready, don't attempt to enable it.
+ if (iter != controllers_->end() && !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.",
+ type.Get());
+ std::map<syncer::ModelType, syncer::SyncError> errors;
+ errors[type.Get()] = error;
+ failed_data_types_handler_->UpdateFailedDataTypes(errors);
stanisc 2014/06/10 21:21:42 Consider adding an overload for UpdateFailedDataTy
Nicolas Zea 2014/06/19 00:04:22 I'd like to avoid that for this patch. I plan on r
+ continue;
+ }
filtered_desired_types.Put(type.Get());
}
}
@@ -111,19 +127,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;
@@ -147,12 +153,15 @@ DataTypeManagerImpl::BuildDataTypeConfigStateMap(
// 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.
@@ -174,7 +183,8 @@ DataTypeManagerImpl::BuildDataTypeConfigStateMap(
BackendDataTypeConfigurer::DataTypeConfigStateMap config_state_map;
BackendDataTypeConfigurer::SetDataTypesState(
- BackendDataTypeConfigurer::CONFIGURE_INACTIVE, enabled_types,
+ BackendDataTypeConfigurer::CONFIGURE_INACTIVE,
+ syncer::Union(enabled_types, unready_types),
&config_state_map);
BackendDataTypeConfigurer::SetDataTypesState(
BackendDataTypeConfigurer::CONFIGURE_ACTIVE, to_configure,

Powered by Google App Engine
This is Rietveld 408576698