Commit 45804446 authored by David Davidovic's avatar David Davidovic Committed by Commit Bot

[sync::consent] Remove unused CopyToEntityData function

In consent_sync_bridge_impl.cc and user_event_sync_bridge.cc, we were
using CopyToEntityData immediately after parsing the specifics, which
was unneeded. Now replaced that with MoveToEntityData and removed the
old, now unused function.

Change-Id: I4dea0cbf9a8865b611d1f95ab02a5f4fdfe9aee0
Reviewed-on: https://chromium-review.googlesource.com/1140322Reviewed-by: default avatarvitaliii <vitaliii@chromium.org>
Reviewed-by: default avatarMikel Astiz <mastiz@chromium.org>
Reviewed-by: default avatarMarkus Heintz <markusheintz@chromium.org>
Commit-Queue: David Davidović <davidovic@google.com>
Cr-Commit-Position: refs/heads/master@{#577485}
parent f474981b
...@@ -51,16 +51,6 @@ std::unique_ptr<EntityData> MoveToEntityData( ...@@ -51,16 +51,6 @@ std::unique_ptr<EntityData> MoveToEntityData(
return entity_data; return entity_data;
} }
// TODO(vitaliii): Delete this function both here and in UserEventSyncBridge.
std::unique_ptr<EntityData> CopyToEntityData(
const UserConsentSpecifics specifics) {
auto entity_data = std::make_unique<EntityData>();
entity_data->non_unique_name =
base::Int64ToString(specifics.client_consent_time_usec());
*entity_data->specifics.mutable_user_consent() = specifics;
return entity_data;
}
} // namespace } // namespace
ConsentSyncBridgeImpl::ConsentSyncBridgeImpl( ConsentSyncBridgeImpl::ConsentSyncBridgeImpl(
...@@ -296,11 +286,12 @@ void ConsentSyncBridgeImpl::OnReadAllData( ...@@ -296,11 +286,12 @@ void ConsentSyncBridgeImpl::OnReadAllData(
} }
auto batch = std::make_unique<MutableDataBatch>(); auto batch = std::make_unique<MutableDataBatch>();
UserConsentSpecifics specifics;
for (const Record& r : *data_records) { for (const Record& r : *data_records) {
if (specifics.ParseFromString(r.value)) { auto specifics = std::make_unique<UserConsentSpecifics>();
DCHECK_EQ(r.id, GetStorageKeyFromSpecifics(specifics));
batch->Put(r.id, CopyToEntityData(specifics)); if (specifics->ParseFromString(r.value)) {
DCHECK_EQ(r.id, GetStorageKeyFromSpecifics(*specifics));
batch->Put(r.id, MoveToEntityData(std::move(specifics)));
} else { } else {
change_processor()->ReportError( change_processor()->ReportError(
{FROM_HERE, "Failed deserializing user events."}); {FROM_HERE, "Failed deserializing user events."});
......
...@@ -59,15 +59,6 @@ std::unique_ptr<EntityData> MoveToEntityData( ...@@ -59,15 +59,6 @@ std::unique_ptr<EntityData> MoveToEntityData(
return entity_data; return entity_data;
} }
std::unique_ptr<EntityData> CopyToEntityData(
const UserEventSpecifics specifics) {
auto entity_data = std::make_unique<EntityData>();
entity_data->non_unique_name =
base::Int64ToString(specifics.event_time_usec());
*entity_data->specifics.mutable_user_event() = specifics;
return entity_data;
}
} // namespace } // namespace
UserEventSyncBridge::UserEventSyncBridge( UserEventSyncBridge::UserEventSyncBridge(
...@@ -358,11 +349,12 @@ void UserEventSyncBridge::OnReadAllData( ...@@ -358,11 +349,12 @@ void UserEventSyncBridge::OnReadAllData(
} }
auto batch = std::make_unique<MutableDataBatch>(); auto batch = std::make_unique<MutableDataBatch>();
UserEventSpecifics specifics;
for (const Record& r : *data_records) { for (const Record& r : *data_records) {
if (specifics.ParseFromString(r.value)) { auto specifics = std::make_unique<UserEventSpecifics>();
DCHECK_EQ(r.id, GetStorageKeyFromSpecifics(specifics));
batch->Put(r.id, CopyToEntityData(specifics)); if (specifics->ParseFromString(r.value)) {
DCHECK_EQ(r.id, GetStorageKeyFromSpecifics(*specifics));
batch->Put(r.id, MoveToEntityData(std::move(specifics)));
} else { } else {
change_processor()->ReportError( change_processor()->ReportError(
{FROM_HERE, "Failed deserializing user events."}); {FROM_HERE, "Failed deserializing user events."});
......
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