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 |
similarity index 90% |
rename from components/sync_driver/data_type_manager_impl.cc |
rename to components/sync/driver/data_type_manager_impl.cc |
index 9d2033c3e3fe82a79a1cca97727f694590664bda..56df36787c8f083369102e46ed517ceeee1f2b76 100644 |
--- a/components/sync_driver/data_type_manager_impl.cc |
+++ b/components/sync/driver/data_type_manager_impl.cc |
@@ -2,7 +2,7 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "components/sync_driver/data_type_manager_impl.h" |
+#include "components/sync/driver/data_type_manager_impl.h" |
#include <algorithm> |
#include <functional> |
@@ -17,24 +17,21 @@ |
#include "base/strings/stringprintf.h" |
#include "base/trace_event/trace_event.h" |
#include "components/sync/core/data_type_debug_info_listener.h" |
-#include "components/sync_driver/data_type_encryption_handler.h" |
-#include "components/sync_driver/data_type_manager_observer.h" |
-#include "components/sync_driver/data_type_status_table.h" |
+#include "components/sync/driver/data_type_encryption_handler.h" |
+#include "components/sync/driver/data_type_manager_observer.h" |
+#include "components/sync/driver/data_type_status_table.h" |
namespace sync_driver { |
namespace { |
-DataTypeStatusTable::TypeErrorMap |
-GenerateCryptoErrorsForTypes(syncer::ModelTypeSet encrypted_types) { |
+DataTypeStatusTable::TypeErrorMap GenerateCryptoErrorsForTypes( |
+ syncer::ModelTypeSet encrypted_types) { |
DataTypeStatusTable::TypeErrorMap crypto_errors; |
for (syncer::ModelTypeSet::Iterator iter = encrypted_types.First(); |
- iter.Good(); iter.Inc()) { |
+ iter.Good(); iter.Inc()) { |
crypto_errors[iter.Get()] = syncer::SyncError( |
- FROM_HERE, |
- syncer::SyncError::CRYPTO_ERROR, |
- "", |
- iter.Get()); |
+ FROM_HERE, syncer::SyncError::CRYPTO_ERROR, "", iter.Get()); |
} |
return crypto_errors; |
} |
@@ -83,20 +80,18 @@ void DataTypeManagerImpl::Configure(syncer::ModelTypeSet desired_types, |
// Only allow control types and types that have controllers. |
syncer::ModelTypeSet filtered_desired_types; |
- for (syncer::ModelTypeSet::Iterator type = desired_types.First(); |
- type.Good(); type.Inc()) { |
+ 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()) || iter != controllers_->end()) { |
if (iter != controllers_->end()) { |
if (!iter->second->ReadyForStart() && |
- !data_type_status_table_.GetUnreadyErrorTypes().Has( |
- type.Get())) { |
+ !data_type_status_table_.GetUnreadyErrorTypes().Has(type.Get())) { |
// 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, |
+ syncer::SyncError error(FROM_HERE, syncer::SyncError::UNREADY_ERROR, |
"Datatype not ready at config time.", |
type.Get()); |
std::map<syncer::ModelType, syncer::SyncError> errors; |
@@ -138,14 +133,13 @@ void DataTypeManagerImpl::ResetDataTypeErrors() { |
void DataTypeManagerImpl::PurgeForMigration( |
syncer::ModelTypeSet undesired_types, |
syncer::ConfigureReason reason) { |
- syncer::ModelTypeSet remainder = Difference(last_requested_types_, |
- undesired_types); |
+ syncer::ModelTypeSet remainder = |
+ Difference(last_requested_types_, undesired_types); |
ConfigureImpl(remainder, reason); |
} |
-void DataTypeManagerImpl::ConfigureImpl( |
- syncer::ModelTypeSet desired_types, |
- syncer::ConfigureReason reason) { |
+void DataTypeManagerImpl::ConfigureImpl(syncer::ModelTypeSet desired_types, |
+ syncer::ConfigureReason reason) { |
DCHECK_NE(reason, syncer::CONFIGURE_REASON_UNKNOWN); |
DVLOG(1) << "Configuring for " << syncer::ModelTypeSetToString(desired_types) |
<< " with reason " << reason; |
@@ -190,8 +184,7 @@ DataTypeManagerImpl::BuildDataTypeConfigStateMap( |
// 3. Flip |types_being_configured| to CONFIGURE_ACTIVE. |
// 4. Set non-enabled user types as DISABLED. |
// 5. Set the fatal, crypto, and unready types to their respective states. |
- syncer::ModelTypeSet error_types = |
- data_type_status_table_.GetFailedTypes(); |
+ syncer::ModelTypeSet error_types = data_type_status_table_.GetFailedTypes(); |
syncer::ModelTypeSet fatal_types = |
data_type_status_table_.GetFatalErrorTypes(); |
syncer::ModelTypeSet crypto_types = |
@@ -216,12 +209,11 @@ DataTypeManagerImpl::BuildDataTypeConfigStateMap( |
if (catch_up_in_progress_) |
clean_types.PutAll(enabled_types); |
- syncer::ModelTypeSet disabled_types = |
- syncer::Difference( |
- syncer::Union(syncer::UserTypes(), syncer::ControlTypes()), |
- enabled_types); |
- syncer::ModelTypeSet to_configure = syncer::Intersection( |
- enabled_types, types_being_configured); |
+ syncer::ModelTypeSet disabled_types = syncer::Difference( |
+ syncer::Union(syncer::UserTypes(), syncer::ControlTypes()), |
+ enabled_types); |
+ syncer::ModelTypeSet to_configure = |
+ syncer::Intersection(enabled_types, types_being_configured); |
DVLOG(1) << "Enabling: " << syncer::ModelTypeSetToString(enabled_types); |
DVLOG(1) << "Configuring: " << syncer::ModelTypeSetToString(to_configure); |
DVLOG(1) << "Disabling: " << syncer::ModelTypeSetToString(disabled_types); |
@@ -235,19 +227,15 @@ DataTypeManagerImpl::BuildDataTypeConfigStateMap( |
&config_state_map); |
BackendDataTypeConfigurer::SetDataTypesState( |
BackendDataTypeConfigurer::CONFIGURE_CLEAN, clean_types, |
- &config_state_map); |
- BackendDataTypeConfigurer::SetDataTypesState( |
- BackendDataTypeConfigurer::DISABLED, disabled_types, |
&config_state_map); |
BackendDataTypeConfigurer::SetDataTypesState( |
- BackendDataTypeConfigurer::FATAL, fatal_types, |
- &config_state_map); |
+ BackendDataTypeConfigurer::DISABLED, disabled_types, &config_state_map); |
+ BackendDataTypeConfigurer::SetDataTypesState(BackendDataTypeConfigurer::FATAL, |
+ fatal_types, &config_state_map); |
BackendDataTypeConfigurer::SetDataTypesState( |
- BackendDataTypeConfigurer::CRYPTO, crypto_types, |
- &config_state_map); |
+ BackendDataTypeConfigurer::CRYPTO, crypto_types, &config_state_map); |
BackendDataTypeConfigurer::SetDataTypesState( |
- BackendDataTypeConfigurer::UNREADY, unready_types, |
- &config_state_map); |
+ BackendDataTypeConfigurer::UNREADY, unready_types, &config_state_map); |
return config_state_map; |
} |
@@ -272,8 +260,7 @@ void DataTypeManagerImpl::Restart(syncer::ConfigureReason reason) { |
syncer::ModelTypeSet encrypted_types = |
encryption_handler_->GetEncryptedDataTypes(); |
encrypted_types.RetainAll(last_requested_types_); |
- encrypted_types.RemoveAll( |
- data_type_status_table_.GetCryptoErrorTypes()); |
+ encrypted_types.RemoveAll(data_type_status_table_.GetCryptoErrorTypes()); |
DataTypeStatusTable::TypeErrorMap crypto_errors = |
GenerateCryptoErrorsForTypes(encrypted_types); |
data_type_status_table_.UpdateFailedDataTypes(crypto_errors); |
@@ -281,8 +268,7 @@ void DataTypeManagerImpl::Restart(syncer::ConfigureReason reason) { |
data_type_status_table_.ResetCryptoErrors(); |
} |
- syncer::ModelTypeSet failed_types = |
- data_type_status_table_.GetFailedTypes(); |
+ syncer::ModelTypeSet failed_types = data_type_status_table_.GetFailedTypes(); |
syncer::ModelTypeSet enabled_types = |
syncer::Difference(last_requested_types_, failed_types); |
@@ -402,12 +388,10 @@ void DataTypeManagerImpl::DownloadReady( |
if (!failed_configuration_types.Empty()) { |
DataTypeStatusTable::TypeErrorMap errors; |
for (syncer::ModelTypeSet::Iterator iter = |
- failed_configuration_types.First(); iter.Good(); iter.Inc()) { |
- syncer::SyncError error( |
- FROM_HERE, |
- syncer::SyncError::DATATYPE_ERROR, |
- "Backend failed to download type.", |
- iter.Get()); |
+ failed_configuration_types.First(); |
+ iter.Good(); iter.Inc()) { |
+ syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, |
+ "Backend failed to download type.", iter.Get()); |
errors[iter.Get()] = error; |
} |
data_type_status_table_.UpdateFailedDataTypes(errors); |
@@ -457,8 +441,7 @@ void DataTypeManagerImpl::StartNextDownload( |
last_configure_reason_, |
BuildDataTypeConfigStateMap(download_types_queue_.front()), |
base::Bind(&DataTypeManagerImpl::DownloadReady, |
- weak_ptr_factory_.GetWeakPtr(), |
- download_types_queue_.front()), |
+ weak_ptr_factory_.GetWeakPtr(), download_types_queue_.front()), |
base::Bind(&DataTypeManagerImpl::OnDownloadRetry, |
weak_ptr_factory_.GetWeakPtr())); |
@@ -481,7 +464,7 @@ void DataTypeManagerImpl::StartNextAssociation(AssociationGroup group) { |
// The model association done event will result in associating any remaining |
// association groups. |
if (model_association_manager_.state() != |
- ModelAssociationManager::INITIALIZED) { |
+ ModelAssociationManager::INITIALIZED) { |
return; |
} |
@@ -520,8 +503,7 @@ void DataTypeManagerImpl::OnSingleDataTypeWillStop( |
if (error.IsSet()) { |
DataTypeStatusTable::TypeErrorMap failed_types; |
failed_types[type] = error; |
- data_type_status_table_.UpdateFailedDataTypes( |
- failed_types); |
+ data_type_status_table_.UpdateFailedDataTypes(failed_types); |
// Unrecoverable errors will shut down the entire backend, so no need to |
// reconfigure. |
@@ -623,8 +605,7 @@ void DataTypeManagerImpl::Stop() { |
StopImpl(); |
if (need_to_notify) { |
- ConfigureResult result(ABORTED, |
- last_requested_types_); |
+ ConfigureResult result(ABORTED, last_requested_types_); |
NotifyDone(result); |
} |
} |
@@ -635,8 +616,7 @@ void DataTypeManagerImpl::Abort(ConfigureStatus status) { |
StopImpl(); |
DCHECK_NE(OK, status); |
- ConfigureResult result(status, |
- last_requested_types_); |
+ ConfigureResult result(status, last_requested_types_); |
NotifyDone(result); |
} |