Chromium Code Reviews| Index: chrome/browser/sync/glue/generic_change_processor.cc |
| diff --git a/chrome/browser/sync/glue/generic_change_processor.cc b/chrome/browser/sync/glue/generic_change_processor.cc |
| index 3317c89cfe2d6d5c4b1de96b03e7540977fd3d29..9ca09f7207619aa77a4258bae77721ce150fcbca 100644 |
| --- a/chrome/browser/sync/glue/generic_change_processor.cc |
| +++ b/chrome/browser/sync/glue/generic_change_processor.cc |
| @@ -128,26 +128,58 @@ SyncError GenericChangeProcessor::GetSyncDataForType( |
| namespace { |
| -bool AttemptDelete(const SyncChange& change, sync_api::WriteNode* node) { |
| +// TODO(isherman): Investigating http://crbug.com/121592 |
| +std::string GetErrorExplanation(sync_api::BaseNode::InitByLookupResult result) { |
| + switch (result) { |
| + case sync_api::BaseNode::INIT_FAILED_ENTRY_NOT_GOOD: |
| + return " could not find entry matching the lookup criteria."; |
| + case sync_api::BaseNode::INIT_FAILED_ENTRY_IS_DEL: |
| + return " entry is already deleted."; |
| + case sync_api::BaseNode::INIT_FAILED_DECRYPT_IF_NECESSARY: |
| + return " unable to decrypt."; |
| + case sync_api::BaseNode::INIT_FAILED_PRECONDITION: |
| + return " a precondition was not met for calling init."; |
| + default: |
| + // Should have listed all the possible error cases above. |
| + NOTREACHED(); |
| + return ""; |
| + } |
| +} |
| + |
| +SyncError AttemptDelete(const SyncChange& change, |
| + syncable::ModelType type, |
| + std::string type_str, |
| + sync_api::WriteNode* node) { |
| DCHECK_EQ(change.change_type(), SyncChange::ACTION_DELETE); |
| if (change.sync_data().IsLocal()) { |
| const std::string& tag = change.sync_data().GetTag(); |
| if (tag.empty()) { |
| - return false; |
| + return SyncError( |
| + FROM_HERE, |
| + "Failed to delete " + type_str + " node. Local data, empty tag.", |
| + type); |
| } |
| - if (node->InitByClientTagLookup( |
| - change.sync_data().GetDataType(), tag) != |
| - sync_api::BaseNode::INIT_OK) { |
| - return false; |
| + |
| + sync_api::BaseNode::InitByLookupResult result = |
| + node->InitByClientTagLookup(change.sync_data().GetDataType(), tag); |
| + if (result != sync_api::BaseNode::INIT_OK) { |
| + return SyncError(FROM_HERE, |
| + "Failed to delete " + type_str + " node. " |
| + "Local data, " + GetErrorExplanation(result), |
| + type); |
| } |
| } else { |
| - if (node->InitByIdLookup(change.sync_data().GetRemoteId()) != |
| - sync_api::BaseNode::INIT_OK) { |
| - return false; |
| + sync_api::BaseNode::InitByLookupResult result = |
| + node->InitByIdLookup(change.sync_data().GetRemoteId()); |
| + if (result != sync_api::BaseNode::INIT_OK) { |
| + return SyncError(FROM_HERE, |
| + "Failed to delete " + type_str + " node. " |
| + "Non-local data, " + GetErrorExplanation(result), |
| + type); |
| } |
| } |
| node->Remove(); |
| - return true; |
| + return SyncError(); |
| } |
| } // namespace |
| @@ -167,11 +199,9 @@ SyncError GenericChangeProcessor::ProcessSyncChanges( |
| std::string type_str = syncable::ModelTypeToString(type); |
| sync_api::WriteNode sync_node(&trans); |
| if (change.change_type() == SyncChange::ACTION_DELETE) { |
| - if (!AttemptDelete(change, &sync_node)) { |
| + SyncError error = AttemptDelete(change, type, type_str, &sync_node); |
|
tim (not reviewing)
2012/05/15 16:44:12
This still doesn't quite do it :P Think of OnSingl
Ilya Sherman
2012/05/16 00:43:06
*sigh* ok, new patch set up... lots of repeated co
|
| + if (error.IsSet()) { |
| NOTREACHED(); |
| - SyncError error(FROM_HERE, |
| - "Failed to delete " + type_str + " node.", |
| - type); |
| error_handler()->OnSingleDatatypeUnrecoverableError(error.location(), |
| error.message()); |
| return error; |