| Index: components/sync/device_info/device_info_sync_bridge.cc
|
| diff --git a/components/sync/device_info/device_info_sync_bridge.cc b/components/sync/device_info/device_info_sync_bridge.cc
|
| index e1387abef361d7f0fcfff38b043161c3ef10810c..95def9779bb6b7b8ba7e9c4d39cfbad4ec40bf50 100644
|
| --- a/components/sync/device_info/device_info_sync_bridge.cc
|
| +++ b/components/sync/device_info/device_info_sync_bridge.cc
|
| @@ -18,8 +18,8 @@
|
| #include "components/sync/device_info/device_info_util.h"
|
| #include "components/sync/model/entity_change.h"
|
| #include "components/sync/model/metadata_batch.h"
|
| +#include "components/sync/model/model_error.h"
|
| #include "components/sync/model/mutable_data_batch.h"
|
| -#include "components/sync/model/sync_error.h"
|
| #include "components/sync/protocol/model_type_state.pb.h"
|
| #include "components/sync/protocol/sync.pb.h"
|
|
|
| @@ -113,7 +113,7 @@ DeviceInfoSyncBridge::CreateMetadataChangeList() {
|
| return WriteBatch::CreateMetadataChangeList();
|
| }
|
|
|
| -SyncError DeviceInfoSyncBridge::MergeSyncData(
|
| +ModelError DeviceInfoSyncBridge::MergeSyncData(
|
| std::unique_ptr<MetadataChangeList> metadata_change_list,
|
| EntityDataMap entity_data_map) {
|
| DCHECK(has_provider_initialized_);
|
| @@ -123,7 +123,7 @@ SyncError DeviceInfoSyncBridge::MergeSyncData(
|
| // If our dependency was yanked out from beneath us, we cannot correctly
|
| // handle this request, and all our data will be deleted soon.
|
| if (local_info == nullptr) {
|
| - return SyncError();
|
| + return ModelError();
|
| }
|
|
|
| // Local data should typically be near empty, with the only possible value
|
| @@ -164,10 +164,10 @@ SyncError DeviceInfoSyncBridge::MergeSyncData(
|
|
|
| batch->TransferMetadataChanges(std::move(metadata_change_list));
|
| CommitAndNotify(std::move(batch), has_changes);
|
| - return SyncError();
|
| + return ModelError();
|
| }
|
|
|
| -SyncError DeviceInfoSyncBridge::ApplySyncChanges(
|
| +ModelError DeviceInfoSyncBridge::ApplySyncChanges(
|
| std::unique_ptr<MetadataChangeList> metadata_change_list,
|
| EntityChangeList entity_changes) {
|
| DCHECK(has_provider_initialized_);
|
| @@ -176,7 +176,7 @@ SyncError DeviceInfoSyncBridge::ApplySyncChanges(
|
| // If our dependency was yanked out from beneath us, we cannot correctly
|
| // handle this request, and all our data will be deleted soon.
|
| if (local_info == nullptr) {
|
| - return SyncError();
|
| + return ModelError();
|
| }
|
|
|
| std::unique_ptr<WriteBatch> batch = store_->CreateWriteBatch();
|
| @@ -203,7 +203,7 @@ SyncError DeviceInfoSyncBridge::ApplySyncChanges(
|
|
|
| batch->TransferMetadataChanges(std::move(metadata_change_list));
|
| CommitAndNotify(std::move(batch), has_changes);
|
| - return SyncError();
|
| + return ModelError();
|
| }
|
|
|
| void DeviceInfoSyncBridge::GetData(StorageKeyList storage_keys,
|
| @@ -216,7 +216,7 @@ void DeviceInfoSyncBridge::GetData(StorageKeyList storage_keys,
|
| batch->Put(key, CopyToEntityData(*iter->second));
|
| }
|
| }
|
| - callback.Run(SyncError(), std::move(batch));
|
| + callback.Run(std::move(batch));
|
| }
|
|
|
| void DeviceInfoSyncBridge::GetAllData(DataCallback callback) {
|
| @@ -224,7 +224,7 @@ void DeviceInfoSyncBridge::GetAllData(DataCallback callback) {
|
| for (const auto& kv : all_data_) {
|
| batch->Put(kv.first, CopyToEntityData(*kv.second));
|
| }
|
| - callback.Run(SyncError(), std::move(batch));
|
| + callback.Run(std::move(batch));
|
| }
|
|
|
| std::string DeviceInfoSyncBridge::GetClientTag(const EntityData& entity_data) {
|
| @@ -343,7 +343,8 @@ void DeviceInfoSyncBridge::OnStoreCreated(
|
| store_->ReadAllData(base::Bind(&DeviceInfoSyncBridge::OnReadAllData,
|
| base::AsWeakPtr(this)));
|
| } else {
|
| - ReportStartupErrorToSync("ModelTypeStore creation failed.");
|
| + change_processor()->ReportError(FROM_HERE,
|
| + "ModelTypeStore creation failed.");
|
| }
|
| }
|
|
|
| @@ -351,7 +352,7 @@ void DeviceInfoSyncBridge::OnReadAllData(
|
| Result result,
|
| std::unique_ptr<RecordList> record_list) {
|
| if (result != Result::SUCCESS) {
|
| - ReportStartupErrorToSync("Initial load of data failed.");
|
| + change_processor()->ReportError(FROM_HERE, "Initial load of data failed.");
|
| return;
|
| }
|
|
|
| @@ -361,7 +362,9 @@ void DeviceInfoSyncBridge::OnReadAllData(
|
| if (specifics->ParseFromString(r.value)) {
|
| all_data_[specifics->cache_guid()] = std::move(specifics);
|
| } else {
|
| - ReportStartupErrorToSync("Failed to deserialize specifics.");
|
| + change_processor()->ReportError(FROM_HERE,
|
| + "Failed to deserialize specifics.");
|
| + return;
|
| }
|
| }
|
|
|
| @@ -377,16 +380,20 @@ void DeviceInfoSyncBridge::LoadMetadataIfReady() {
|
| }
|
|
|
| void DeviceInfoSyncBridge::OnReadAllMetadata(
|
| - SyncError error,
|
| + ModelError error,
|
| std::unique_ptr<MetadataBatch> metadata_batch) {
|
| - change_processor()->OnMetadataLoaded(error, std::move(metadata_batch));
|
| + if (error.IsSet()) {
|
| + change_processor()->ReportError(error);
|
| + return;
|
| + }
|
| +
|
| + change_processor()->OnMetadataLoaded(std::move(metadata_batch));
|
| ReconcileLocalAndStored();
|
| }
|
|
|
| void DeviceInfoSyncBridge::OnCommit(Result result) {
|
| if (result != Result::SUCCESS) {
|
| - change_processor()->CreateAndUploadError(FROM_HERE,
|
| - "Failed a write to store.");
|
| + change_processor()->ReportError(FROM_HERE, "Failed a write to store.");
|
| }
|
| }
|
|
|
| @@ -472,11 +479,4 @@ int DeviceInfoSyncBridge::CountActiveDevices(const Time now) const {
|
| });
|
| }
|
|
|
| -void DeviceInfoSyncBridge::ReportStartupErrorToSync(const std::string& msg) {
|
| - // TODO(skym): Shouldn't need to log this here, reporting should always log.
|
| - LOG(WARNING) << msg;
|
| - change_processor()->OnMetadataLoaded(
|
| - change_processor()->CreateAndUploadError(FROM_HERE, msg), nullptr);
|
| -}
|
| -
|
| } // namespace syncer
|
|
|