Commit e9c53838 authored by vitaliii's avatar vitaliii Committed by Commit Bot

[Sync:Sharing] Wrap per-datatype specific error into message.

This simplifies passing it around both on the client and on the server.

Bug: 1043929
Change-Id: If04978a2757d6bdda3366f1882b85978b3aa3b55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2017355
Commit-Queue: vitaliii <vitaliii@chromium.org>
Commit-Queue: Marc Treib <treib@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Auto-Submit: vitaliii <vitaliii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#734896}
parent e5eb732c
......@@ -126,8 +126,9 @@ void SharingMessageBridgeImpl::OnCommitAttemptErrors(
// TODO(rushans): untrack entity in change processor on error. We cannot
// untrack it by only client tag hash and there is no storage key in
// response data.
ProcessCommitResponse(response.client_tag_hash,
response.sharing_message_error);
ProcessCommitResponse(
response.client_tag_hash,
response.datatype_specific_error.sharing_message_error());
}
}
......
......@@ -134,8 +134,8 @@ TEST_F(SharingMessageBridgeTest, ShouldInvokeCallbackOnFailure) {
{
syncer::FailedCommitResponseData response;
response.client_tag_hash = entity_data.client_tag_hash;
response.sharing_message_error.set_error_code(
sync_pb::SharingMessageCommitError::PERMISSION_DENIED);
response.datatype_specific_error.mutable_sharing_message_error()
->set_error_code(sync_pb::SharingMessageCommitError::PERMISSION_DENIED);
response_list.push_back(std::move(response));
}
bridge()->OnCommitAttemptErrors(response_list);
......
......@@ -77,9 +77,8 @@ struct FailedCommitResponseData {
sync_pb::CommitResponse::ResponseType response_type =
sync_pb::CommitResponse::TRANSIENT_ERROR;
// Datatype specific errors (populated only if committed item is of that
// datatype).
sync_pb::SharingMessageCommitError sharing_message_error;
sync_pb::CommitResponse::EntryResponse::DatatypeSpecificError
datatype_specific_error;
};
struct UpdateResponseData {
......
......@@ -17,17 +17,6 @@
namespace syncer {
namespace {
void SetDatatypeError(const sync_pb::CommitResponse_EntryResponse& response,
FailedCommitResponseData* data) {
if (response.has_sharing_message_error()) {
data->sharing_message_error = response.sharing_message_error();
}
}
} // namespace
NonBlockingTypeCommitContribution::NonBlockingTypeCommitContribution(
ModelType type,
const sync_pb::DataTypeContext& context,
......@@ -140,7 +129,8 @@ SyncerError NonBlockingTypeCommitContribution::ProcessCommitResponse(
response_data.client_tag_hash = commit_request.entity->client_tag_hash;
response_data.response_type = entry_response.response_type();
SetDatatypeError(entry_response, &response_data);
response_data.datatype_specific_error =
entry_response.datatype_specific_error();
error_response_list.push_back(response_data);
switch (entry_response.response_type()) {
......
......@@ -305,7 +305,8 @@ TEST(NonBlockingTypeCommitContributionTest,
commit_response->add_entryresponse();
entry->set_response_type(CommitResponse::TRANSIENT_ERROR);
SharingMessageCommitError* sharing_message_error =
entry->mutable_sharing_message_error();
entry->mutable_datatype_specific_error()
->mutable_sharing_message_error();
sharing_message_error->set_error_code(
SharingMessageCommitError::INVALID_ARGUMENT);
}
......@@ -318,8 +319,9 @@ TEST(NonBlockingTypeCommitContributionTest,
FailedCommitResponseData failed_item = actual_error_response_list[0];
EXPECT_EQ(ClientTagHash::FromHashed("hash"), failed_item.client_tag_hash);
EXPECT_EQ(CommitResponse::TRANSIENT_ERROR, failed_item.response_type);
EXPECT_EQ(SharingMessageCommitError::INVALID_ARGUMENT,
failed_item.sharing_message_error.error_code());
EXPECT_EQ(
SharingMessageCommitError::INVALID_ARGUMENT,
failed_item.datatype_specific_error.sharing_message_error().error_code());
}
} // namespace
......
......@@ -2451,8 +2451,8 @@ TEST_F(ClientTagBasedModelTypeProcessorTest,
FailedCommitResponseData response_data;
response_data.client_tag_hash = GetHash("dummy tag");
response_data.response_type = sync_pb::CommitResponse::TRANSIENT_ERROR;
response_data.sharing_message_error.set_error_code(
sync_pb::SharingMessageCommitError::INVALID_ARGUMENT);
response_data.datatype_specific_error.mutable_sharing_message_error()
->set_error_code(sync_pb::SharingMessageCommitError::INVALID_ARGUMENT);
FailedCommitResponseDataList failed_list;
failed_list.push_back(response_data);
......@@ -2480,8 +2480,11 @@ TEST_F(ClientTagBasedModelTypeProcessorTest,
actual_error_response_list[0].client_tag_hash);
EXPECT_EQ(response_data.response_type,
actual_error_response_list[0].response_type);
EXPECT_EQ(response_data.sharing_message_error.error_code(),
actual_error_response_list[0].sharing_message_error.error_code());
EXPECT_EQ(response_data.datatype_specific_error.sharing_message_error()
.error_code(),
actual_error_response_list[0]
.datatype_specific_error.sharing_message_error()
.error_code());
}
TEST_F(ClientTagBasedModelTypeProcessorTest,
......
......@@ -868,10 +868,13 @@ message CommitResponse {
// to override the client-supplied mtime during a commit operation.
optional int64 mtime = 10;
// Datatype specific error (if any).
oneof datatype_error {
SharingMessageCommitError sharing_message_error = 11;
message DatatypeSpecificError {
oneof datatype_error {
SharingMessageCommitError sharing_message_error = 1;
}
}
// Datatype specific error (if any).
optional DatatypeSpecificError datatype_specific_error = 11;
}
}
......
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