Chromium Code Reviews| Index: components/autofill/core/browser/webdata/autofill_metadata_change_list.cc |
| diff --git a/components/autofill/core/browser/webdata/autofill_metadata_change_list.cc b/components/autofill/core/browser/webdata/autofill_metadata_change_list.cc |
| index 5126c27de142f67ca7340b1d26640b5a74b38444..1ccad7f1dba07c4e248a6ce99b5e6c4889ef6c12 100644 |
| --- a/components/autofill/core/browser/webdata/autofill_metadata_change_list.cc |
| +++ b/components/autofill/core/browser/webdata/autofill_metadata_change_list.cc |
| @@ -6,7 +6,8 @@ |
| #include "base/location.h" |
| -using syncer::SyncError; |
| +using base::Optional; |
| +using syncer::ModelError; |
| namespace autofill { |
| @@ -19,60 +20,56 @@ AutofillMetadataChangeList::AutofillMetadataChangeList(AutofillTable* table, |
| } |
| AutofillMetadataChangeList::~AutofillMetadataChangeList() { |
| - DCHECK(!error_.IsSet()); |
| + DCHECK(!error_); |
| } |
| void AutofillMetadataChangeList::UpdateModelTypeState( |
| const sync_pb::ModelTypeState& model_type_state) { |
| - if (error_.IsSet()) { |
| + if (error_) { |
| return; |
| } |
| if (!table_->UpdateModelTypeState(type_, model_type_state)) { |
| - error_ = SyncError(FROM_HERE, SyncError::DATATYPE_ERROR, |
| - "Failed to update ModelTypeState.", type_); |
| + error_ = ModelError(FROM_HERE, "Failed to update ModelTypeState."); |
| } |
| } |
| void AutofillMetadataChangeList::ClearModelTypeState() { |
| - if (error_.IsSet()) { |
| + if (error_) { |
| return; |
| } |
| if (!table_->ClearModelTypeState(type_)) { |
| - error_ = SyncError(FROM_HERE, SyncError::DATATYPE_ERROR, |
| - "Failed to clear ModelTypeState.", type_); |
| + error_ = ModelError(FROM_HERE, "Failed to clear ModelTypeState."); |
| } |
| } |
| void AutofillMetadataChangeList::UpdateMetadata( |
| const std::string& storage_key, |
| const sync_pb::EntityMetadata& metadata) { |
| - if (error_.IsSet()) { |
| + if (error_) { |
| return; |
| } |
| if (!table_->UpdateSyncMetadata(type_, storage_key, metadata)) { |
| - error_ = SyncError(FROM_HERE, SyncError::DATATYPE_ERROR, |
| - "Failed to update entity metadata.", type_); |
| + error_ = ModelError(FROM_HERE, "Failed to update entity metadata."); |
| } |
| } |
| void AutofillMetadataChangeList::ClearMetadata(const std::string& storage_key) { |
| - if (error_.IsSet()) { |
| + if (error_) { |
| return; |
| } |
| if (!table_->ClearSyncMetadata(type_, storage_key)) { |
| - error_ = SyncError(FROM_HERE, SyncError::DATATYPE_ERROR, |
| - "Failed to clear entity metadata.", type_); |
| + error_ = ModelError(FROM_HERE, "Failed to clear entity metadata."); |
| } |
| } |
| -SyncError AutofillMetadataChangeList::TakeError() { |
| - SyncError e = error_; |
| - error_ = SyncError(); |
| - return e; |
| +Optional<ModelError> AutofillMetadataChangeList::TakeError() { |
| + Optional<ModelError> temp = error_; |
| + error_ = Optional<ModelError>(); |
|
maxbogue
2017/01/12 00:15:17
can do error_.reset() too.
skym
2017/01/12 17:44:00
Oooh, great idea. Done.
|
| + return temp; |
| } |
| } // namespace autofill |