Commit 2b7908a7 authored by Marc Treib's avatar Marc Treib Committed by Commit Bot

Cleanup: Remove SyncError::UNRECOVERABLE_ERROR and PERSISTENCE_ERROR

...plus all the code for handling them.
These were unused (outside of some tests), so this was all dead code.

Bug: 1145589
Change-Id: Ic54a7fa293dc8cf5e785acb6cb137118f91f51d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2518981Reviewed-by: default avatarJan Krcal <jkrcal@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824403}
parent c2919fdc
...@@ -257,11 +257,6 @@ DataTypeManagerImpl::BuildDataTypeConfigStateMap( ...@@ -257,11 +257,6 @@ DataTypeManagerImpl::BuildDataTypeConfigStateMap(
ModelTypeSet crypto_types = data_type_status_table_.GetCryptoErrorTypes(); ModelTypeSet crypto_types = data_type_status_table_.GetCryptoErrorTypes();
ModelTypeSet unready_types = data_type_status_table_.GetUnreadyErrorTypes(); ModelTypeSet unready_types = data_type_status_table_.GetUnreadyErrorTypes();
// Types with persistence errors are only purged/resynced when they're
// actively being configured.
ModelTypeSet clean_types = data_type_status_table_.GetPersistenceErrorTypes();
clean_types.RetainAll(types_being_configured);
// Types with unready errors do not count as unready if they've been disabled. // Types with unready errors do not count as unready if they've been disabled.
unready_types.RetainAll(last_requested_types_); unready_types.RetainAll(last_requested_types_);
...@@ -278,7 +273,6 @@ DataTypeManagerImpl::BuildDataTypeConfigStateMap( ...@@ -278,7 +273,6 @@ DataTypeManagerImpl::BuildDataTypeConfigStateMap(
DataTypeConfigStateMap config_state_map; DataTypeConfigStateMap config_state_map;
SetDataTypesState(CONFIGURE_INACTIVE, enabled_types, &config_state_map); SetDataTypesState(CONFIGURE_INACTIVE, enabled_types, &config_state_map);
SetDataTypesState(CONFIGURE_ACTIVE, to_configure, &config_state_map); SetDataTypesState(CONFIGURE_ACTIVE, to_configure, &config_state_map);
SetDataTypesState(CONFIGURE_CLEAN, clean_types, &config_state_map);
SetDataTypesState(DISABLED, disabled_types, &config_state_map); SetDataTypesState(DISABLED, disabled_types, &config_state_map);
SetDataTypesState(FATAL, fatal_types, &config_state_map); SetDataTypesState(FATAL, fatal_types, &config_state_map);
SetDataTypesState(CRYPTO, crypto_types, &config_state_map); SetDataTypesState(CRYPTO, crypto_types, &config_state_map);
...@@ -471,10 +465,6 @@ void DataTypeManagerImpl::DownloadCompleted( ...@@ -471,10 +465,6 @@ void DataTypeManagerImpl::DownloadCompleted(
ModelTypeSet failed_configuration_types) { ModelTypeSet failed_configuration_types) {
DCHECK_EQ(CONFIGURING, state_); DCHECK_EQ(CONFIGURING, state_);
// Persistence errors are reset after each backend configuration attempt
// during which they would have been purged.
data_type_status_table_.ResetPersistenceErrorsFrom(downloaded_types);
if (!failed_configuration_types.Empty()) { if (!failed_configuration_types.Empty()) {
DataTypeStatusTable::TypeErrorMap errors; DataTypeStatusTable::TypeErrorMap errors;
for (ModelType type : failed_configuration_types) { for (ModelType type : failed_configuration_types) {
...@@ -566,12 +556,10 @@ ModelTypeSet DataTypeManagerImpl::PrepareConfigureParams( ...@@ -566,12 +556,10 @@ ModelTypeSet DataTypeManagerImpl::PrepareConfigureParams(
GetDataTypesInState(UNREADY, config_state_map); GetDataTypesInState(UNREADY, config_state_map);
const ModelTypeSet active_types = const ModelTypeSet active_types =
GetDataTypesInState(CONFIGURE_ACTIVE, config_state_map); GetDataTypesInState(CONFIGURE_ACTIVE, config_state_map);
const ModelTypeSet clean_types =
GetDataTypesInState(CONFIGURE_CLEAN, config_state_map);
const ModelTypeSet inactive_types = const ModelTypeSet inactive_types =
GetDataTypesInState(CONFIGURE_INACTIVE, config_state_map); GetDataTypesInState(CONFIGURE_INACTIVE, config_state_map);
ModelTypeSet enabled_types = Union(active_types, clean_types); ModelTypeSet enabled_types = active_types;
ModelTypeSet disabled_types = GetDataTypesInState(DISABLED, config_state_map); ModelTypeSet disabled_types = GetDataTypesInState(DISABLED, config_state_map);
disabled_types.PutAll(fatal_types); disabled_types.PutAll(fatal_types);
disabled_types.PutAll(crypto_types); disabled_types.PutAll(crypto_types);
...@@ -589,7 +577,6 @@ ModelTypeSet DataTypeManagerImpl::PrepareConfigureParams( ...@@ -589,7 +577,6 @@ ModelTypeSet DataTypeManagerImpl::PrepareConfigureParams(
downloaded_types_.PutAll(enabled_types); downloaded_types_.PutAll(enabled_types);
downloaded_types_.RemoveAll(disabled_types); downloaded_types_.RemoveAll(disabled_types);
types_to_download.PutAll(clean_types);
types_to_download.RemoveAll(ProxyTypes()); types_to_download.RemoveAll(ProxyTypes());
types_to_download.RemoveAll(CommitOnlyTypes()); types_to_download.RemoveAll(CommitOnlyTypes());
if (!types_to_download.Empty()) if (!types_to_download.Empty())
...@@ -626,10 +613,6 @@ ModelTypeSet DataTypeManagerImpl::PrepareConfigureParams( ...@@ -626,10 +613,6 @@ ModelTypeSet DataTypeManagerImpl::PrepareConfigureParams(
// mode. // mode.
if (last_requested_context_.sync_mode == SyncMode::kFull) { if (last_requested_context_.sync_mode == SyncMode::kFull) {
types_to_purge = Difference(ModelTypeSet::All(), downloaded_types_); types_to_purge = Difference(ModelTypeSet::All(), downloaded_types_);
// Include clean_types in types_to_purge, they are part of
// |downloaded_types_|, but still need to be cleared.
DCHECK(downloaded_types_.HasAll(clean_types));
types_to_purge.PutAll(clean_types);
types_to_purge.RemoveAll(inactive_types); types_to_purge.RemoveAll(inactive_types);
types_to_purge.RemoveAll(unready_types); types_to_purge.RemoveAll(unready_types);
} }
...@@ -722,20 +705,15 @@ void DataTypeManagerImpl::OnSingleDataTypeWillStop(ModelType type, ...@@ -722,20 +705,15 @@ void DataTypeManagerImpl::OnSingleDataTypeWillStop(ModelType type,
if (error.IsSet()) { if (error.IsSet()) {
data_type_status_table_.UpdateFailedDataType(type, error); data_type_status_table_.UpdateFailedDataType(type, error);
needs_reconfigure_ = true;
// Unrecoverable errors will shut down the entire backend, so no need to last_requested_context_.reason =
// reconfigure. GetReasonForProgrammaticReconfigure(last_requested_context_.reason);
if (error.error_type() != SyncError::UNRECOVERABLE_ERROR) { // Do this asynchronously so the ModelLoadManager has a chance to
needs_reconfigure_ = true; // finish stopping this type, otherwise DeactivateDataType() and Stop()
last_requested_context_.reason = // end up getting called twice on the controller.
GetReasonForProgrammaticReconfigure(last_requested_context_.reason); base::SequencedTaskRunnerHandle::Get()->PostTask(
// Do this asynchronously so the ModelLoadManager has a chance to FROM_HERE, base::BindOnce(&DataTypeManagerImpl::ProcessReconfigure,
// finish stopping this type, otherwise DeactivateDataType() and Stop() weak_ptr_factory_.GetWeakPtr()));
// end up getting called twice on the controller.
base::SequencedTaskRunnerHandle::Get()->PostTask(
FROM_HERE, base::BindOnce(&DataTypeManagerImpl::ProcessReconfigure,
weak_ptr_factory_.GetWeakPtr()));
}
} }
} }
......
...@@ -75,8 +75,6 @@ class DataTypeManagerImpl : public DataTypeManager, ...@@ -75,8 +75,6 @@ class DataTypeManagerImpl : public DataTypeManager,
CONFIGURE_INACTIVE, // Already configured or to be configured in future. CONFIGURE_INACTIVE, // Already configured or to be configured in future.
// Data of such types is left as it is, no // Data of such types is left as it is, no
// downloading or purging. // downloading or purging.
CONFIGURE_CLEAN, // Actively being configured but requiring unapply
// and GetUpdates first (e.g. for persistence errors).
DISABLED, // Not syncing. Disabled by user. DISABLED, // Not syncing. Disabled by user.
FATAL, // Not syncing due to unrecoverable error. FATAL, // Not syncing due to unrecoverable error.
CRYPTO, // Not syncing due to a cryptographer error. CRYPTO, // Not syncing due to a cryptographer error.
......
...@@ -40,15 +40,14 @@ ConfigureContext BuildConfigureContext(ConfigureReason reason, ...@@ -40,15 +40,14 @@ ConfigureContext BuildConfigureContext(ConfigureReason reason,
} }
DataTypeStatusTable BuildStatusTable(ModelTypeSet crypto_errors, DataTypeStatusTable BuildStatusTable(ModelTypeSet crypto_errors,
ModelTypeSet association_errors, ModelTypeSet datatype_errors,
ModelTypeSet unready_errors, ModelTypeSet unready_errors) {
ModelTypeSet unrecoverable_errors) {
DataTypeStatusTable::TypeErrorMap error_map; DataTypeStatusTable::TypeErrorMap error_map;
for (ModelType type : crypto_errors) { for (ModelType type : crypto_errors) {
error_map[type] = SyncError(FROM_HERE, SyncError::CRYPTO_ERROR, error_map[type] = SyncError(FROM_HERE, SyncError::CRYPTO_ERROR,
"crypto error expected", type); "crypto error expected", type);
} }
for (ModelType type : association_errors) { for (ModelType type : datatype_errors) {
error_map[type] = SyncError(FROM_HERE, SyncError::DATATYPE_ERROR, error_map[type] = SyncError(FROM_HERE, SyncError::DATATYPE_ERROR,
"association error expected", type); "association error expected", type);
} }
...@@ -56,10 +55,6 @@ DataTypeStatusTable BuildStatusTable(ModelTypeSet crypto_errors, ...@@ -56,10 +55,6 @@ DataTypeStatusTable BuildStatusTable(ModelTypeSet crypto_errors,
error_map[type] = SyncError(FROM_HERE, SyncError::UNREADY_ERROR, error_map[type] = SyncError(FROM_HERE, SyncError::UNREADY_ERROR,
"unready error expected", type); "unready error expected", type);
} }
for (ModelType type : unrecoverable_errors) {
error_map[type] = SyncError(FROM_HERE, SyncError::UNRECOVERABLE_ERROR,
"unrecoverable error expected", type);
}
DataTypeStatusTable status_table; DataTypeStatusTable status_table;
status_table.UpdateFailedDataTypes(error_map); status_table.UpdateFailedDataTypes(error_map);
return status_table; return status_table;
...@@ -423,7 +418,7 @@ TEST_F(SyncDataTypeManagerImplTest, OneWaitingForCrypto) { ...@@ -423,7 +418,7 @@ TEST_F(SyncDataTypeManagerImplTest, OneWaitingForCrypto) {
SetConfigureDoneExpectation( SetConfigureDoneExpectation(
DataTypeManager::OK, DataTypeManager::OK,
BuildStatusTable(/*crypto_errors=*/ModelTypeSet(PASSWORDS), BuildStatusTable(/*crypto_errors=*/ModelTypeSet(PASSWORDS),
ModelTypeSet(), ModelTypeSet(), ModelTypeSet())); ModelTypeSet(), ModelTypeSet()));
Configure(ModelTypeSet(PASSWORDS)); Configure(ModelTypeSet(PASSWORDS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state()); EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
FinishDownload(ModelTypeSet(), ModelTypeSet()); // priority types FinishDownload(ModelTypeSet(), ModelTypeSet()); // priority types
...@@ -588,8 +583,9 @@ TEST_F(SyncDataTypeManagerImplTest, OneFailingController) { ...@@ -588,8 +583,9 @@ TEST_F(SyncDataTypeManagerImplTest, OneFailingController) {
SetConfigureStartExpectation(); SetConfigureStartExpectation();
SetConfigureDoneExpectation( SetConfigureDoneExpectation(
DataTypeManager::UNKNOWN, DataTypeManager::UNKNOWN,
BuildStatusTable(ModelTypeSet(), ModelTypeSet(), ModelTypeSet(), BuildStatusTable(ModelTypeSet(),
/*unrecoverable_errors=*/ModelTypeSet(BOOKMARKS))); /*datatype_errors=*/ModelTypeSet(BOOKMARKS),
ModelTypeSet()));
Configure(ModelTypeSet(BOOKMARKS)); Configure(ModelTypeSet(BOOKMARKS));
EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state()); EXPECT_EQ(DataTypeManager::CONFIGURING, dtm_->state());
...@@ -896,8 +892,8 @@ TEST_F(SyncDataTypeManagerImplTest, PrioritizedConfigurationDownloadError) { ...@@ -896,8 +892,8 @@ TEST_F(SyncDataTypeManagerImplTest, PrioritizedConfigurationDownloadError) {
SetConfigureDoneExpectation( SetConfigureDoneExpectation(
DataTypeManager::OK, DataTypeManager::OK,
BuildStatusTable(ModelTypeSet(), BuildStatusTable(ModelTypeSet(),
/*association_errors=*/ModelTypeSet(BOOKMARKS), /*datatype_errors=*/ModelTypeSet(BOOKMARKS),
ModelTypeSet(), ModelTypeSet())); ModelTypeSet()));
// Initially only PREFERENCES is configured. // Initially only PREFERENCES is configured.
Configure(ModelTypeSet(BOOKMARKS, PREFERENCES)); Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
...@@ -958,8 +954,7 @@ TEST_F(SyncDataTypeManagerImplTest, FailingPreconditionKeepData) { ...@@ -958,8 +954,7 @@ TEST_F(SyncDataTypeManagerImplTest, FailingPreconditionKeepData) {
SetConfigureDoneExpectation( SetConfigureDoneExpectation(
DataTypeManager::OK, DataTypeManager::OK,
BuildStatusTable(ModelTypeSet(), ModelTypeSet(), BuildStatusTable(ModelTypeSet(), ModelTypeSet(),
/*unready_errors=*/ModelTypeSet(BOOKMARKS), /*unready_errors=*/ModelTypeSet(BOOKMARKS)));
ModelTypeSet()));
Configure(ModelTypeSet(BOOKMARKS)); Configure(ModelTypeSet(BOOKMARKS));
FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types
EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state()); EXPECT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
...@@ -1000,8 +995,7 @@ TEST_F(SyncDataTypeManagerImplTest, UnreadyTypeResetReconfigure) { ...@@ -1000,8 +995,7 @@ TEST_F(SyncDataTypeManagerImplTest, UnreadyTypeResetReconfigure) {
SetConfigureDoneExpectation( SetConfigureDoneExpectation(
DataTypeManager::OK, DataTypeManager::OK,
BuildStatusTable(ModelTypeSet(), ModelTypeSet(), BuildStatusTable(ModelTypeSet(), ModelTypeSet(),
/*unready_errors=*/ModelTypeSet(BOOKMARKS), /*unready_errors=*/ModelTypeSet(BOOKMARKS)));
ModelTypeSet()));
Configure(ModelTypeSet(BOOKMARKS)); Configure(ModelTypeSet(BOOKMARKS));
// Second Configure sets a flag to perform reconfiguration after the first one // Second Configure sets a flag to perform reconfiguration after the first one
// is done. // is done.
...@@ -1028,8 +1022,7 @@ TEST_F(SyncDataTypeManagerImplTest, UnreadyTypeLaterReady) { ...@@ -1028,8 +1022,7 @@ TEST_F(SyncDataTypeManagerImplTest, UnreadyTypeLaterReady) {
SetConfigureDoneExpectation( SetConfigureDoneExpectation(
DataTypeManager::OK, DataTypeManager::OK,
BuildStatusTable(ModelTypeSet(), ModelTypeSet(), BuildStatusTable(ModelTypeSet(), ModelTypeSet(),
/*unready_errors=*/ModelTypeSet(BOOKMARKS), /*unready_errors=*/ModelTypeSet(BOOKMARKS)));
ModelTypeSet()));
Configure(ModelTypeSet(BOOKMARKS)); Configure(ModelTypeSet(BOOKMARKS));
FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types
ASSERT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state()); ASSERT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
...@@ -1067,9 +1060,9 @@ TEST_F(SyncDataTypeManagerImplTest, ...@@ -1067,9 +1060,9 @@ TEST_F(SyncDataTypeManagerImplTest,
SetConfigureStartExpectation(); SetConfigureStartExpectation();
SetConfigureDoneExpectation( SetConfigureDoneExpectation(
DataTypeManager::OK, DataTypeManager::OK,
BuildStatusTable(ModelTypeSet(), ModelTypeSet(), BuildStatusTable(
/*unready_errors=*/ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet(), ModelTypeSet(),
ModelTypeSet())); /*unready_errors=*/ModelTypeSet(BOOKMARKS, PREFERENCES)));
Configure(ModelTypeSet(BOOKMARKS, PREFERENCES)); Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types
ASSERT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state()); ASSERT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
...@@ -1116,9 +1109,9 @@ TEST_F(SyncDataTypeManagerImplTest, MultipleUnreadyTypesLaterOneOfThemReady) { ...@@ -1116,9 +1109,9 @@ TEST_F(SyncDataTypeManagerImplTest, MultipleUnreadyTypesLaterOneOfThemReady) {
SetConfigureStartExpectation(); SetConfigureStartExpectation();
SetConfigureDoneExpectation( SetConfigureDoneExpectation(
DataTypeManager::OK, DataTypeManager::OK,
BuildStatusTable(ModelTypeSet(), ModelTypeSet(), BuildStatusTable(
/*unready_errors=*/ModelTypeSet(BOOKMARKS, PREFERENCES), ModelTypeSet(), ModelTypeSet(),
ModelTypeSet())); /*unready_errors=*/ModelTypeSet(BOOKMARKS, PREFERENCES)));
Configure(ModelTypeSet(BOOKMARKS, PREFERENCES)); Configure(ModelTypeSet(BOOKMARKS, PREFERENCES));
FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types
ASSERT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state()); ASSERT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
...@@ -1140,8 +1133,7 @@ TEST_F(SyncDataTypeManagerImplTest, MultipleUnreadyTypesLaterOneOfThemReady) { ...@@ -1140,8 +1133,7 @@ TEST_F(SyncDataTypeManagerImplTest, MultipleUnreadyTypesLaterOneOfThemReady) {
SetConfigureDoneExpectation( SetConfigureDoneExpectation(
DataTypeManager::OK, DataTypeManager::OK,
BuildStatusTable(ModelTypeSet(), ModelTypeSet(), BuildStatusTable(ModelTypeSet(), ModelTypeSet(),
/*unready_errors=*/ModelTypeSet(PREFERENCES), /*unready_errors=*/ModelTypeSet(PREFERENCES)));
ModelTypeSet()));
FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types
FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet()); FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
...@@ -1161,8 +1153,7 @@ TEST_F(SyncDataTypeManagerImplTest, ...@@ -1161,8 +1153,7 @@ TEST_F(SyncDataTypeManagerImplTest,
SetConfigureDoneExpectation( SetConfigureDoneExpectation(
DataTypeManager::OK, DataTypeManager::OK,
BuildStatusTable(ModelTypeSet(), ModelTypeSet(), BuildStatusTable(ModelTypeSet(), ModelTypeSet(),
/*unready_errors=*/ModelTypeSet(BOOKMARKS), /*unready_errors=*/ModelTypeSet(BOOKMARKS)));
ModelTypeSet()));
Configure(ModelTypeSet(BOOKMARKS)); Configure(ModelTypeSet(BOOKMARKS));
FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types
ASSERT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state()); ASSERT_EQ(DataTypeController::NOT_RUNNING, GetController(BOOKMARKS)->state());
...@@ -1206,8 +1197,8 @@ TEST_F(SyncDataTypeManagerImplTest, ModelLoadError) { ...@@ -1206,8 +1197,8 @@ TEST_F(SyncDataTypeManagerImplTest, ModelLoadError) {
SetConfigureDoneExpectation( SetConfigureDoneExpectation(
DataTypeManager::OK, DataTypeManager::OK,
BuildStatusTable(ModelTypeSet(), BuildStatusTable(ModelTypeSet(),
/*association_errors=*/ModelTypeSet(BOOKMARKS), /*datatype_errors=*/ModelTypeSet(BOOKMARKS),
ModelTypeSet(), ModelTypeSet())); ModelTypeSet()));
Configure(ModelTypeSet(BOOKMARKS)); Configure(ModelTypeSet(BOOKMARKS));
FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types
FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet()); FinishDownload(ModelTypeSet(BOOKMARKS), ModelTypeSet());
...@@ -1240,11 +1231,10 @@ TEST_F(SyncDataTypeManagerImplTest, ErrorBeforeStartup) { ...@@ -1240,11 +1231,10 @@ TEST_F(SyncDataTypeManagerImplTest, ErrorBeforeStartup) {
SetConfigureStartExpectation(); SetConfigureStartExpectation();
Configure({BOOKMARKS, PREFERENCES}); Configure({BOOKMARKS, PREFERENCES});
SetConfigureDoneExpectation( SetConfigureDoneExpectation(DataTypeManager::OK,
DataTypeManager::OK, BuildStatusTable(/*crypto_errors=*/{}, BuildStatusTable(/*crypto_errors=*/{},
/*association_errors=*/{BOOKMARKS}, /*datatype_errors=*/{BOOKMARKS},
/*unready_errore=*/{}, /*unready_errore=*/{}));
/*unrecoverable_errors=*/{}));
FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types FinishDownload(ModelTypeSet(), ModelTypeSet()); // control types
FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet()); FinishDownload(ModelTypeSet(PREFERENCES), ModelTypeSet());
......
...@@ -43,16 +43,12 @@ bool DataTypeStatusTable::UpdateFailedDataType(ModelType type, ...@@ -43,16 +43,12 @@ bool DataTypeStatusTable::UpdateFailedDataType(ModelType type,
case SyncError::UNSET: case SyncError::UNSET:
NOTREACHED(); NOTREACHED();
break; break;
case SyncError::UNRECOVERABLE_ERROR:
return unrecoverable_errors_.emplace(type, error).second;
case SyncError::DATATYPE_ERROR: case SyncError::DATATYPE_ERROR:
return data_type_errors_.emplace(type, error).second; return data_type_errors_.emplace(type, error).second;
case SyncError::DATATYPE_POLICY_ERROR: case SyncError::DATATYPE_POLICY_ERROR:
return data_type_policy_errors_.emplace(type, error).second; return data_type_policy_errors_.emplace(type, error).second;
case SyncError::CRYPTO_ERROR: case SyncError::CRYPTO_ERROR:
return crypto_errors_.emplace(type, error).second; return crypto_errors_.emplace(type, error).second;
case SyncError::PERSISTENCE_ERROR:
return persistence_errors_.emplace(type, error).second;
case SyncError::UNREADY_ERROR: case SyncError::UNREADY_ERROR:
return unready_errors_.emplace(type, error).second; return unready_errors_.emplace(type, error).second;
} }
...@@ -62,11 +58,9 @@ bool DataTypeStatusTable::UpdateFailedDataType(ModelType type, ...@@ -62,11 +58,9 @@ bool DataTypeStatusTable::UpdateFailedDataType(ModelType type,
void DataTypeStatusTable::Reset() { void DataTypeStatusTable::Reset() {
DVLOG(1) << "Resetting data type errors."; DVLOG(1) << "Resetting data type errors.";
unrecoverable_errors_.clear();
data_type_errors_.clear(); data_type_errors_.clear();
data_type_policy_errors_.clear(); data_type_policy_errors_.clear();
crypto_errors_.clear(); crypto_errors_.clear();
persistence_errors_.clear();
unready_errors_.clear(); unready_errors_.clear();
} }
...@@ -74,13 +68,6 @@ void DataTypeStatusTable::ResetCryptoErrors() { ...@@ -74,13 +68,6 @@ void DataTypeStatusTable::ResetCryptoErrors() {
crypto_errors_.clear(); crypto_errors_.clear();
} }
void DataTypeStatusTable::ResetPersistenceErrorsFrom(
ModelTypeSet purged_types) {
for (ModelType type : purged_types) {
persistence_errors_.erase(type);
}
}
bool DataTypeStatusTable::ResetDataTypePolicyErrorFor(ModelType type) { bool DataTypeStatusTable::ResetDataTypePolicyErrorFor(ModelType type) {
return data_type_policy_errors_.erase(type) > 0; return data_type_policy_errors_.erase(type) > 0;
} }
...@@ -95,9 +82,7 @@ DataTypeStatusTable::TypeErrorMap DataTypeStatusTable::GetAllErrors() const { ...@@ -95,9 +82,7 @@ DataTypeStatusTable::TypeErrorMap DataTypeStatusTable::GetAllErrors() const {
result.insert(data_type_policy_errors_.begin(), result.insert(data_type_policy_errors_.begin(),
data_type_policy_errors_.end()); data_type_policy_errors_.end());
result.insert(crypto_errors_.begin(), crypto_errors_.end()); result.insert(crypto_errors_.begin(), crypto_errors_.end());
result.insert(persistence_errors_.begin(), persistence_errors_.end());
result.insert(unready_errors_.begin(), unready_errors_.end()); result.insert(unready_errors_.begin(), unready_errors_.end());
result.insert(unrecoverable_errors_.begin(), unrecoverable_errors_.end());
return result; return result;
} }
...@@ -112,7 +97,6 @@ ModelTypeSet DataTypeStatusTable::GetFatalErrorTypes() const { ...@@ -112,7 +97,6 @@ ModelTypeSet DataTypeStatusTable::GetFatalErrorTypes() const {
ModelTypeSet result; ModelTypeSet result;
result.PutAll(GetTypesFromErrorMap(data_type_errors_)); result.PutAll(GetTypesFromErrorMap(data_type_errors_));
result.PutAll(GetTypesFromErrorMap(data_type_policy_errors_)); result.PutAll(GetTypesFromErrorMap(data_type_policy_errors_));
result.PutAll(GetTypesFromErrorMap(unrecoverable_errors_));
return result; return result;
} }
...@@ -121,28 +105,9 @@ ModelTypeSet DataTypeStatusTable::GetCryptoErrorTypes() const { ...@@ -121,28 +105,9 @@ ModelTypeSet DataTypeStatusTable::GetCryptoErrorTypes() const {
return result; return result;
} }
ModelTypeSet DataTypeStatusTable::GetPersistenceErrorTypes() const {
ModelTypeSet result = GetTypesFromErrorMap(persistence_errors_);
return result;
}
ModelTypeSet DataTypeStatusTable::GetUnreadyErrorTypes() const { ModelTypeSet DataTypeStatusTable::GetUnreadyErrorTypes() const {
ModelTypeSet result = GetTypesFromErrorMap(unready_errors_); ModelTypeSet result = GetTypesFromErrorMap(unready_errors_);
return result; return result;
} }
ModelTypeSet DataTypeStatusTable::GetUnrecoverableErrorTypes() const {
ModelTypeSet result = GetTypesFromErrorMap(unrecoverable_errors_);
return result;
}
SyncError DataTypeStatusTable::GetUnrecoverableError() const {
// Just return the first one. It is assumed all the unrecoverable errors
// have the same cause. The others are just tracked to know which types
// were involved.
return (unrecoverable_errors_.empty()
? SyncError()
: unrecoverable_errors_.begin()->second);
}
} // namespace syncer } // namespace syncer
...@@ -39,9 +39,6 @@ class DataTypeStatusTable { ...@@ -39,9 +39,6 @@ class DataTypeStatusTable {
// Resets the set of types with cryptographer errors. // Resets the set of types with cryptographer errors.
void ResetCryptoErrors(); void ResetCryptoErrors();
// Resets those persistence errors that intersect with |purged_types|.
void ResetPersistenceErrorsFrom(ModelTypeSet purged_types);
// Removes |type| from the data_type_errors_ set. Returns true if the type // Removes |type| from the data_type_errors_ set. Returns true if the type
// was removed from the error set, false if the type did not have a data type // was removed from the error set, false if the type did not have a data type
// error to begin with. // error to begin with.
...@@ -56,45 +53,27 @@ class DataTypeStatusTable { ...@@ -56,45 +53,27 @@ class DataTypeStatusTable {
TypeErrorMap GetAllErrors() const; TypeErrorMap GetAllErrors() const;
// Returns all types with failure errors. This includes, fatal, crypto, and // Returns all types with failure errors. This includes, fatal, crypto, and
// unready types.` // unready types.
ModelTypeSet GetFailedTypes() const; ModelTypeSet GetFailedTypes() const;
// Returns the types that are failing due to unrecoverable or datatype errors. // Returns the types that are failing due to datatype errors.
ModelTypeSet GetFatalErrorTypes() const; ModelTypeSet GetFatalErrorTypes() const;
// Returns the types that are failing due to cryptographer errors. // Returns the types that are failing due to cryptographer errors.
ModelTypeSet GetCryptoErrorTypes() const; ModelTypeSet GetCryptoErrorTypes() const;
// Returns the types that are failing due to persistence errors.
ModelTypeSet GetPersistenceErrorTypes() const;
// Returns the types that cannot be configured due to not being ready. // Returns the types that cannot be configured due to not being ready.
ModelTypeSet GetUnreadyErrorTypes() const; ModelTypeSet GetUnreadyErrorTypes() const;
// Returns the types that triggered the unrecoverable error.
ModelTypeSet GetUnrecoverableErrorTypes() const;
// Returns the current unrecoverable error, if there is one.
SyncError GetUnrecoverableError() const;
private: private:
// The current unrecoverable errors. Only one unrecoverable error can be
// active at a time, but it may apply to more than one type.
TypeErrorMap unrecoverable_errors_;
// List of data types that failed due to runtime errors and should be // List of data types that failed due to runtime errors and should be
// disabled. These are different from unrecoverable_errors_ in that // disabled. ResetDataTypeError can remove them from this list.
// ResetDataTypeError can remove them from this list.
TypeErrorMap data_type_errors_; TypeErrorMap data_type_errors_;
TypeErrorMap data_type_policy_errors_; TypeErrorMap data_type_policy_errors_;
// List of data types that failed due to the cryptographer not being ready. // List of data types that failed due to the cryptographer not being ready.
TypeErrorMap crypto_errors_; TypeErrorMap crypto_errors_;
// List of data types that failed because sync did not persist the newest
// version of their data.
TypeErrorMap persistence_errors_;
// List of data types that could not start due to not being ready. These can // List of data types that could not start due to not being ready. These can
// be marked as ready by calling ResetUnreadyErrorFor(..). // be marked as ready by calling ResetUnreadyErrorFor(..).
TypeErrorMap unready_errors_; TypeErrorMap unready_errors_;
......
...@@ -1044,35 +1044,15 @@ void ProfileSyncService::OnConfigureDone( ...@@ -1044,35 +1044,15 @@ void ProfileSyncService::OnConfigureDone(
// ABORT - Configuration was aborted. This is not an error, if // ABORT - Configuration was aborted. This is not an error, if
// initiated by user. // initiated by user.
// OK - Some or all types succeeded. // OK - Some or all types succeeded.
// Everything else is an UnrecoverableError. So treat it as such.
// First handle the abort case. // First handle the abort case.
if (result.status == DataTypeManager::ABORTED && if (result.status == DataTypeManager::ABORTED) {
expect_sync_configuration_aborted_) { DCHECK(expect_sync_configuration_aborted_);
DVLOG(0) << "ProfileSyncService::Observe Sync Configure aborted"; DVLOG(0) << "ProfileSyncService::Observe Sync Configure aborted";
expect_sync_configuration_aborted_ = false; expect_sync_configuration_aborted_ = false;
return; return;
} }
// Handle unrecoverable error.
if (result.status != DataTypeManager::OK) {
// Something catastrophic had happened. We should only have one
// error representing it.
SyncError error = result.data_type_status_table.GetUnrecoverableError();
DCHECK(error.IsSet());
std::string message =
"Sync configuration failed with status " +
DataTypeManager::ConfigureStatusToString(result.status) +
" caused by " +
ModelTypeSetToString(
result.data_type_status_table.GetUnrecoverableErrorTypes()) +
": " + error.message();
LOG(ERROR) << "ProfileSyncService error: " << message;
OnUnrecoverableErrorImpl(error.location(), message,
ERROR_REASON_CONFIGURATION_FAILURE);
return;
}
DCHECK_EQ(DataTypeManager::OK, result.status); DCHECK_EQ(DataTypeManager::OK, result.status);
// We should never get in a state where we have no encrypted datatypes // We should never get in a state where we have no encrypted datatypes
......
...@@ -261,7 +261,6 @@ class ProfileSyncService : public SyncService, ...@@ -261,7 +261,6 @@ class ProfileSyncService : public SyncService,
ERROR_REASON_SYNCER, ERROR_REASON_SYNCER,
ERROR_REASON_ENGINE_INIT_FAILURE, ERROR_REASON_ENGINE_INIT_FAILURE,
ERROR_REASON_CONFIGURATION_RETRY, ERROR_REASON_CONFIGURATION_RETRY,
ERROR_REASON_CONFIGURATION_FAILURE,
ERROR_REASON_ACTIONABLE_ERROR, ERROR_REASON_ACTIONABLE_ERROR,
ERROR_REASON_LIMIT ERROR_REASON_LIMIT
}; };
......
...@@ -34,13 +34,6 @@ namespace { ...@@ -34,13 +34,6 @@ namespace {
const char kEmail[] = "test_user@gmail.com"; const char kEmail[] = "test_user@gmail.com";
void SetError(DataTypeManager::ConfigureResult* result) {
DataTypeStatusTable::TypeErrorMap errors;
errors[BOOKMARKS] =
SyncError(FROM_HERE, SyncError::UNRECOVERABLE_ERROR, "Error", BOOKMARKS);
result->data_type_status_table.UpdateFailedDataTypes(errors);
}
} // namespace } // namespace
ACTION_P(InvokeOnConfigureStart, sync_service) { ACTION_P(InvokeOnConfigureStart, sync_service) {
...@@ -545,29 +538,6 @@ TEST_F(ProfileSyncServiceStartupTest, SwitchManaged) { ...@@ -545,29 +538,6 @@ TEST_F(ProfileSyncServiceStartupTest, SwitchManaged) {
EXPECT_FALSE(sync_service()->IsSyncFeatureActive()); EXPECT_FALSE(sync_service()->IsSyncFeatureActive());
} }
TEST_F(ProfileSyncServiceStartupTest, StartFailure) {
sync_prefs()->SetSyncRequested(true);
sync_prefs()->SetFirstSetupComplete();
CreateSyncService(ProfileSyncService::MANUAL_START);
SimulateTestUserSignin();
SetUpFakeSyncEngine();
DataTypeManagerMock* data_type_manager = SetUpDataTypeManagerMock();
DataTypeManager::ConfigureStatus status = DataTypeManager::ABORTED;
DataTypeManager::ConfigureResult result(status, ModelTypeSet());
EXPECT_CALL(*data_type_manager, Configure(_, _))
.WillRepeatedly(
DoAll(InvokeOnConfigureStart(sync_service()),
InvokeOnConfigureDone(sync_service(),
base::BindRepeating(&SetError), result)));
EXPECT_CALL(*data_type_manager, state())
.WillOnce(Return(DataTypeManager::STOPPED));
sync_service()->Initialize();
EXPECT_TRUE(sync_service()->HasUnrecoverableError());
EXPECT_EQ(SyncService::DisableReasonSet(
SyncService::DISABLE_REASON_UNRECOVERABLE_ERROR),
sync_service()->GetDisableReasons());
}
TEST_F(ProfileSyncServiceStartupTest, StartDownloadFailed) { TEST_F(ProfileSyncServiceStartupTest, StartDownloadFailed) {
sync_prefs()->SetSyncRequested(true); sync_prefs()->SetSyncRequested(true);
CreateSyncService(ProfileSyncService::MANUAL_START); CreateSyncService(ProfileSyncService::MANUAL_START);
......
...@@ -109,15 +109,9 @@ SyncError::Severity SyncError::GetSeverity() const { ...@@ -109,15 +109,9 @@ SyncError::Severity SyncError::GetSeverity() const {
std::string SyncError::GetMessagePrefix() const { std::string SyncError::GetMessagePrefix() const {
std::string type_message; std::string type_message;
switch (error_type_) { switch (error_type_) {
case UNRECOVERABLE_ERROR:
type_message = "unrecoverable error was encountered: ";
break;
case DATATYPE_ERROR: case DATATYPE_ERROR:
type_message = "datatype error was encountered: "; type_message = "datatype error was encountered: ";
break; break;
case PERSISTENCE_ERROR:
type_message = "persistence error was encountered: ";
break;
case CRYPTO_ERROR: case CRYPTO_ERROR:
type_message = "cryptographer error was encountered: "; type_message = "cryptographer error was encountered: ";
break; break;
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#ifndef COMPONENTS_SYNC_MODEL_SYNC_ERROR_H_ #ifndef COMPONENTS_SYNC_MODEL_SYNC_ERROR_H_
#define COMPONENTS_SYNC_MODEL_SYNC_ERROR_H_ #define COMPONENTS_SYNC_MODEL_SYNC_ERROR_H_
#include <iosfwd>
#include <memory> #include <memory>
#include <string> #include <string>
...@@ -27,15 +26,10 @@ class SyncError { ...@@ -27,15 +26,10 @@ class SyncError {
// have more complicated results). // have more complicated results).
enum ErrorType { enum ErrorType {
UNSET, // No error. UNSET, // No error.
UNRECOVERABLE_ERROR, // An unrecoverable runtime error was encountered,
// and sync should be disabled and purged completely.
DATATYPE_ERROR, // A datatype error was encountered, and the datatype DATATYPE_ERROR, // A datatype error was encountered, and the datatype
// should be disabled and purged completely. Note // should be disabled and purged completely. Note
// that datatype errors may be reset, triggering a // that datatype errors may be reset, triggering a
// re-enable. // re-enable.
PERSISTENCE_ERROR, // A persistence error was detected, and the
// datataype should be associated after a sync
// update.
CRYPTO_ERROR, // A cryptographer error was detected, and the CRYPTO_ERROR, // A cryptographer error was detected, and the
// datatype should be associated after it is // datatype should be associated after it is
// resolved. // resolved.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment