Get rid of unique_ptrs for UpdateResponseData and EntityData.
Immutability for const UpdateResponseDataList should be preserved for
its members UpdateResponseData and EntityData. That's why this CL
replaces unique_ptrs with movable semantics for UpdateResponseData
and EntityData.
Bug: 1029267
Change-Id: Ia5e8d35e81939ed9f21ebb56c9d5922c053fc42d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1980736
Commit-Queue: Mikel Astiz <[email protected]>
Reviewed-by: Olivier Robin <[email protected]>
Reviewed-by: Scott Violet <[email protected]>
Reviewed-by: Alan Cutter <[email protected]>
Reviewed-by: Dominic Battré <[email protected]>
Reviewed-by: Istiaque Ahmed <[email protected]>
Reviewed-by: Mikel Astiz <[email protected]>
Cr-Commit-Position: refs/heads/master@{#729693}
diff --git a/chrome/browser/extensions/api/sessions/sessions_apitest.cc b/chrome/browser/extensions/api/sessions/sessions_apitest.cc
index 533703cc..a32ab21 100644
--- a/chrome/browser/extensions/api/sessions/sessions_apitest.cc
+++ b/chrome/browser/extensions/api/sessions/sessions_apitest.cc
@@ -234,19 +234,19 @@
// sessions (anything older than 14 days), so we cannot use
// MockModelTypeWorker's convenience functions, which internally use very
// old timestamps.
- auto header_entity_data = std::make_unique<syncer::EntityData>();
- header_entity_data->client_tag_hash =
+ syncer::EntityData header_entity_data;
+ header_entity_data.client_tag_hash =
TagHashFromSpecifics(header_entity.session());
- header_entity_data->id =
- "FakeId:" + header_entity_data->client_tag_hash.value();
- header_entity_data->specifics = header_entity;
- header_entity_data->creation_time =
+ header_entity_data.id =
+ "FakeId:" + header_entity_data.client_tag_hash.value();
+ header_entity_data.specifics = header_entity;
+ header_entity_data.creation_time =
time_now - base::TimeDelta::FromSeconds(index);
- header_entity_data->modification_time = header_entity_data->creation_time;
+ header_entity_data.modification_time = header_entity_data.creation_time;
- auto header_update = std::make_unique<syncer::UpdateResponseData>();
- header_update->entity = std::move(header_entity_data);
- header_update->response_version = 1;
+ syncer::UpdateResponseData header_update;
+ header_update.entity = std::move(header_entity_data);
+ header_update.response_version = 1;
syncer::UpdateResponseDataList updates;
updates.push_back(std::move(header_update));
worker.UpdateFromServer(std::move(updates));
diff --git a/chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.cc b/chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.cc
index dd5237e..f0c7abc 100644
--- a/chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.cc
+++ b/chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.cc
@@ -301,20 +301,19 @@
return specifics;
}
-std::unique_ptr<syncer::UpdateResponseData>
-RecentTabsBuilderTestHelper::BuildUpdateResponseData(
+syncer::UpdateResponseData RecentTabsBuilderTestHelper::BuildUpdateResponseData(
const sync_pb::SessionSpecifics& specifics,
base::Time timestamp) {
- auto entity = std::make_unique<syncer::EntityData>();
- *entity->specifics.mutable_session() = specifics;
- entity->creation_time = timestamp;
- entity->modification_time = timestamp;
- entity->client_tag_hash = syncer::ClientTagHash::FromUnhashed(
+ syncer::EntityData entity;
+ *entity.specifics.mutable_session() = specifics;
+ entity.creation_time = timestamp;
+ entity.modification_time = timestamp;
+ entity.client_tag_hash = syncer::ClientTagHash::FromUnhashed(
syncer::SESSIONS, sync_sessions::SessionStore::GetClientTag(specifics));
- entity->id = entity->client_tag_hash.value();
+ entity.id = entity.client_tag_hash.value();
- auto update = std::make_unique<syncer::UpdateResponseData>();
- update->entity = std::move(entity);
- update->response_version = ++next_response_version_;
+ syncer::UpdateResponseData update;
+ update.entity = std::move(entity);
+ update.response_version = ++next_response_version_;
return update;
}
diff --git a/chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.h b/chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.h
index b8dae09..17cacd5 100644
--- a/chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.h
+++ b/chrome/browser/ui/toolbar/recent_tabs_builder_test_helper.h
@@ -67,7 +67,7 @@
sync_pb::SessionSpecifics BuildTabSpecifics(int session_index,
int window_index,
int tab_index);
- std::unique_ptr<syncer::UpdateResponseData> BuildUpdateResponseData(
+ syncer::UpdateResponseData BuildUpdateResponseData(
const sync_pb::SessionSpecifics& specifics,
base::Time timestamp);
diff --git a/chrome/browser/web_applications/web_app_sync_bridge_unittest.cc b/chrome/browser/web_applications/web_app_sync_bridge_unittest.cc
index 8fe5ad2..28b531b4 100644
--- a/chrome/browser/web_applications/web_app_sync_bridge_unittest.cc
+++ b/chrome/browser/web_applications/web_app_sync_bridge_unittest.cc
@@ -140,11 +140,11 @@
switch (change_type) {
case syncer::EntityChange::ACTION_ADD:
entity_change = syncer::EntityChange::CreateAdd(
- app.app_id(), CreateSyncEntityData(app));
+ app.app_id(), std::move(*CreateSyncEntityData(app)));
break;
case syncer::EntityChange::ACTION_UPDATE:
entity_change = syncer::EntityChange::CreateUpdate(
- app.app_id(), CreateSyncEntityData(app));
+ app.app_id(), std::move(*CreateSyncEntityData(app)));
break;
case syncer::EntityChange::ACTION_DELETE:
entity_change = syncer::EntityChange::CreateDelete(app.app_id());
diff --git a/chromeos/components/sync_wifi/wifi_configuration_bridge_unittest.cc b/chromeos/components/sync_wifi/wifi_configuration_bridge_unittest.cc
index f263deb..9991cb9 100644
--- a/chromeos/components/sync_wifi/wifi_configuration_bridge_unittest.cc
+++ b/chromeos/components/sync_wifi/wifi_configuration_bridge_unittest.cc
@@ -43,13 +43,13 @@
const char kSsidMeow[] = "meow";
const char kSsidWoof[] = "woof";
-std::unique_ptr<syncer::EntityData> GenerateWifiEntityData(
+syncer::EntityData GenerateWifiEntityData(
const sync_pb::WifiConfigurationSpecificsData& data) {
- auto entity_data = std::make_unique<syncer::EntityData>();
- entity_data->specifics.mutable_wifi_configuration()
+ syncer::EntityData entity_data;
+ entity_data.specifics.mutable_wifi_configuration()
->mutable_client_only_encrypted_data()
->CopyFrom(data);
- entity_data->name = data.hex_ssid();
+ entity_data.name = data.hex_ssid();
return entity_data;
}
@@ -113,13 +113,13 @@
const std::vector<WifiConfigurationSpecificsData>& specifics_list) {
syncer::EntityChangeList changes;
for (const auto& data : specifics_list) {
- auto entity_data = std::make_unique<syncer::EntityData>();
+ syncer::EntityData entity_data;
sync_pb::WifiConfigurationSpecifics specifics;
specifics.mutable_client_only_encrypted_data()->CopyFrom(data);
- entity_data->specifics.mutable_wifi_configuration()->CopyFrom(specifics);
+ entity_data.specifics.mutable_wifi_configuration()->CopyFrom(specifics);
- entity_data->name = data.hex_ssid();
+ entity_data.name = data.hex_ssid();
changes.push_back(syncer::EntityChange::CreateAdd(
data.hex_ssid(), std::move(entity_data)));
diff --git a/components/autofill/core/browser/webdata/autocomplete_sync_bridge_unittest.cc b/components/autofill/core/browser/webdata/autocomplete_sync_bridge_unittest.cc
index 66e412c..d559076 100644
--- a/components/autofill/core/browser/webdata/autocomplete_sync_bridge_unittest.cc
+++ b/components/autofill/core/browser/webdata/autocomplete_sync_bridge_unittest.cc
@@ -220,13 +220,13 @@
}
std::string GetClientTag(const AutofillSpecifics& specifics) {
- std::string tag = bridge()->GetClientTag(*SpecificsToEntity(specifics));
+ std::string tag = bridge()->GetClientTag(SpecificsToEntity(specifics));
EXPECT_FALSE(tag.empty());
return tag;
}
std::string GetStorageKey(const AutofillSpecifics& specifics) {
- std::string key = bridge()->GetStorageKey(*SpecificsToEntity(specifics));
+ std::string key = bridge()->GetStorageKey(SpecificsToEntity(specifics));
EXPECT_FALSE(key.empty());
return key;
}
@@ -241,19 +241,18 @@
return changes;
}
- std::unique_ptr<EntityData> SpecificsToEntity(
- const AutofillSpecifics& specifics) {
- auto data = std::make_unique<EntityData>();
- *data->specifics.mutable_autofill() = specifics;
- data->client_tag_hash = syncer::ClientTagHash::FromUnhashed(
- syncer::AUTOFILL, bridge()->GetClientTag(*data));
+ EntityData SpecificsToEntity(const AutofillSpecifics& specifics) {
+ EntityData data;
+ *data.specifics.mutable_autofill() = specifics;
+ data.client_tag_hash = syncer::ClientTagHash::FromUnhashed(
+ syncer::AUTOFILL, bridge()->GetClientTag(data));
return data;
}
- std::unique_ptr<syncer::UpdateResponseData> SpecificsToUpdateResponse(
+ syncer::UpdateResponseData SpecificsToUpdateResponse(
const AutofillSpecifics& specifics) {
- auto data = std::make_unique<syncer::UpdateResponseData>();
- data->entity = SpecificsToEntity(specifics);
+ syncer::UpdateResponseData data;
+ data.entity = SpecificsToEntity(specifics);
return data;
}
diff --git a/components/autofill/core/browser/webdata/autofill_profile_sync_bridge_unittest.cc b/components/autofill/core/browser/webdata/autofill_profile_sync_bridge_unittest.cc
index 0ebf17d..de79851 100644
--- a/components/autofill/core/browser/webdata/autofill_profile_sync_bridge_unittest.cc
+++ b/components/autofill/core/browser/webdata/autofill_profile_sync_bridge_unittest.cc
@@ -292,19 +292,18 @@
return data;
}
- std::unique_ptr<EntityData> SpecificsToEntity(
- const AutofillProfileSpecifics& specifics) {
- auto data = std::make_unique<EntityData>();
- *data->specifics.mutable_autofill_profile() = specifics;
- data->client_tag_hash = syncer::ClientTagHash::FromUnhashed(
- syncer::AUTOFILL_PROFILE, bridge()->GetClientTag(*data));
+ EntityData SpecificsToEntity(const AutofillProfileSpecifics& specifics) {
+ EntityData data;
+ *data.specifics.mutable_autofill_profile() = specifics;
+ data.client_tag_hash = syncer::ClientTagHash::FromUnhashed(
+ syncer::AUTOFILL_PROFILE, bridge()->GetClientTag(data));
return data;
}
- std::unique_ptr<syncer::UpdateResponseData> SpecificsToUpdateResponse(
+ syncer::UpdateResponseData SpecificsToUpdateResponse(
const AutofillProfileSpecifics& specifics) {
- auto data = std::make_unique<syncer::UpdateResponseData>();
- data->entity = SpecificsToEntity(specifics);
+ syncer::UpdateResponseData data;
+ data.entity = SpecificsToEntity(specifics);
return data;
}
diff --git a/components/autofill/core/browser/webdata/autofill_sync_bridge_util_unittest.cc b/components/autofill/core/browser/webdata/autofill_sync_bridge_util_unittest.cc
index 39e44a9a..52e23a4 100644
--- a/components/autofill/core/browser/webdata/autofill_sync_bridge_util_unittest.cc
+++ b/components/autofill/core/browser/webdata/autofill_sync_bridge_util_unittest.cc
@@ -46,12 +46,11 @@
DISALLOW_COPY_AND_ASSIGN(TestAutofillTable);
};
-std::unique_ptr<EntityData> SpecificsToEntity(
- const sync_pb::AutofillWalletSpecifics& specifics,
- const std::string& client_tag) {
- auto data = std::make_unique<syncer::EntityData>();
- *data->specifics.mutable_autofill_wallet() = specifics;
- data->client_tag_hash = syncer::ClientTagHash::FromUnhashed(
+EntityData SpecificsToEntity(const sync_pb::AutofillWalletSpecifics& specifics,
+ const std::string& client_tag) {
+ syncer::EntityData data;
+ *data.specifics.mutable_autofill_wallet() = specifics;
+ data.client_tag_hash = syncer::ClientTagHash::FromUnhashed(
syncer::AUTOFILL_WALLET_DATA, client_tag);
return data;
}
diff --git a/components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge_unittest.cc b/components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge_unittest.cc
index 23f973c..fed8e9a 100644
--- a/components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge_unittest.cc
+++ b/components/autofill/core/browser/webdata/autofill_wallet_metadata_sync_bridge_unittest.cc
@@ -348,28 +348,27 @@
real_processor_->OnUpdateReceived(state, std::move(updates));
}
- std::unique_ptr<EntityData> SpecificsToEntity(
- const WalletMetadataSpecifics& specifics,
- bool is_deleted = false) {
- auto data = std::make_unique<EntityData>();
- *data->specifics.mutable_wallet_metadata() = specifics;
- data->client_tag_hash = syncer::ClientTagHash::FromUnhashed(
- syncer::AUTOFILL_WALLET_METADATA, bridge()->GetClientTag(*data));
+ EntityData SpecificsToEntity(const WalletMetadataSpecifics& specifics,
+ bool is_deleted = false) {
+ EntityData data;
+ *data.specifics.mutable_wallet_metadata() = specifics;
+ data.client_tag_hash = syncer::ClientTagHash::FromUnhashed(
+ syncer::AUTOFILL_WALLET_METADATA, bridge()->GetClientTag(data));
if (is_deleted) {
// Specifics had to be set in order to generate the client tag. Since
// deleted entity is defined by specifics being empty, we need to clear
// them now.
- data->specifics = sync_pb::EntitySpecifics();
+ data.specifics = sync_pb::EntitySpecifics();
}
return data;
}
- std::unique_ptr<syncer::UpdateResponseData> SpecificsToUpdateResponse(
+ syncer::UpdateResponseData SpecificsToUpdateResponse(
const WalletMetadataSpecifics& specifics,
bool is_deleted = false) {
- auto data = std::make_unique<syncer::UpdateResponseData>();
- data->entity = SpecificsToEntity(specifics, is_deleted);
- data->response_version = response_version;
+ syncer::UpdateResponseData data;
+ data.entity = SpecificsToEntity(specifics, is_deleted);
+ data.response_version = response_version;
return data;
}
@@ -467,7 +466,7 @@
ResetBridge();
WalletMetadataSpecifics specifics =
CreateWalletMetadataSpecificsForAddress(kAddr1SpecificsId);
- EXPECT_EQ(bridge()->GetClientTag(*SpecificsToEntity(specifics)),
+ EXPECT_EQ(bridge()->GetClientTag(SpecificsToEntity(specifics)),
kAddr1SyncTag);
}
@@ -475,7 +474,7 @@
ResetBridge();
WalletMetadataSpecifics specifics =
CreateWalletMetadataSpecificsForCard(kCard1SpecificsId);
- EXPECT_EQ(bridge()->GetClientTag(*SpecificsToEntity(specifics)),
+ EXPECT_EQ(bridge()->GetClientTag(SpecificsToEntity(specifics)),
kCard1SyncTag);
}
@@ -484,7 +483,7 @@
ResetBridge();
WalletMetadataSpecifics specifics =
CreateWalletMetadataSpecificsForAddress(kAddr1SpecificsId);
- EXPECT_EQ(bridge()->GetStorageKey(*SpecificsToEntity(specifics)),
+ EXPECT_EQ(bridge()->GetStorageKey(SpecificsToEntity(specifics)),
GetAddressStorageKey(kAddr1SpecificsId));
}
@@ -492,7 +491,7 @@
ResetBridge();
WalletMetadataSpecifics specifics =
CreateWalletMetadataSpecificsForCard(kCard1SpecificsId);
- EXPECT_EQ(bridge()->GetStorageKey(*SpecificsToEntity(specifics)),
+ EXPECT_EQ(bridge()->GetStorageKey(SpecificsToEntity(specifics)),
GetCardStorageKey(kCard1SpecificsId));
}
diff --git a/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge_unittest.cc b/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge_unittest.cc
index 69d194b..03e489c 100644
--- a/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge_unittest.cc
+++ b/components/autofill/core/browser/webdata/autofill_wallet_sync_bridge_unittest.cc
@@ -278,12 +278,11 @@
EXPECT_EQ(addresses_count, addresses_metadata.size());
}
- std::unique_ptr<EntityData> SpecificsToEntity(
- const AutofillWalletSpecifics& specifics) {
- auto data = std::make_unique<EntityData>();
- *data->specifics.mutable_autofill_wallet() = specifics;
- data->client_tag_hash = syncer::ClientTagHash::FromUnhashed(
- syncer::AUTOFILL_WALLET_DATA, bridge()->GetClientTag(*data));
+ EntityData SpecificsToEntity(const AutofillWalletSpecifics& specifics) {
+ EntityData data;
+ *data.specifics.mutable_autofill_wallet() = specifics;
+ data.client_tag_hash = syncer::ClientTagHash::FromUnhashed(
+ syncer::AUTOFILL_WALLET_DATA, bridge()->GetClientTag(data));
return data;
}
@@ -300,10 +299,10 @@
return data;
}
- std::unique_ptr<syncer::UpdateResponseData> SpecificsToUpdateResponse(
+ syncer::UpdateResponseData SpecificsToUpdateResponse(
const AutofillWalletSpecifics& specifics) {
- auto data = std::make_unique<syncer::UpdateResponseData>();
- data->entity = SpecificsToEntity(specifics);
+ syncer::UpdateResponseData data;
+ data.entity = SpecificsToEntity(specifics);
return data;
}
@@ -335,14 +334,14 @@
TEST_F(AutofillWalletSyncBridgeTest, GetClientTagForAddress) {
AutofillWalletSpecifics specifics =
CreateAutofillWalletSpecificsForAddress(kAddr1ClientTag);
- EXPECT_EQ(bridge()->GetClientTag(*SpecificsToEntity(specifics)),
+ EXPECT_EQ(bridge()->GetClientTag(SpecificsToEntity(specifics)),
kAddr1ClientTag);
}
TEST_F(AutofillWalletSyncBridgeTest, GetClientTagForCard) {
AutofillWalletSpecifics specifics =
CreateAutofillWalletSpecificsForCard(kCard1ClientTag);
- EXPECT_EQ(bridge()->GetClientTag(*SpecificsToEntity(specifics)),
+ EXPECT_EQ(bridge()->GetClientTag(SpecificsToEntity(specifics)),
kCard1ClientTag);
}
@@ -350,7 +349,7 @@
AutofillWalletSpecifics specifics =
CreateAutofillWalletSpecificsForPaymentsCustomerData(
kCustomerDataClientTag);
- EXPECT_EQ(bridge()->GetClientTag(*SpecificsToEntity(specifics)),
+ EXPECT_EQ(bridge()->GetClientTag(SpecificsToEntity(specifics)),
kCustomerDataClientTag);
}
@@ -358,7 +357,7 @@
AutofillWalletSpecifics specifics =
CreateAutofillWalletSpecificsForCreditCardCloudTokenData(
kCloudTokenDataClientTag);
- EXPECT_EQ(bridge()->GetClientTag(*SpecificsToEntity(specifics)),
+ EXPECT_EQ(bridge()->GetClientTag(SpecificsToEntity(specifics)),
kCloudTokenDataClientTag);
}
@@ -366,14 +365,14 @@
TEST_F(AutofillWalletSyncBridgeTest, GetStorageKeyForAddress) {
AutofillWalletSpecifics specifics1 =
CreateAutofillWalletSpecificsForAddress(kAddr1ClientTag);
- EXPECT_EQ(bridge()->GetStorageKey(*SpecificsToEntity(specifics1)),
+ EXPECT_EQ(bridge()->GetStorageKey(SpecificsToEntity(specifics1)),
kAddr1ClientTag);
}
TEST_F(AutofillWalletSyncBridgeTest, GetStorageKeyForCard) {
AutofillWalletSpecifics specifics2 =
CreateAutofillWalletSpecificsForCard(kCard1ClientTag);
- EXPECT_EQ(bridge()->GetStorageKey(*SpecificsToEntity(specifics2)),
+ EXPECT_EQ(bridge()->GetStorageKey(SpecificsToEntity(specifics2)),
kCard1ClientTag);
}
@@ -381,7 +380,7 @@
AutofillWalletSpecifics specifics3 =
CreateAutofillWalletSpecificsForPaymentsCustomerData(
kCustomerDataClientTag);
- EXPECT_EQ(bridge()->GetStorageKey(*SpecificsToEntity(specifics3)),
+ EXPECT_EQ(bridge()->GetStorageKey(SpecificsToEntity(specifics3)),
kCustomerDataClientTag);
}
@@ -389,7 +388,7 @@
AutofillWalletSpecifics specifics4 =
CreateAutofillWalletSpecificsForCreditCardCloudTokenData(
kCloudTokenDataClientTag);
- EXPECT_EQ(bridge()->GetStorageKey(*SpecificsToEntity(specifics4)),
+ EXPECT_EQ(bridge()->GetStorageKey(SpecificsToEntity(specifics4)),
kCloudTokenDataClientTag);
}
diff --git a/components/history/core/browser/sync/typed_url_sync_bridge_unittest.cc b/components/history/core/browser/sync/typed_url_sync_bridge_unittest.cc
index 8254afc..e5b6c1f 100644
--- a/components/history/core/browser/sync/typed_url_sync_bridge_unittest.cc
+++ b/components/history/core/browser/sync/typed_url_sync_bridge_unittest.cc
@@ -400,10 +400,9 @@
return bridge()->GetStorageKeyInternal(url);
}
- std::unique_ptr<EntityData> SpecificsToEntity(
- const TypedUrlSpecifics& specifics) {
- auto data = std::make_unique<EntityData>();
- *data->specifics.mutable_typed_url() = specifics;
+ EntityData SpecificsToEntity(const TypedUrlSpecifics& specifics) {
+ EntityData data;
+ *data.specifics.mutable_typed_url() = specifics;
return data;
}
diff --git a/components/password_manager/core/browser/sync/password_sync_bridge_unittest.cc b/components/password_manager/core/browser/sync/password_sync_bridge_unittest.cc
index ff93af0..bb38b88f 100644
--- a/components/password_manager/core/browser/sync/password_sync_bridge_unittest.cc
+++ b/components/password_manager/core/browser/sync/password_sync_bridge_unittest.cc
@@ -259,12 +259,12 @@
}
// Creates an EntityData around a copy of the given specifics.
- std::unique_ptr<syncer::EntityData> SpecificsToEntity(
+ syncer::EntityData SpecificsToEntity(
const sync_pb::PasswordSpecifics& specifics) {
- auto data = std::make_unique<syncer::EntityData>();
- *data->specifics.mutable_password() = specifics;
- data->client_tag_hash = syncer::ClientTagHash::FromUnhashed(
- syncer::PASSWORDS, bridge()->GetClientTag(*data));
+ syncer::EntityData data;
+ *data.specifics.mutable_password() = specifics;
+ data.client_tag_hash = syncer::ClientTagHash::FromUnhashed(
+ syncer::PASSWORDS, bridge()->GetClientTag(data));
return data;
}
@@ -436,7 +436,7 @@
EXPECT_CALL(mock_processor(),
UntrackEntityForClientTagHash(
- SpecificsToEntity(specifics)->client_tag_hash));
+ SpecificsToEntity(specifics).client_tag_hash));
syncer::EntityChangeList entity_change_list;
entity_change_list.push_back(syncer::EntityChange::CreateAdd(
@@ -732,7 +732,7 @@
EXPECT_CALL(mock_processor(),
UntrackEntityForClientTagHash(
- SpecificsToEntity(specifics)->client_tag_hash));
+ SpecificsToEntity(specifics).client_tag_hash));
syncer::EntityChangeList entity_change_list;
entity_change_list.push_back(syncer::EntityChange::CreateAdd(
diff --git a/components/reading_list/core/reading_list_store_unittest.cc b/components/reading_list/core/reading_list_store_unittest.cc
index 89e581d..8e31def 100644
--- a/components/reading_list/core/reading_list_store_unittest.cc
+++ b/components/reading_list/core/reading_list_store_unittest.cc
@@ -199,8 +199,8 @@
std::unique_ptr<sync_pb::ReadingListSpecifics> specifics =
entry.AsReadingListSpecifics();
- auto data = std::make_unique<syncer::EntityData>();
- *data->specifics.mutable_reading_list() = *specifics;
+ syncer::EntityData data;
+ *data.specifics.mutable_reading_list() = *specifics;
remote_input.push_back(syncer::EntityChange::CreateAdd(
"http://read.example.com/", std::move(data)));
@@ -223,8 +223,8 @@
entry.SetRead(true, AdvanceAndGetTime(&clock_));
std::unique_ptr<sync_pb::ReadingListSpecifics> specifics =
entry.AsReadingListSpecifics();
- auto data = std::make_unique<syncer::EntityData>();
- *data->specifics.mutable_reading_list() = *specifics;
+ syncer::EntityData data;
+ *data.specifics.mutable_reading_list() = *specifics;
syncer::EntityChangeList add_changes;
@@ -248,8 +248,8 @@
new_entry.SetRead(true, AdvanceAndGetTime(&clock_));
std::unique_ptr<sync_pb::ReadingListSpecifics> specifics =
new_entry.AsReadingListSpecifics();
- auto data = std::make_unique<syncer::EntityData>();
- *data->specifics.mutable_reading_list() = *specifics;
+ syncer::EntityData data;
+ *data.specifics.mutable_reading_list() = *specifics;
EXPECT_CALL(processor_, Put("http://unread.example.com/", _, _));
@@ -277,8 +277,8 @@
std::unique_ptr<sync_pb::ReadingListSpecifics> specifics =
old_entry.AsReadingListSpecifics();
- auto data = std::make_unique<syncer::EntityData>();
- *data->specifics.mutable_reading_list() = *specifics;
+ syncer::EntityData data;
+ *data.specifics.mutable_reading_list() = *specifics;
EXPECT_CALL(processor_, Put("http://unread.example.com/", _, _));
diff --git a/components/send_tab_to_self/send_tab_to_self_bridge_unittest.cc b/components/send_tab_to_self/send_tab_to_self_bridge_unittest.cc
index 0261a61..9ab9917 100644
--- a/components/send_tab_to_self/send_tab_to_self_bridge_unittest.cc
+++ b/components/send_tab_to_self/send_tab_to_self_bridge_unittest.cc
@@ -132,15 +132,13 @@
ON_CALL(mock_processor_, IsTrackingMetadata()).WillByDefault(Return(false));
}
- std::unique_ptr<syncer::EntityData> MakeEntityData(
- const SendTabToSelfEntry& entry) {
+ syncer::EntityData MakeEntityData(const SendTabToSelfEntry& entry) {
SendTabToSelfLocal specifics = entry.AsLocalProto();
- auto entity_data = std::make_unique<syncer::EntityData>();
+ syncer::EntityData entity_data;
- *(entity_data->specifics.mutable_send_tab_to_self()) =
- specifics.specifics();
- entity_data->name = entry.GetURL().spec();
+ *entity_data.specifics.mutable_send_tab_to_self() = specifics.specifics();
+ entity_data.name = entry.GetURL().spec();
return entity_data;
}
@@ -151,10 +149,10 @@
const std::vector<sync_pb::SendTabToSelfSpecifics>& specifics_list) {
syncer::EntityChangeList changes;
for (const auto& specifics : specifics_list) {
- auto entity_data = std::make_unique<syncer::EntityData>();
+ syncer::EntityData entity_data;
- *(entity_data->specifics.mutable_send_tab_to_self()) = specifics;
- entity_data->name = specifics.url();
+ *entity_data.specifics.mutable_send_tab_to_self() = specifics;
+ entity_data.name = specifics.url();
changes.push_back(syncer::EntityChange::CreateAdd(
specifics.guid(), std::move(entity_data)));
diff --git a/components/sync/engine/non_blocking_sync_common.h b/components/sync/engine/non_blocking_sync_common.h
index 82044a01..89ab448 100644
--- a/components/sync/engine/non_blocking_sync_common.h
+++ b/components/sync/engine/non_blocking_sync_common.h
@@ -62,20 +62,22 @@
struct UpdateResponseData {
UpdateResponseData();
+ UpdateResponseData(UpdateResponseData&&) = default;
+ UpdateResponseData& operator=(UpdateResponseData&&) = default;
~UpdateResponseData();
- std::unique_ptr<EntityData> entity;
+ UpdateResponseData(const UpdateResponseData&) = delete;
+ UpdateResponseData& operator=(const UpdateResponseData&) = delete;
+
+ EntityData entity;
int64_t response_version = 0;
std::string encryption_key_name;
-
- private:
- DISALLOW_COPY_AND_ASSIGN(UpdateResponseData);
};
using CommitRequestDataList = std::vector<std::unique_ptr<CommitRequestData>>;
using CommitResponseDataList = std::vector<CommitResponseData>;
-using UpdateResponseDataList = std::vector<std::unique_ptr<UpdateResponseData>>;
+using UpdateResponseDataList = std::vector<UpdateResponseData>;
// Returns the estimate of dynamically allocated memory in bytes.
size_t EstimateMemoryUsage(const CommitRequestData& value);
diff --git a/components/sync/engine_impl/model_type_worker.cc b/components/sync/engine_impl/model_type_worker.cc
index 3e2b759..383f60d 100644
--- a/components/sync/engine_impl/model_type_worker.cc
+++ b/components/sync/engine_impl/model_type_worker.cc
@@ -183,9 +183,9 @@
}
}
- auto response_data = std::make_unique<UpdateResponseData>();
+ UpdateResponseData response_data;
switch (PopulateUpdateResponseData(cryptographer_.get(), type_,
- *update_entity, response_data.get())) {
+ *update_entity, &response_data)) {
case SUCCESS:
pending_updates_.push_back(std::move(response_data));
break;
@@ -212,7 +212,7 @@
ModelType model_type,
const sync_pb::SyncEntity& update_entity,
UpdateResponseData* response_data) {
- auto data = std::make_unique<syncer::EntityData>();
+ syncer::EntityData data;
// Deleted entities must use the default instance of EntitySpecifics in
// order for EntityData to correctly reflect that they are deleted.
@@ -233,8 +233,7 @@
if (!cryptographer->CanDecrypt(specifics.password().encrypted())) {
return DECRYPTION_PENDING;
}
- if (!DecryptPasswordSpecifics(*cryptographer, specifics,
- &data->specifics)) {
+ if (!DecryptPasswordSpecifics(*cryptographer, specifics, &data.specifics)) {
return FAILED_TO_DECRYPT;
}
response_data->encryption_key_name =
@@ -249,41 +248,41 @@
return DECRYPTION_PENDING;
}
// Encrypted and we know the key.
- if (!DecryptSpecifics(*cryptographer, specifics, &data->specifics)) {
+ if (!DecryptSpecifics(*cryptographer, specifics, &data.specifics)) {
return FAILED_TO_DECRYPT;
}
response_data->encryption_key_name = specifics.encrypted().key_name();
specifics_were_encrypted = true;
} else {
// No encryption.
- data->specifics = specifics;
+ data.specifics = specifics;
}
response_data->response_version = update_entity.version();
// Prepare the message for the model thread.
- data->id = update_entity.id_string();
- data->client_tag_hash =
+ data.id = update_entity.id_string();
+ data.client_tag_hash =
ClientTagHash::FromHashed(update_entity.client_defined_unique_tag());
- data->creation_time = ProtoTimeToTime(update_entity.ctime());
- data->modification_time = ProtoTimeToTime(update_entity.mtime());
- data->name = update_entity.name();
- data->is_folder = update_entity.folder();
- data->parent_id = update_entity.parent_id_string();
- data->server_defined_unique_tag = update_entity.server_defined_unique_tag();
+ data.creation_time = ProtoTimeToTime(update_entity.ctime());
+ data.modification_time = ProtoTimeToTime(update_entity.mtime());
+ data.name = update_entity.name();
+ data.is_folder = update_entity.folder();
+ data.parent_id = update_entity.parent_id_string();
+ data.server_defined_unique_tag = update_entity.server_defined_unique_tag();
// Populate |originator_cache_guid| and |originator_client_item_id|. This is
// currently relevant only for bookmarks.
- data->originator_cache_guid = update_entity.originator_cache_guid();
- data->originator_client_item_id = update_entity.originator_client_item_id();
+ data.originator_cache_guid = update_entity.originator_cache_guid();
+ data.originator_client_item_id = update_entity.originator_client_item_id();
// Adapt the update for compatibility.
if (model_type == BOOKMARKS) {
- AdaptUniquePositionForBookmark(update_entity, data.get());
- AdaptTitleForBookmark(update_entity, &data->specifics,
+ AdaptUniquePositionForBookmark(update_entity, &data);
+ AdaptTitleForBookmark(update_entity, &data.specifics,
specifics_were_encrypted);
- AdaptGuidForBookmark(update_entity, &data->specifics);
+ AdaptGuidForBookmark(update_entity, &data.specifics);
} else if (model_type == AUTOFILL_WALLET_DATA) {
- AdaptClientTagForWalletData(data.get());
+ AdaptClientTagForWalletData(&data);
}
response_data->entity = std::move(data);
@@ -473,9 +472,9 @@
it != entries_pending_decryption_.end();) {
const sync_pb::SyncEntity& encrypted_update = it->second;
- auto response_data = std::make_unique<UpdateResponseData>();
+ UpdateResponseData response_data;
switch (PopulateUpdateResponseData(cryptographer_.get(), type_,
- encrypted_update, response_data.get())) {
+ encrypted_update, &response_data)) {
case SUCCESS:
pending_updates_.push_back(std::move(response_data));
it = entries_pending_decryption_.erase(it);
@@ -500,15 +499,14 @@
pending_updates_.reserve(candidates.size());
std::map<std::string, size_t> id_to_index;
- for (std::unique_ptr<UpdateResponseData>& candidate : candidates) {
- DCHECK(candidate);
- if (candidate->entity->id.empty()) {
+ for (UpdateResponseData& candidate : candidates) {
+ if (candidate.entity.id.empty()) {
continue;
}
// Try to insert. If we already saw an item with the same server id,
// this will fail but give us its iterator.
auto it_and_success =
- id_to_index.emplace(candidate->entity->id, pending_updates_.size());
+ id_to_index.emplace(candidate.entity.id, pending_updates_.size());
if (it_and_success.second) {
// New server id, append at the end. Note that we already inserted
// the correct index (|pending_updates_.size()|) above.
@@ -527,17 +525,16 @@
pending_updates_.reserve(candidates.size());
std::map<ClientTagHash, size_t> tag_to_index;
- for (std::unique_ptr<UpdateResponseData>& candidate : candidates) {
- DCHECK(candidate);
+ for (UpdateResponseData& candidate : candidates) {
// Items with empty client tag hash just get passed through.
- if (candidate->entity->client_tag_hash.value().empty()) {
+ if (candidate.entity.client_tag_hash.value().empty()) {
pending_updates_.push_back(std::move(candidate));
continue;
}
// Try to insert. If we already saw an item with the same client tag hash,
// this will fail but give us its iterator.
- auto it_and_success = tag_to_index.emplace(
- candidate->entity->client_tag_hash, pending_updates_.size());
+ auto it_and_success = tag_to_index.emplace(candidate.entity.client_tag_hash,
+ pending_updates_.size());
if (it_and_success.second) {
// New client tag hash, append at the end. Note that we already inserted
// the correct index (|pending_updates_.size()|) above.
@@ -556,18 +553,17 @@
pending_updates_.reserve(candidates.size());
std::map<std::string, size_t> id_to_index;
- for (std::unique_ptr<UpdateResponseData>& candidate : candidates) {
- DCHECK(candidate);
+ for (UpdateResponseData& candidate : candidates) {
// Items with empty item ID just get passed through (which is the case for
// all datatypes except bookmarks).
- if (candidate->entity->originator_client_item_id.empty()) {
+ if (candidate.entity.originator_client_item_id.empty()) {
pending_updates_.push_back(std::move(candidate));
continue;
}
// Try to insert. If we already saw an item with the same originator item
// ID, this will fail but give us its iterator.
auto it_and_success = id_to_index.emplace(
- candidate->entity->originator_client_item_id, pending_updates_.size());
+ candidate.entity.originator_client_item_id, pending_updates_.size());
if (it_and_success.second) {
// New item ID, append at the end. Note that we already inserted the
// correct index (|pending_updates_.size()|) above.
diff --git a/components/sync/engine_impl/model_type_worker_unittest.cc b/components/sync/engine_impl/model_type_worker_unittest.cc
index 7cc859c08..3150c26 100644
--- a/components/sync/engine_impl/model_type_worker_unittest.cc
+++ b/components/sync/engine_impl/model_type_worker_unittest.cc
@@ -727,7 +727,7 @@
ASSERT_TRUE(processor()->HasUpdateResponse(kHash1));
const UpdateResponseData& update = processor()->GetUpdateResponse(kHash1);
- const EntityData& entity = *update.entity;
+ const EntityData& entity = update.entity;
EXPECT_FALSE(entity.id.empty());
EXPECT_EQ(tag_hash, entity.client_tag_hash);
@@ -757,11 +757,11 @@
processor()->GetNthUpdateResponse(0);
ASSERT_EQ(3u, result.size());
ASSERT_TRUE(result[0]);
- EXPECT_EQ(GenerateTagHash(kTag1), result[0]->entity->client_tag_hash);
+ EXPECT_EQ(GenerateTagHash(kTag1), result[0]->entity.client_tag_hash);
ASSERT_TRUE(result[1]);
- EXPECT_EQ(GenerateTagHash(kTag2), result[1]->entity->client_tag_hash);
+ EXPECT_EQ(GenerateTagHash(kTag2), result[1]->entity.client_tag_hash);
ASSERT_TRUE(result[2]);
- EXPECT_EQ(GenerateTagHash(kTag3), result[2]->entity->client_tag_hash);
+ EXPECT_EQ(GenerateTagHash(kTag3), result[2]->entity.client_tag_hash);
}
TEST_F(ModelTypeWorkerTest, ReceiveUpdates_DuplicateHashWithinPartialUpdate) {
@@ -778,8 +778,8 @@
processor()->GetNthUpdateResponse(0);
ASSERT_EQ(1u, result.size());
ASSERT_TRUE(result[0]);
- EXPECT_EQ(GenerateTagHash(kTag1), result[0]->entity->client_tag_hash);
- EXPECT_EQ(kValue2, result[0]->entity->specifics.preference().value());
+ EXPECT_EQ(GenerateTagHash(kTag1), result[0]->entity.client_tag_hash);
+ EXPECT_EQ(kValue2, result[0]->entity.specifics.preference().value());
}
TEST_F(ModelTypeWorkerTest, ReceiveUpdates_DuplicateHashAcrossPartialUpdates) {
@@ -797,8 +797,8 @@
processor()->GetNthUpdateResponse(0);
ASSERT_EQ(1u, result.size());
ASSERT_TRUE(result[0]);
- EXPECT_EQ(GenerateTagHash(kTag1), result[0]->entity->client_tag_hash);
- EXPECT_EQ(kValue2, result[0]->entity->specifics.preference().value());
+ EXPECT_EQ(GenerateTagHash(kTag1), result[0]->entity.client_tag_hash);
+ EXPECT_EQ(kValue2, result[0]->entity.specifics.preference().value());
}
TEST_F(ModelTypeWorkerTest,
@@ -829,9 +829,9 @@
processor()->GetNthUpdateResponse(0);
ASSERT_EQ(2u, result.size());
ASSERT_TRUE(result[0]);
- EXPECT_EQ(entity1.id_string(), result[0]->entity->id);
+ EXPECT_EQ(entity1.id_string(), result[0]->entity.id);
ASSERT_TRUE(result[1]);
- EXPECT_EQ(entity2.id_string(), result[1]->entity->id);
+ EXPECT_EQ(entity2.id_string(), result[1]->entity.id);
}
TEST_F(ModelTypeWorkerTest, ReceiveUpdates_MultipleDuplicateHashes) {
@@ -856,12 +856,12 @@
ASSERT_TRUE(result[0]);
ASSERT_TRUE(result[1]);
ASSERT_TRUE(result[2]);
- EXPECT_EQ(GenerateTagHash(kTag1), result[0]->entity->client_tag_hash);
- EXPECT_EQ(GenerateTagHash(kTag2), result[1]->entity->client_tag_hash);
- EXPECT_EQ(GenerateTagHash(kTag3), result[2]->entity->client_tag_hash);
- EXPECT_EQ(kValue1, result[0]->entity->specifics.preference().value());
- EXPECT_EQ(kValue2, result[1]->entity->specifics.preference().value());
- EXPECT_EQ(kValue3, result[2]->entity->specifics.preference().value());
+ EXPECT_EQ(GenerateTagHash(kTag1), result[0]->entity.client_tag_hash);
+ EXPECT_EQ(GenerateTagHash(kTag2), result[1]->entity.client_tag_hash);
+ EXPECT_EQ(GenerateTagHash(kTag3), result[2]->entity.client_tag_hash);
+ EXPECT_EQ(kValue1, result[0]->entity.specifics.preference().value());
+ EXPECT_EQ(kValue2, result[1]->entity.specifics.preference().value());
+ EXPECT_EQ(kValue3, result[2]->entity.specifics.preference().value());
}
// Covers the scenario where two updates have the same client tag hash but
@@ -893,7 +893,7 @@
processor()->GetNthUpdateResponse(0);
ASSERT_EQ(1u, result.size());
ASSERT_TRUE(result[0]);
- EXPECT_EQ(entity2.id_string(), result[0]->entity->id);
+ EXPECT_EQ(entity2.id_string(), result[0]->entity.id);
}
// Covers the scenario where two updates have the same originator client item ID
@@ -931,7 +931,7 @@
processor()->GetNthUpdateResponse(0);
ASSERT_EQ(1u, result.size());
ASSERT_TRUE(result[0]);
- EXPECT_EQ(kURL2, result[0]->entity->specifics.bookmark().url());
+ EXPECT_EQ(kURL2, result[0]->entity.specifics.bookmark().url());
}
// Test that an update download coming in multiple parts gets accumulated into
@@ -952,9 +952,9 @@
processor()->GetNthUpdateResponse(0);
ASSERT_EQ(2U, updates.size());
ASSERT_TRUE(updates[0]);
- EXPECT_EQ(GenerateTagHash(kTag1), updates[0]->entity->client_tag_hash);
+ EXPECT_EQ(GenerateTagHash(kTag1), updates[0]->entity.client_tag_hash);
ASSERT_TRUE(updates[1]);
- EXPECT_EQ(GenerateTagHash(kTag2), updates[1]->entity->client_tag_hash);
+ EXPECT_EQ(GenerateTagHash(kTag2), updates[1]->entity.client_tag_hash);
// A subsequent update doesn't pass the same entities again.
TriggerUpdateFromServer(10, kTag3, kValue3);
@@ -962,7 +962,7 @@
updates = processor()->GetNthUpdateResponse(1);
ASSERT_EQ(1U, updates.size());
ASSERT_TRUE(updates[0]);
- EXPECT_EQ(GenerateTagHash(kTag3), updates[0]->entity->client_tag_hash);
+ EXPECT_EQ(GenerateTagHash(kTag3), updates[0]->entity.client_tag_hash);
}
// Test that updates with no entities behave correctly.
@@ -1109,8 +1109,8 @@
// Test some basic properties regarding the update.
ASSERT_TRUE(processor()->HasUpdateResponse(kHash1));
const UpdateResponseData& update1 = processor()->GetUpdateResponse(kHash1);
- EXPECT_EQ(kTag1, update1.entity->specifics.preference().name());
- EXPECT_EQ(kValue1, update1.entity->specifics.preference().value());
+ EXPECT_EQ(kTag1, update1.entity.specifics.preference().name());
+ EXPECT_EQ(kValue1, update1.entity.specifics.preference().value());
EXPECT_TRUE(update1.encryption_key_name.empty());
// Set received updates to be encrypted using the new nigori.
@@ -1122,8 +1122,8 @@
// Test its basic features and the value of encryption_key_name.
ASSERT_TRUE(processor()->HasUpdateResponse(kHash2));
const UpdateResponseData& update2 = processor()->GetUpdateResponse(kHash2);
- EXPECT_EQ(kTag2, update2.entity->specifics.preference().name());
- EXPECT_EQ(kValue2, update2.entity->specifics.preference().value());
+ EXPECT_EQ(kTag2, update2.entity.specifics.preference().name());
+ EXPECT_EQ(kValue2, update2.entity.specifics.preference().value());
EXPECT_FALSE(update2.encryption_key_name.empty());
}
@@ -1249,8 +1249,8 @@
EXPECT_EQ(1U, processor()->GetNumUpdateResponses());
ASSERT_TRUE(processor()->HasUpdateResponse(kHash1));
const UpdateResponseData& update = processor()->GetUpdateResponse(kHash1);
- EXPECT_EQ(kTag1, update.entity->specifics.preference().name());
- EXPECT_EQ(kValue1, update.entity->specifics.preference().value());
+ EXPECT_EQ(kTag1, update.entity.specifics.preference().name());
+ EXPECT_EQ(kValue1, update.entity.specifics.preference().value());
EXPECT_EQ(GetLocalCryptographerKeyName(), update.encryption_key_name);
}
@@ -1383,7 +1383,7 @@
EXPECT_EQ(ModelTypeWorker::SUCCESS,
ModelTypeWorker::PopulateUpdateResponseData(
&cryptographer, PREFERENCES, entity, &response_data));
- const EntityData& data = *response_data.entity;
+ const EntityData& data = response_data.entity;
EXPECT_FALSE(data.id.empty());
EXPECT_FALSE(data.parent_id.empty());
EXPECT_FALSE(data.is_folder);
@@ -1417,7 +1417,7 @@
ModelTypeWorker::PopulateUpdateResponseData(
&cryptographer, BOOKMARKS, entity, &response_data));
- const EntityData& data = *response_data.entity;
+ const EntityData& data = response_data.entity;
// A tombstone should remain a tombstone after populating the response data.
EXPECT_TRUE(data.is_deleted());
}
@@ -1440,7 +1440,7 @@
EXPECT_EQ(ModelTypeWorker::SUCCESS,
ModelTypeWorker::PopulateUpdateResponseData(
&cryptographer, BOOKMARKS, entity, &response_data));
- const EntityData& data = *response_data.entity;
+ const EntityData& data = response_data.entity;
EXPECT_TRUE(
syncer::UniquePosition::FromProto(data.unique_position).IsValid());
@@ -1468,7 +1468,7 @@
EXPECT_EQ(ModelTypeWorker::SUCCESS,
ModelTypeWorker::PopulateUpdateResponseData(
&cryptographer, BOOKMARKS, entity, &response_data));
- const EntityData& data = *response_data.entity;
+ const EntityData& data = response_data.entity;
EXPECT_TRUE(
syncer::UniquePosition::FromProto(data.unique_position).IsValid());
@@ -1496,7 +1496,7 @@
EXPECT_EQ(ModelTypeWorker::SUCCESS,
ModelTypeWorker::PopulateUpdateResponseData(
&cryptographer, BOOKMARKS, entity, &response_data));
- const EntityData& data = *response_data.entity;
+ const EntityData& data = response_data.entity;
EXPECT_TRUE(
syncer::UniquePosition::FromProto(data.unique_position).IsValid());
histogram_tester.ExpectUniqueSample(
@@ -1525,7 +1525,7 @@
EXPECT_EQ(ModelTypeWorker::SUCCESS,
ModelTypeWorker::PopulateUpdateResponseData(
&cryptographer, BOOKMARKS, entity, &response_data));
- const EntityData& data = *response_data.entity;
+ const EntityData& data = response_data.entity;
EXPECT_FALSE(
syncer::UniquePosition::FromProto(data.unique_position).IsValid());
histogram_tester.ExpectUniqueSample("Sync.Entities.PositioningScheme",
@@ -1549,7 +1549,7 @@
EXPECT_EQ(ModelTypeWorker::SUCCESS,
ModelTypeWorker::PopulateUpdateResponseData(
&cryptographer, PREFERENCES, entity, &response_data));
- const EntityData& data = *response_data.entity;
+ const EntityData& data = response_data.entity;
EXPECT_FALSE(
syncer::UniquePosition::FromProto(data.unique_position).IsValid());
histogram_tester.ExpectTotalCount("Sync.Entities.PositioningScheme",
@@ -1576,7 +1576,7 @@
ModelTypeWorker::PopulateUpdateResponseData(
&cryptographer, BOOKMARKS, entity, &response_data));
- const EntityData& data = *response_data.entity;
+ const EntityData& data = response_data.entity;
EXPECT_EQ(kGuid1, data.specifics.bookmark().guid());
EXPECT_EQ(kGuid2, data.originator_client_item_id);
@@ -1601,7 +1601,7 @@
ModelTypeWorker::PopulateUpdateResponseData(
&cryptographer, BOOKMARKS, entity, &response_data));
- const EntityData& data = *response_data.entity;
+ const EntityData& data = response_data.entity;
EXPECT_EQ(kGuid1, data.originator_client_item_id);
EXPECT_EQ(kGuid1, data.specifics.bookmark().guid());
@@ -1627,7 +1627,7 @@
ModelTypeWorker::PopulateUpdateResponseData(
&cryptographer, BOOKMARKS, entity, &response_data));
- const EntityData& data = *response_data.entity;
+ const EntityData& data = response_data.entity;
EXPECT_EQ(kInvalidOCII, data.originator_client_item_id);
EXPECT_TRUE(data.specifics.bookmark().guid().empty());
@@ -1650,7 +1650,7 @@
&cryptographer, AUTOFILL_WALLET_DATA, entity, &response_data));
// The client tag hash gets filled in by the worker.
- EXPECT_FALSE(response_data.entity->client_tag_hash.value().empty());
+ EXPECT_FALSE(response_data.entity.client_tag_hash.value().empty());
}
class GetLocalChangesRequestTest : public testing::Test {
@@ -1818,11 +1818,11 @@
// Test its basic features and the value of encryption_key_name.
ASSERT_TRUE(processor()->HasUpdateResponse(kHash1));
const UpdateResponseData& update = processor()->GetUpdateResponse(kHash1);
- EXPECT_FALSE(update.entity->specifics.password().has_encrypted());
- EXPECT_FALSE(update.entity->specifics.has_encrypted());
+ EXPECT_FALSE(update.entity.specifics.password().has_encrypted());
+ EXPECT_FALSE(update.entity.specifics.has_encrypted());
ASSERT_TRUE(
- update.entity->specifics.password().has_client_only_encrypted_data());
- EXPECT_EQ(kPassword, update.entity->specifics.password()
+ update.entity.specifics.password().has_client_only_encrypted_data());
+ EXPECT_EQ(kPassword, update.entity.specifics.password()
.client_only_encrypted_data()
.password_value());
}
@@ -1895,11 +1895,11 @@
ASSERT_TRUE(processor()->HasUpdateResponse(kHash1));
const UpdateResponseData& update = processor()->GetUpdateResponse(kHash1);
// Password should now be decrypted and sent to the processor.
- EXPECT_TRUE(update.entity->specifics.has_password());
- EXPECT_FALSE(update.entity->specifics.password().has_encrypted());
+ EXPECT_TRUE(update.entity.specifics.has_password());
+ EXPECT_FALSE(update.entity.specifics.password().has_encrypted());
ASSERT_TRUE(
- update.entity->specifics.password().has_client_only_encrypted_data());
- EXPECT_EQ(kPassword, update.entity->specifics.password()
+ update.entity.specifics.password().has_client_only_encrypted_data());
+ EXPECT_EQ(kPassword, update.entity.specifics.password()
.client_only_encrypted_data()
.password_value());
}
@@ -1985,12 +1985,12 @@
EXPECT_EQ(kGuid1, processor()
->GetNthUpdateResponse(1)
.at(0)
- ->entity->originator_client_item_id);
+ ->entity.originator_client_item_id);
EXPECT_EQ(kGuid1, processor()
->GetNthUpdateResponse(1)
.at(0)
- ->entity->specifics.bookmark()
+ ->entity.specifics.bookmark()
.guid());
}
@@ -2034,12 +2034,12 @@
EXPECT_EQ(kInvalidOCII, processor()
->GetNthUpdateResponse(1)
.at(0)
- ->entity->originator_client_item_id);
+ ->entity.originator_client_item_id);
EXPECT_EQ("", processor()
->GetNthUpdateResponse(1)
.at(0)
- ->entity->specifics.bookmark()
+ ->entity.specifics.bookmark()
.guid());
}
@@ -2075,12 +2075,12 @@
EXPECT_EQ(kGuid1, processor()
->GetNthUpdateResponse(0)
.at(0)
- ->entity->originator_client_item_id);
+ ->entity.originator_client_item_id);
EXPECT_EQ(kGuid1, processor()
->GetNthUpdateResponse(0)
.at(0)
- ->entity->specifics.bookmark()
+ ->entity.specifics.bookmark()
.guid());
}
@@ -2117,12 +2117,12 @@
EXPECT_EQ(kInvalidOCII, processor()
->GetNthUpdateResponse(0)
.at(0)
- ->entity->originator_client_item_id);
+ ->entity.originator_client_item_id);
EXPECT_TRUE(processor()
->GetNthUpdateResponse(0)
.at(0)
- ->entity->specifics.bookmark()
+ ->entity.specifics.bookmark()
.guid()
.empty());
}
diff --git a/components/sync/engine_impl/uss_migrator_unittest.cc b/components/sync/engine_impl/uss_migrator_unittest.cc
index 70d0561..ce9a443 100644
--- a/components/sync/engine_impl/uss_migrator_unittest.cc
+++ b/components/sync/engine_impl/uss_migrator_unittest.cc
@@ -135,7 +135,7 @@
const UpdateResponseData* update =
std::move(processor()->GetNthUpdateResponse(0).at(0));
ASSERT_TRUE(update);
- const EntityData& entity = *update->entity;
+ const EntityData& entity = update->entity;
EXPECT_FALSE(entity.id.empty());
EXPECT_EQ(GenerateTagHash(kTag1), entity.client_tag_hash);
@@ -167,11 +167,11 @@
std::vector<const UpdateResponseData*> updates =
processor()->GetNthUpdateResponse(0);
ASSERT_TRUE(updates.at(0));
- EXPECT_EQ(kTag1, updates.at(0)->entity->specifics.preference().name());
+ EXPECT_EQ(kTag1, updates.at(0)->entity.specifics.preference().name());
ASSERT_TRUE(updates.at(1));
- EXPECT_EQ(kTag2, updates.at(1)->entity->specifics.preference().name());
+ EXPECT_EQ(kTag2, updates.at(1)->entity.specifics.preference().name());
ASSERT_TRUE(updates.at(2));
- EXPECT_EQ(kTag3, updates.at(2)->entity->specifics.preference().name());
+ EXPECT_EQ(kTag3, updates.at(2)->entity.specifics.preference().name());
const sync_pb::ModelTypeState& state = processor()->GetNthUpdateState(0);
EXPECT_EQ(kToken1, state.progress_marker().token());
@@ -201,11 +201,11 @@
std::vector<const UpdateResponseData*> updates =
processor()->GetNthUpdateResponse(0);
ASSERT_TRUE(updates.at(0));
- EXPECT_EQ(kTag1, updates.at(0)->entity->specifics.preference().name());
+ EXPECT_EQ(kTag1, updates.at(0)->entity.specifics.preference().name());
ASSERT_TRUE(updates.at(1));
- EXPECT_EQ(kTag2, updates.at(1)->entity->specifics.preference().name());
+ EXPECT_EQ(kTag2, updates.at(1)->entity.specifics.preference().name());
ASSERT_TRUE(updates.at(2));
- EXPECT_EQ(kTag3, updates.at(2)->entity->specifics.preference().name());
+ EXPECT_EQ(kTag3, updates.at(2)->entity.specifics.preference().name());
const sync_pb::ModelTypeState& state = processor()->GetNthUpdateState(0);
EXPECT_EQ(kToken1, state.progress_marker().token());
diff --git a/components/sync/model/entity_change.cc b/components/sync/model/entity_change.cc
index b7726d3..95f26381 100644
--- a/components/sync/model/entity_change.cc
+++ b/components/sync/model/entity_change.cc
@@ -13,7 +13,7 @@
// static
std::unique_ptr<EntityChange> EntityChange::CreateAdd(
const std::string& storage_key,
- std::unique_ptr<EntityData> data) {
+ EntityData data) {
return base::WrapUnique(
new EntityChange(storage_key, ACTION_ADD, std::move(data)));
}
@@ -21,7 +21,7 @@
// static
std::unique_ptr<EntityChange> EntityChange::CreateUpdate(
const std::string& storage_key,
- std::unique_ptr<EntityData> data) {
+ EntityData data) {
return base::WrapUnique(
new EntityChange(storage_key, ACTION_UPDATE, std::move(data)));
}
@@ -30,12 +30,12 @@
std::unique_ptr<EntityChange> EntityChange::CreateDelete(
const std::string& storage_key) {
return base::WrapUnique(
- new EntityChange(storage_key, ACTION_DELETE, nullptr));
+ new EntityChange(storage_key, ACTION_DELETE, EntityData()));
}
EntityChange::EntityChange(const std::string& storage_key,
ChangeType type,
- std::unique_ptr<EntityData> data)
+ EntityData data)
: storage_key_(storage_key), type_(type), data_(std::move(data)) {}
EntityChange::~EntityChange() {}
diff --git a/components/sync/model/entity_change.h b/components/sync/model/entity_change.h
index 01ec2893..be421fd 100644
--- a/components/sync/model/entity_change.h
+++ b/components/sync/model/entity_change.h
@@ -18,12 +18,11 @@
public:
enum ChangeType { ACTION_ADD, ACTION_UPDATE, ACTION_DELETE };
- static std::unique_ptr<EntityChange> CreateAdd(
- const std::string& storage_key,
- std::unique_ptr<EntityData> data);
+ static std::unique_ptr<EntityChange> CreateAdd(const std::string& storage_key,
+ EntityData data);
static std::unique_ptr<EntityChange> CreateUpdate(
const std::string& storage_key,
- std::unique_ptr<EntityData> data);
+ EntityData data);
static std::unique_ptr<EntityChange> CreateDelete(
const std::string& storage_key);
@@ -31,16 +30,16 @@
std::string storage_key() const { return storage_key_; }
ChangeType type() const { return type_; }
- const EntityData& data() const { return *data_; }
+ const EntityData& data() const { return data_; }
private:
EntityChange(const std::string& storage_key,
ChangeType type,
- std::unique_ptr<EntityData> data);
+ EntityData data);
std::string storage_key_;
ChangeType type_;
- std::unique_ptr<EntityData> data_;
+ EntityData data_;
DISALLOW_COPY_AND_ASSIGN(EntityChange);
};
diff --git a/components/sync/model_impl/client_tag_based_model_type_processor.cc b/components/sync/model_impl/client_tag_based_model_type_processor.cc
index 49f8284c..ad89860 100644
--- a/components/sync/model_impl/client_tag_based_model_type_processor.cc
+++ b/components/sync/model_impl/client_tag_based_model_type_processor.cc
@@ -765,14 +765,13 @@
model_type_state_ = model_type_state;
metadata_changes->UpdateModelTypeState(model_type_state_);
- for (const std::unique_ptr<syncer::UpdateResponseData>& update : updates) {
- DCHECK(update);
- const ClientTagHash& client_tag_hash = update->entity->client_tag_hash;
+ for (syncer::UpdateResponseData& update : updates) {
+ const ClientTagHash& client_tag_hash = update.entity.client_tag_hash;
if (client_tag_hash.value().empty()) {
// Ignore updates missing a client tag hash (e.g. permanent nodes).
continue;
}
- if (update->entity->is_deleted()) {
+ if (update.entity.is_deleted()) {
DLOG(WARNING) << "Ignoring tombstone found during initial update: "
<< "client_tag_hash = " << client_tag_hash << " for "
<< ModelTypeToString(type_);
@@ -780,7 +779,7 @@
}
if (bridge_->SupportsGetClientTag() &&
client_tag_hash != ClientTagHash::FromUnhashed(
- type_, bridge_->GetClientTag(*update->entity))) {
+ type_, bridge_->GetClientTag(update.entity))) {
DLOG(WARNING) << "Received unexpected client tag hash: "
<< client_tag_hash << " for " << ModelTypeToString(type_);
continue;
@@ -795,11 +794,11 @@
<< " for " << ModelTypeToString(type_);
}
#endif // DCHECK_IS_ON()
- ProcessorEntity* entity = CreateEntity(*update->entity);
- entity->RecordAcceptedUpdate(*update);
+ ProcessorEntity* entity = CreateEntity(update.entity);
+ entity->RecordAcceptedUpdate(update);
const std::string& storage_key = entity->storage_key();
entity_data.push_back(
- EntityChange::CreateAdd(storage_key, std::move(update->entity)));
+ EntityChange::CreateAdd(storage_key, std::move(update.entity)));
if (!storage_key.empty())
metadata_changes->UpdateMetadata(storage_key, entity->metadata());
}
diff --git a/components/sync/model_impl/client_tag_based_remote_update_handler.cc b/components/sync/model_impl/client_tag_based_remote_update_handler.cc
index 19c9830..ef4338d 100644
--- a/components/sync/model_impl/client_tag_based_remote_update_handler.cc
+++ b/components/sync/model_impl/client_tag_based_remote_update_handler.cc
@@ -74,8 +74,7 @@
// re-encryption phase at the end.
std::unordered_set<std::string> already_updated;
- for (std::unique_ptr<syncer::UpdateResponseData>& update : updates) {
- DCHECK(update);
+ for (syncer::UpdateResponseData& update : updates) {
std::string storage_key_to_clear;
ProcessorEntity* entity = ProcessUpdate(std::move(update), &entity_changes,
&storage_key_to_clear);
@@ -138,10 +137,10 @@
}
ProcessorEntity* ClientTagBasedRemoteUpdateHandler::ProcessUpdate(
- std::unique_ptr<UpdateResponseData> update,
+ UpdateResponseData update,
EntityChangeList* entity_changes,
std::string* storage_key_to_clear) {
- const EntityData& data = *update->entity;
+ const EntityData& data = update.entity;
const ClientTagHash& client_tag_hash = data.client_tag_hash;
// Filter out updates without a client tag hash (including permanent nodes,
@@ -171,17 +170,17 @@
}
if (entity) {
- entity->RecordEntityUpdateLatency(update->response_version, type_);
+ entity->RecordEntityUpdateLatency(update.response_version, type_);
}
- if (entity && entity->UpdateIsReflection(update->response_version)) {
+ if (entity && entity->UpdateIsReflection(update.response_version)) {
// Seen this update before; just ignore it.
return nullptr;
}
// Cache update encryption key name in case |update| will be moved away into
// ResolveConflict().
- const std::string update_encryption_key_name = update->encryption_key_name;
+ const std::string update_encryption_key_name = update.encryption_key_name;
ConflictResolution resolution_type = ConflictResolution::kTypeSize;
if (entity && entity->IsUnsynced()) {
// Handle conflict resolution.
@@ -202,13 +201,13 @@
} else if (!entity->MatchesData(data)) {
change_type = EntityChange::ACTION_UPDATE;
}
- entity->RecordAcceptedUpdate(*update);
+ entity->RecordAcceptedUpdate(update);
// Inform the bridge about the changes if needed.
if (change_type) {
switch (change_type.value()) {
case EntityChange::ACTION_ADD:
entity_changes->push_back(EntityChange::CreateAdd(
- entity->storage_key(), std::move(update->entity)));
+ entity->storage_key(), std::move(update.entity)));
break;
case EntityChange::ACTION_DELETE:
// The entity was deleted; inform the bridge. Note that the local data
@@ -220,7 +219,7 @@
case EntityChange::ACTION_UPDATE:
// Specifics have changed, so update the bridge.
entity_changes->push_back(EntityChange::CreateUpdate(
- entity->storage_key(), std::move(update->entity)));
+ entity->storage_key(), std::move(update.entity)));
break;
}
}
@@ -262,11 +261,11 @@
}
ConflictResolution ClientTagBasedRemoteUpdateHandler::ResolveConflict(
- std::unique_ptr<UpdateResponseData> update,
+ UpdateResponseData update,
ProcessorEntity* entity,
EntityChangeList* changes,
std::string* storage_key_to_clear) {
- const EntityData& remote_data = *update->entity;
+ const EntityData& remote_data = update.entity;
ConflictResolution resolution_type = ConflictResolution::kTypeSize;
@@ -296,27 +295,27 @@
switch (resolution_type) {
case ConflictResolution::kChangesMatch:
// Record the update and squash the pending commit.
- entity->RecordForcedUpdate(*update);
+ entity->RecordForcedUpdate(update);
break;
case ConflictResolution::kUseLocal:
case ConflictResolution::kIgnoreRemoteEncryption:
// Record that we received the update from the server but leave the
// pending commit intact.
- entity->RecordIgnoredUpdate(*update);
+ entity->RecordIgnoredUpdate(update);
break;
case ConflictResolution::kUseRemote:
case ConflictResolution::kIgnoreLocalEncryption:
// Update client data to match server.
- if (update->entity->is_deleted()) {
+ if (update.entity.is_deleted()) {
DCHECK(!entity->metadata().is_deleted());
// Squash the pending commit.
- entity->RecordForcedUpdate(*update);
+ entity->RecordForcedUpdate(update);
changes->push_back(EntityChange::CreateDelete(entity->storage_key()));
} else if (!entity->metadata().is_deleted()) {
// Squash the pending commit.
- entity->RecordForcedUpdate(*update);
+ entity->RecordForcedUpdate(update);
changes->push_back(EntityChange::CreateUpdate(
- entity->storage_key(), std::move(update->entity)));
+ entity->storage_key(), std::move(update.entity)));
} else {
// Remote undeletion. This could imply a new storage key for some
// bridges, so we may need to wait until UpdateStorageKey() is called.
@@ -325,9 +324,9 @@
entity->ClearStorageKey();
}
// Squash the pending commit.
- entity->RecordForcedUpdate(*update);
+ entity->RecordForcedUpdate(update);
changes->push_back(EntityChange::CreateAdd(entity->storage_key(),
- std::move(update->entity)));
+ std::move(update.entity)));
}
break;
case ConflictResolution::kUseNewDEPRECATED:
diff --git a/components/sync/model_impl/client_tag_based_remote_update_handler.h b/components/sync/model_impl/client_tag_based_remote_update_handler.h
index 58bcf8d..86f2e97 100644
--- a/components/sync/model_impl/client_tag_based_remote_update_handler.h
+++ b/components/sync/model_impl/client_tag_based_remote_update_handler.h
@@ -59,7 +59,7 @@
// |storage_key_to_clear| must not be null and allows the implementation to
// indicate that a certain storage key is now obsolete and should be cleared,
// which is leveraged in certain conflict resolution scenarios.
- ProcessorEntity* ProcessUpdate(std::unique_ptr<UpdateResponseData> update,
+ ProcessorEntity* ProcessUpdate(UpdateResponseData update,
EntityChangeList* entity_changes,
std::string* storage_key_to_clear);
@@ -69,7 +69,7 @@
MetadataChangeList* metadata_changes);
// Resolve a conflict between |update| and the pending commit in |entity|.
- ConflictResolution ResolveConflict(std::unique_ptr<UpdateResponseData> update,
+ ConflictResolution ResolveConflict(UpdateResponseData update,
ProcessorEntity* entity,
EntityChangeList* changes,
std::string* storage_key_to_clear);
diff --git a/components/sync/model_impl/processor_entity.cc b/components/sync/model_impl/processor_entity.cc
index dd36b8e..2cefabd 100644
--- a/components/sync/model_impl/processor_entity.cc
+++ b/components/sync/model_impl/processor_entity.cc
@@ -179,8 +179,8 @@
void ProcessorEntity::RecordIgnoredUpdate(const UpdateResponseData& update) {
DCHECK(metadata_.server_id().empty() ||
- metadata_.server_id() == update.entity->id);
- metadata_.set_server_id(update.entity->id);
+ metadata_.server_id() == update.entity.id);
+ metadata_.set_server_id(update.entity.id);
metadata_.set_server_version(update.response_version);
// Either these already matched, acked was just bumped to squash a pending
// commit and this should follow, or the pending commit needs to be requeued.
@@ -196,10 +196,10 @@
void ProcessorEntity::RecordAcceptedUpdate(const UpdateResponseData& update) {
DCHECK(!IsUnsynced());
RecordIgnoredUpdate(update);
- metadata_.set_is_deleted(update.entity->is_deleted());
+ metadata_.set_is_deleted(update.entity.is_deleted());
metadata_.set_modification_time(
- TimeToProtoTime(update.entity->modification_time));
- UpdateSpecificsHash(update.entity->specifics);
+ TimeToProtoTime(update.entity.modification_time));
+ UpdateSpecificsHash(update.entity.specifics);
}
void ProcessorEntity::RecordForcedUpdate(const UpdateResponseData& update) {
diff --git a/components/sync/model_impl/processor_entity_unittest.cc b/components/sync/model_impl/processor_entity_unittest.cc
index 810dae10..e5f6d40 100644
--- a/components/sync/model_impl/processor_entity_unittest.cc
+++ b/components/sync/model_impl/processor_entity_unittest.cc
@@ -47,38 +47,36 @@
return entity_data;
}
-std::unique_ptr<UpdateResponseData> GenerateUpdate(
- const ProcessorEntity& entity,
- const ClientTagHash& hash,
- const std::string& id,
- const std::string& name,
- const std::string& value,
- const base::Time& mtime,
- int64_t version) {
+UpdateResponseData GenerateUpdate(const ProcessorEntity& entity,
+ const ClientTagHash& hash,
+ const std::string& id,
+ const std::string& name,
+ const std::string& value,
+ const base::Time& mtime,
+ int64_t version) {
std::unique_ptr<EntityData> data = GenerateEntityData(hash, name, value);
data->id = id;
data->modification_time = mtime;
- auto update = std::make_unique<UpdateResponseData>();
- update->entity = std::move(data);
- update->response_version = version;
+ UpdateResponseData update;
+ update.entity = std::move(*data);
+ update.response_version = version;
return update;
}
-std::unique_ptr<UpdateResponseData> GenerateTombstone(
- const ProcessorEntity& entity,
- const ClientTagHash& hash,
- const std::string& id,
- const std::string& name,
- const base::Time& mtime,
- int64_t version) {
+UpdateResponseData GenerateTombstone(const ProcessorEntity& entity,
+ const ClientTagHash& hash,
+ const std::string& id,
+ const std::string& name,
+ const base::Time& mtime,
+ int64_t version) {
std::unique_ptr<EntityData> data = std::make_unique<EntityData>();
data->client_tag_hash = hash;
data->name = name;
data->id = id;
data->modification_time = mtime;
- auto update = std::make_unique<UpdateResponseData>();
- update->entity = std::move(data);
- update->response_version = version;
+ UpdateResponseData update;
+ update.entity = std::move(*data);
+ update.response_version = version;
return update;
}
@@ -121,9 +119,9 @@
std::unique_ptr<ProcessorEntity> CreateSynced() {
std::unique_ptr<ProcessorEntity> entity = CreateNew();
- std::unique_ptr<UpdateResponseData> update =
+ UpdateResponseData update =
GenerateUpdate(*entity, kHash, kId, kName, kValue1, ctime_, 1);
- entity->RecordAcceptedUpdate(*update);
+ entity->RecordAcceptedUpdate(update);
DCHECK(!entity->IsUnsynced());
return entity;
}
@@ -238,9 +236,9 @@
std::unique_ptr<ProcessorEntity> entity = CreateNew();
const base::Time mtime = base::Time::Now();
- std::unique_ptr<UpdateResponseData> update =
+ UpdateResponseData update =
GenerateUpdate(*entity, kHash, kId, kName, kValue1, mtime, 10);
- entity->RecordAcceptedUpdate(*update);
+ entity->RecordAcceptedUpdate(update);
EXPECT_EQ(kId, entity->metadata().server_id());
EXPECT_FALSE(entity->metadata().is_deleted());
@@ -269,9 +267,9 @@
EXPECT_EQ("", entity->storage_key());
const base::Time mtime = base::Time::Now();
- std::unique_ptr<UpdateResponseData> update =
+ UpdateResponseData update =
GenerateUpdate(*entity, kHash, kId, kName, kValue1, mtime, 10);
- entity->RecordAcceptedUpdate(*update);
+ entity->RecordAcceptedUpdate(update);
entity->SetStorageKey(kKey);
EXPECT_EQ(kKey, entity->storage_key());
}
@@ -281,9 +279,9 @@
std::unique_ptr<ProcessorEntity> entity = CreateNew();
const base::Time mtime = base::Time::Now();
- std::unique_ptr<UpdateResponseData> tombstone =
+ UpdateResponseData tombstone =
GenerateTombstone(*entity, kHash, kId, kName, mtime, 1);
- entity->RecordAcceptedUpdate(*tombstone);
+ entity->RecordAcceptedUpdate(tombstone);
EXPECT_EQ(kId, entity->metadata().server_id());
EXPECT_TRUE(entity->metadata().is_deleted());
@@ -309,9 +307,9 @@
std::unique_ptr<ProcessorEntity> entity = CreateSynced();
// A deletion update one version later.
const base::Time mtime = base::Time::Now();
- std::unique_ptr<UpdateResponseData> tombstone =
+ UpdateResponseData tombstone =
GenerateTombstone(*entity, kHash, kId, kName, mtime, 2);
- entity->RecordAcceptedUpdate(*tombstone);
+ entity->RecordAcceptedUpdate(tombstone);
EXPECT_TRUE(entity->metadata().is_deleted());
EXPECT_EQ(0, entity->metadata().sequence_number());
@@ -577,9 +575,9 @@
// Before anything gets committed, we receive a remote tombstone, but local
// would usually win so the remote update is ignored.
- std::unique_ptr<UpdateResponseData> tombstone =
+ UpdateResponseData tombstone =
GenerateTombstone(*entity, kHash, kId, kName, base::Time::Now(), 2);
- entity->RecordIgnoredUpdate(*tombstone);
+ entity->RecordIgnoredUpdate(tombstone);
EXPECT_EQ(kId, entity->metadata().server_id());
EXPECT_TRUE(entity->IsUnsynced());
diff --git a/components/sync/nigori/nigori_model_type_processor.cc b/components/sync/nigori/nigori_model_type_processor.cc
index 0633602..982eba90 100644
--- a/components/sync/nigori/nigori_model_type_processor.cc
+++ b/components/sync/nigori/nigori_model_type_processor.cc
@@ -132,12 +132,12 @@
if (updates.empty()) {
error = bridge_->MergeSyncData(base::nullopt);
} else {
- DCHECK(!updates[0]->entity->is_deleted());
+ DCHECK(!updates[0].entity.is_deleted());
entity_ = ProcessorEntity::CreateNew(
kNigoriStorageKey, ClientTagHash::FromHashed(kRawNigoriClientTagHash),
- updates[0]->entity->id, updates[0]->entity->creation_time);
- entity_->RecordAcceptedUpdate(*updates[0]);
- error = bridge_->MergeSyncData(std::move(*updates[0]->entity));
+ updates[0].entity.id, updates[0].entity.creation_time);
+ entity_->RecordAcceptedUpdate(updates[0]);
+ error = bridge_->MergeSyncData(std::move(updates[0].entity));
}
if (error) {
ReportError(*error);
@@ -153,9 +153,9 @@
DCHECK(entity_);
// We assume the bridge will issue errors in case of deletions. Therefore, we
// are adding the following DCHECK to simplify the code.
- DCHECK(!updates[0]->entity->is_deleted());
+ DCHECK(!updates[0].entity.is_deleted());
- if (entity_->UpdateIsReflection(updates[0]->response_version)) {
+ if (entity_->UpdateIsReflection(updates[0].response_version)) {
// Seen this update before; just ignore it.
bridge_->ApplySyncChanges(/*data=*/base::nullopt);
return;
@@ -164,18 +164,18 @@
if (entity_->IsUnsynced()) {
// Remote update always win in case of conflict, because bridge takes care
// of reapplying pending local changes after processing the remote update.
- entity_->RecordForcedUpdate(*updates[0]);
- error = bridge_->ApplySyncChanges(std::move(*updates[0]->entity));
+ entity_->RecordForcedUpdate(updates[0]);
+ error = bridge_->ApplySyncChanges(std::move(updates[0].entity));
UMA_HISTOGRAM_ENUMERATION("Sync.ResolveConflict",
ConflictResolution::kUseRemote,
ConflictResolution::kTypeSize);
UMA_HISTOGRAM_ENUMERATION("Sync.ResolveSimpleConflict",
ConflictResolver::NIGORI_MERGE,
ConflictResolver::CONFLICT_RESOLUTION_SIZE);
- } else if (!entity_->MatchesData(*updates[0]->entity)) {
+ } else if (!entity_->MatchesData(updates[0].entity)) {
// Inform the bridge of the new or updated data.
- entity_->RecordAcceptedUpdate(*updates[0]);
- error = bridge_->ApplySyncChanges(std::move(*updates[0]->entity));
+ entity_->RecordAcceptedUpdate(updates[0]);
+ error = bridge_->ApplySyncChanges(std::move(updates[0].entity));
}
if (error) {
diff --git a/components/sync/nigori/nigori_model_type_processor_unittest.cc b/components/sync/nigori/nigori_model_type_processor_unittest.cc
index 46a0995..8bd7033 100644
--- a/components/sync/nigori/nigori_model_type_processor_unittest.cc
+++ b/components/sync/nigori/nigori_model_type_processor_unittest.cc
@@ -53,21 +53,21 @@
// Creates a dummy Nigori UpdateResponseData that has the keystore decryptor
// token key name set.
-std::unique_ptr<syncer::UpdateResponseData> CreateDummyNigoriUpdateResponseData(
+syncer::UpdateResponseData CreateDummyNigoriUpdateResponseData(
const std::string keystore_decryptor_token_key_name,
int response_version) {
- auto entity_data = std::make_unique<syncer::EntityData>();
- entity_data->is_folder = true;
- entity_data->id = kNigoriServerId;
+ syncer::EntityData entity_data;
+ entity_data.is_folder = true;
+ entity_data.id = kNigoriServerId;
sync_pb::NigoriSpecifics* nigori_specifics =
- entity_data->specifics.mutable_nigori();
+ entity_data.specifics.mutable_nigori();
nigori_specifics->mutable_keystore_decryptor_token()->set_key_name(
keystore_decryptor_token_key_name);
- entity_data->name = kNigoriNonUniqueName;
+ entity_data.name = kNigoriNonUniqueName;
- auto response_data = std::make_unique<syncer::UpdateResponseData>();
- response_data->entity = std::move(entity_data);
- response_data->response_version = response_version;
+ syncer::UpdateResponseData response_data;
+ response_data.entity = std::move(entity_data);
+ response_data.response_version = response_version;
return response_data;
}
diff --git a/components/sync/test/engine/mock_model_type_processor.cc b/components/sync/test/engine/mock_model_type_processor.cc
index b8e133b..03e5606 100644
--- a/components/sync/test/engine/mock_model_type_processor.cc
+++ b/components/sync/test/engine/mock_model_type_processor.cc
@@ -137,9 +137,8 @@
MockModelTypeProcessor::GetNthUpdateResponse(size_t n) const {
DCHECK_LT(n, GetNumUpdateResponses());
std::vector<const UpdateResponseData*> nth_update_responses;
- for (const std::unique_ptr<UpdateResponseData>& response :
- received_update_responses_[n]) {
- nth_update_responses.push_back(response.get());
+ for (const UpdateResponseData& response : received_update_responses_[n]) {
+ nth_update_responses.push_back(&response);
}
return nth_update_responses;
}
@@ -236,12 +235,12 @@
UpdateResponseDataList response_list) {
type_states_received_on_update_.push_back(type_state);
for (auto it = response_list.begin(); it != response_list.end(); ++it) {
- const ClientTagHash& client_tag_hash = (*it)->entity->client_tag_hash;
+ const ClientTagHash& client_tag_hash = it->entity.client_tag_hash;
// Server wins. Set the model's base version.
- SetBaseVersion(client_tag_hash, (*it)->response_version);
- SetServerAssignedId(client_tag_hash, (*it)->entity->id);
+ SetBaseVersion(client_tag_hash, it->response_version);
+ SetServerAssignedId(client_tag_hash, it->entity.id);
- update_response_items_.insert(std::make_pair(client_tag_hash, it->get()));
+ update_response_items_.insert(std::make_pair(client_tag_hash, &(*it)));
}
received_update_responses_.push_back(std::move(response_list));
}
diff --git a/components/sync/test/engine/mock_model_type_worker.cc b/components/sync/test/engine/mock_model_type_worker.cc
index a36e332..eed5c2f 100644
--- a/components/sync/test/engine/mock_model_type_worker.cc
+++ b/components/sync/test/engine/mock_model_type_worker.cc
@@ -151,8 +151,7 @@
processor_->OnUpdateReceived(model_type_state_, std::move(updates));
}
-std::unique_ptr<syncer::UpdateResponseData>
-MockModelTypeWorker::GenerateUpdateData(
+syncer::UpdateResponseData MockModelTypeWorker::GenerateUpdateData(
const ClientTagHash& tag_hash,
const sync_pb::EntitySpecifics& specifics,
int64_t version_offset,
@@ -164,51 +163,50 @@
SetServerVersion(tag_hash, version);
}
- auto data = std::make_unique<syncer::EntityData>();
- data->id = GenerateId(tag_hash);
- data->client_tag_hash = tag_hash;
- data->specifics = specifics;
+ syncer::EntityData data;
+ data.id = GenerateId(tag_hash);
+ data.client_tag_hash = tag_hash;
+ data.specifics = specifics;
// These elements should have no effect on behavior, but we set them anyway
// so we can test they are properly copied around the system if we want to.
- data->creation_time = base::Time::UnixEpoch() + base::TimeDelta::FromDays(1);
- data->modification_time =
- data->creation_time + base::TimeDelta::FromSeconds(version);
- data->name = data->specifics.has_encrypted()
- ? "encrypted"
- : data->specifics.preference().name();
+ data.creation_time = base::Time::UnixEpoch() + base::TimeDelta::FromDays(1);
+ data.modification_time =
+ data.creation_time + base::TimeDelta::FromSeconds(version);
+ data.name = data.specifics.has_encrypted()
+ ? "encrypted"
+ : data.specifics.preference().name();
- auto response_data = std::make_unique<syncer::UpdateResponseData>();
- response_data->entity = std::move(data);
- response_data->response_version = version;
- response_data->encryption_key_name = ekn;
+ syncer::UpdateResponseData response_data;
+ response_data.entity = std::move(data);
+ response_data.response_version = version;
+ response_data.encryption_key_name = ekn;
return response_data;
}
-std::unique_ptr<syncer::UpdateResponseData>
-MockModelTypeWorker::GenerateUpdateData(
+syncer::UpdateResponseData MockModelTypeWorker::GenerateUpdateData(
const ClientTagHash& tag_hash,
const sync_pb::EntitySpecifics& specifics) {
return GenerateUpdateData(tag_hash, specifics, 1,
model_type_state_.encryption_key_name());
}
-std::unique_ptr<syncer::UpdateResponseData>
-MockModelTypeWorker::GenerateTypeRootUpdateData(const ModelType& model_type) {
- auto data = std::make_unique<syncer::EntityData>();
- data->id = syncer::ModelTypeToRootTag(model_type);
- data->parent_id = "r";
- data->server_defined_unique_tag = syncer::ModelTypeToRootTag(model_type);
- syncer::AddDefaultFieldValue(model_type, &data->specifics);
+syncer::UpdateResponseData MockModelTypeWorker::GenerateTypeRootUpdateData(
+ const ModelType& model_type) {
+ syncer::EntityData data;
+ data.id = syncer::ModelTypeToRootTag(model_type);
+ data.parent_id = "r";
+ data.server_defined_unique_tag = syncer::ModelTypeToRootTag(model_type);
+ syncer::AddDefaultFieldValue(model_type, &data.specifics);
// These elements should have no effect on behavior, but we set them anyway
// so we can test they are properly copied around the system if we want to.
- data->creation_time = base::Time::UnixEpoch();
- data->modification_time = base::Time::UnixEpoch();
+ data.creation_time = base::Time::UnixEpoch();
+ data.modification_time = base::Time::UnixEpoch();
- auto response_data = std::make_unique<syncer::UpdateResponseData>();
- response_data->entity = std::move(data);
+ syncer::UpdateResponseData response_data;
+ response_data.entity = std::move(data);
// Similar to what's done in the loopback_server.
- response_data->response_version = 0;
+ response_data.response_version = 0;
return response_data;
}
@@ -217,20 +215,20 @@
int64_t version = old_version + 1;
SetServerVersion(tag_hash, version);
- auto data = std::make_unique<syncer::EntityData>();
- data->id = GenerateId(tag_hash);
- data->client_tag_hash = tag_hash;
+ syncer::EntityData data;
+ data.id = GenerateId(tag_hash);
+ data.client_tag_hash = tag_hash;
// These elements should have no effect on behavior, but we set them anyway
// so we can test they are properly copied around the system if we want to.
- data->creation_time = base::Time::UnixEpoch() + base::TimeDelta::FromDays(1);
- data->modification_time =
- data->creation_time + base::TimeDelta::FromSeconds(version);
- data->name = "Name Non Unique";
+ data.creation_time = base::Time::UnixEpoch() + base::TimeDelta::FromDays(1);
+ data.modification_time =
+ data.creation_time + base::TimeDelta::FromSeconds(version);
+ data.name = "Name Non Unique";
- auto response_data = std::make_unique<UpdateResponseData>();
- response_data->entity = std::move(data);
- response_data->response_version = version;
- response_data->encryption_key_name = model_type_state_.encryption_key_name();
+ UpdateResponseData response_data;
+ response_data.entity = std::move(data);
+ response_data.response_version = version;
+ response_data.encryption_key_name = model_type_state_.encryption_key_name();
UpdateResponseDataList list;
list.push_back(std::move(response_data));
diff --git a/components/sync/test/engine/mock_model_type_worker.h b/components/sync/test/engine/mock_model_type_worker.h
index bc3faff..19df06c3 100644
--- a/components/sync/test/engine/mock_model_type_worker.h
+++ b/components/sync/test/engine/mock_model_type_worker.h
@@ -88,7 +88,7 @@
// the same version) or new updates.
//
// |ekn| is the encryption key name this item will fake having.
- std::unique_ptr<syncer::UpdateResponseData> GenerateUpdateData(
+ syncer::UpdateResponseData GenerateUpdateData(
const ClientTagHash& tag_hash,
const sync_pb::EntitySpecifics& specifics,
int64_t version_offset,
@@ -96,13 +96,13 @@
// Mostly same as GenerateUpdateData above, but set 1 as |version_offset|, and
// use model_type_state_.encryption_key_name() as |ekn|.
- std::unique_ptr<syncer::UpdateResponseData> GenerateUpdateData(
+ syncer::UpdateResponseData GenerateUpdateData(
const ClientTagHash& tag_hash,
const sync_pb::EntitySpecifics& specifics);
// Returns an UpdateResponseData representing an update received from
// the server for a type root node.
- std::unique_ptr<syncer::UpdateResponseData> GenerateTypeRootUpdateData(
+ syncer::UpdateResponseData GenerateTypeRootUpdateData(
const ModelType& model_type);
// Triggers a server-side deletion of the entity with |tag_hash|; updates
diff --git a/components/sync_bookmarks/bookmark_model_merger.cc b/components/sync_bookmarks/bookmark_model_merger.cc
index fc0e358..aae3a285 100644
--- a/components/sync_bookmarks/bookmark_model_merger.cc
+++ b/components/sync_bookmarks/bookmark_model_merger.cc
@@ -55,9 +55,8 @@
const char kMobileBookmarksTag[] = "synced_bookmarks";
const char kOtherBookmarksTag[] = "other_bookmarks";
-using UpdatesPerParentId = std::unordered_map<base::StringPiece,
- syncer::UpdateResponseDataList,
- base::StringPieceHash>;
+using UpdatesPerParentId =
+ std::unordered_map<std::string, syncer::UpdateResponseDataList>;
// Gets the bookmark node corresponding to a permanent folder identified by
// |server_defined_unique_tag|. |bookmark_model| must not be null.
@@ -125,31 +124,25 @@
std::set<std::string> known_guids;
// In a first pass we process |originator_client_item_id| which is more
// authoritative and cannot run into duplicates.
- for (const std::unique_ptr<UpdateResponseData>& update : *updates) {
- DCHECK(update);
- DCHECK(update->entity);
-
+ for (const UpdateResponseData& update : *updates) {
// |originator_client_item_id| is empty for permanent nodes.
- if (update->entity->is_deleted() ||
- update->entity->originator_client_item_id.empty()) {
+ if (update.entity.is_deleted() ||
+ update.entity.originator_client_item_id.empty()) {
continue;
}
bool success =
- known_guids.insert(update->entity->originator_client_item_id).second;
+ known_guids.insert(update.entity.originator_client_item_id).second;
DCHECK(success);
}
// In a second pass, detect if GUIDs in specifics conflict with each other or
// with |originator_client_item_id| values processed earlier.
- for (std::unique_ptr<UpdateResponseData>& update : *updates) {
- DCHECK(update);
- DCHECK(update->entity);
-
+ for (UpdateResponseData& update : *updates) {
const std::string& guid_in_specifics =
- update->entity->specifics.bookmark().guid();
+ update.entity.specifics.bookmark().guid();
if (guid_in_specifics.empty() ||
- guid_in_specifics == update->entity->originator_client_item_id) {
+ guid_in_specifics == update.entity.originator_client_item_id) {
continue;
}
@@ -158,7 +151,7 @@
// This GUID conflicts with another one, so let's ignore it for the
// purpose of merging. This mimics the data produced by old clients,
// without the GUID being populated.
- update->entity->specifics.mutable_bookmark()->clear_guid();
+ update.entity.specifics.mutable_bookmark()->clear_guid();
}
}
}
@@ -169,11 +162,8 @@
UpdateResponseDataList* updates) {
UpdatesPerParentId updates_per_parent_id;
- for (std::unique_ptr<UpdateResponseData>& update : *updates) {
- DCHECK(update);
- DCHECK(update->entity);
-
- const EntityData& update_entity = *update->entity;
+ for (UpdateResponseData& update : *updates) {
+ const EntityData& update_entity = update.entity;
if (update_entity.is_deleted()) {
continue;
}
@@ -246,23 +236,19 @@
// static
BookmarkModelMerger::RemoteTreeNode
BookmarkModelMerger::RemoteTreeNode::BuildTree(
- std::unique_ptr<UpdateResponseData> update,
+ UpdateResponseData update,
UpdatesPerParentId* updates_per_parent_id) {
DCHECK(updates_per_parent_id);
- DCHECK(update);
- DCHECK(update->entity);
RemoteTreeNode node;
node.update_ = std::move(update);
// Populate descendants recursively.
- for (std::unique_ptr<UpdateResponseData>& child_update :
+ for (UpdateResponseData& child_update :
(*updates_per_parent_id)[node.entity().id]) {
- DCHECK(child_update);
- DCHECK(child_update->entity);
- DCHECK_EQ(child_update->entity->parent_id, node.entity().id);
- DCHECK(IsValidBookmarkSpecifics(child_update->entity->specifics.bookmark(),
- child_update->entity->is_folder));
+ DCHECK_EQ(child_update.entity.parent_id, node.entity().id);
+ DCHECK(IsValidBookmarkSpecifics(child_update.entity.specifics.bookmark(),
+ child_update.entity.is_folder));
node.children_.push_back(
BuildTree(std::move(child_update), updates_per_parent_id));
@@ -335,14 +321,14 @@
// Construct one tree per permanent entity.
RemoteForest update_forest;
- for (std::unique_ptr<UpdateResponseData>& update : updates) {
- if (!update || update->entity->server_defined_unique_tag.empty()) {
+ for (UpdateResponseData& update : updates) {
+ if (update.entity.server_defined_unique_tag.empty()) {
continue;
}
// Make a copy of the string to avoid relying on argument evaluation order.
const std::string server_defined_unique_tag =
- update->entity->server_defined_unique_tag;
+ update.entity.server_defined_unique_tag;
update_forest.emplace(
server_defined_unique_tag,
diff --git a/components/sync_bookmarks/bookmark_model_merger.h b/components/sync_bookmarks/bookmark_model_merger.h
index bf0783ec..9758ee9 100644
--- a/components/sync_bookmarks/bookmark_model_merger.h
+++ b/components/sync_bookmarks/bookmark_model_merger.h
@@ -54,9 +54,7 @@
class RemoteTreeNode final {
private:
using UpdatesPerParentId =
- std::unordered_map<base::StringPiece,
- syncer::UpdateResponseDataList,
- base::StringPieceHash>;
+ std::unordered_map<std::string, syncer::UpdateResponseDataList>;
public:
// Constructs a tree given |update| as root and recursively all descendants
@@ -65,9 +63,8 @@
// |*updates_per_parent_id| must represent valid updates. Updates
// corresponding from descendant nodes are moved away from
// |*updates_per_parent_id|.
- static RemoteTreeNode BuildTree(
- std::unique_ptr<syncer::UpdateResponseData> update,
- UpdatesPerParentId* updates_per_parent_id);
+ static RemoteTreeNode BuildTree(syncer::UpdateResponseData update,
+ UpdatesPerParentId* updates_per_parent_id);
~RemoteTreeNode();
@@ -75,8 +72,8 @@
RemoteTreeNode(RemoteTreeNode&&);
RemoteTreeNode& operator=(RemoteTreeNode&&);
- const syncer::EntityData& entity() const { return *update_->entity; }
- int64_t response_version() const { return update_->response_version; }
+ const syncer::EntityData& entity() const { return update_.entity; }
+ int64_t response_version() const { return update_.response_version; }
// Direct children nodes, sorted by ascending unique position. These are
// guaranteed to be valid updates (e.g. IsValidBookmarkSpecifics()).
@@ -94,7 +91,7 @@
RemoteTreeNode();
- std::unique_ptr<syncer::UpdateResponseData> update_;
+ syncer::UpdateResponseData update_;
std::vector<RemoteTreeNode> children_;
};
diff --git a/components/sync_bookmarks/bookmark_model_merger_unittest.cc b/components/sync_bookmarks/bookmark_model_merger_unittest.cc
index cba854b..2edf63b 100644
--- a/components/sync_bookmarks/bookmark_model_merger_unittest.cc
+++ b/components/sync_bookmarks/bookmark_model_merger_unittest.cc
@@ -50,7 +50,7 @@
return arg[0].get() == expected_raw_ptr0 && arg[1].get() == expected_raw_ptr1;
}
-std::unique_ptr<syncer::UpdateResponseData> CreateUpdateResponseData(
+syncer::UpdateResponseData CreateUpdateResponseData(
const std::string& server_id,
const std::string& parent_id,
const std::string& title,
@@ -63,39 +63,39 @@
if (!guid)
guid = base::GenerateGUID();
- auto data = std::make_unique<syncer::EntityData>();
- data->id = server_id;
- data->originator_client_item_id = *guid;
- data->parent_id = parent_id;
- data->unique_position = unique_position.ToProto();
+ syncer::EntityData data;
+ data.id = server_id;
+ data.originator_client_item_id = *guid;
+ data.parent_id = parent_id;
+ data.unique_position = unique_position.ToProto();
sync_pb::BookmarkSpecifics* bookmark_specifics =
- data->specifics.mutable_bookmark();
+ data.specifics.mutable_bookmark();
bookmark_specifics->set_guid(*guid);
bookmark_specifics->set_title(title);
bookmark_specifics->set_url(url);
bookmark_specifics->set_icon_url(icon_url);
bookmark_specifics->set_favicon(icon_data);
- data->is_folder = is_folder;
- auto response_data = std::make_unique<syncer::UpdateResponseData>();
- response_data->entity = std::move(data);
+ data.is_folder = is_folder;
+ syncer::UpdateResponseData response_data;
+ response_data.entity = std::move(data);
// Similar to what's done in the loopback_server.
- response_data->response_version = 0;
+ response_data.response_version = 0;
return response_data;
}
-std::unique_ptr<syncer::UpdateResponseData> CreateBookmarkBarNodeUpdateData() {
- auto data = std::make_unique<syncer::EntityData>();
- data->id = kBookmarkBarId;
- data->server_defined_unique_tag = kBookmarkBarTag;
+syncer::UpdateResponseData CreateBookmarkBarNodeUpdateData() {
+ syncer::EntityData data;
+ data.id = kBookmarkBarId;
+ data.server_defined_unique_tag = kBookmarkBarTag;
- data->specifics.mutable_bookmark();
+ data.specifics.mutable_bookmark();
- auto response_data = std::make_unique<syncer::UpdateResponseData>();
- response_data->entity = std::move(data);
+ syncer::UpdateResponseData response_data;
+ response_data.entity = std::move(data);
// Similar to what's done in the loopback_server.
- response_data->response_version = 0;
+ response_data.response_version = 0;
return response_data;
}
@@ -1309,7 +1309,7 @@
// |originator_client_item_id| cannot itself be duplicated because
// ModelTypeWorker guarantees otherwise.
- updates.back()->entity->originator_client_item_id = base::GenerateGUID();
+ updates.back().entity.originator_client_item_id = base::GenerateGUID();
std::unique_ptr<SyncedBookmarkTracker> tracker =
Merge(std::move(updates), bookmark_model.get());
@@ -1380,7 +1380,7 @@
// |originator_client_item_id| cannot itself be duplicated because
// ModelTypeWorker guarantees otherwise.
- updates.back()->entity->originator_client_item_id = base::GenerateGUID();
+ updates.back().entity.originator_client_item_id = base::GenerateGUID();
std::unique_ptr<SyncedBookmarkTracker> tracker =
Merge(std::move(updates), bookmark_model.get());
diff --git a/components/sync_bookmarks/bookmark_model_type_processor_unittest.cc b/components/sync_bookmarks/bookmark_model_type_processor_unittest.cc
index 90940c5..e8aebfc7 100644
--- a/components/sync_bookmarks/bookmark_model_type_processor_unittest.cc
+++ b/components/sync_bookmarks/bookmark_model_type_processor_unittest.cc
@@ -50,34 +50,34 @@
std::string server_tag;
};
-std::unique_ptr<syncer::UpdateResponseData> CreateUpdateResponseData(
+syncer::UpdateResponseData CreateUpdateResponseData(
const BookmarkInfo& bookmark_info,
const syncer::UniquePosition& unique_position,
int response_version,
const std::string& guid) {
- auto data = std::make_unique<syncer::EntityData>();
- data->id = bookmark_info.server_id;
- data->parent_id = bookmark_info.parent_id;
- data->server_defined_unique_tag = bookmark_info.server_tag;
- data->unique_position = unique_position.ToProto();
+ syncer::EntityData data;
+ data.id = bookmark_info.server_id;
+ data.parent_id = bookmark_info.parent_id;
+ data.server_defined_unique_tag = bookmark_info.server_tag;
+ data.unique_position = unique_position.ToProto();
sync_pb::BookmarkSpecifics* bookmark_specifics =
- data->specifics.mutable_bookmark();
+ data.specifics.mutable_bookmark();
bookmark_specifics->set_guid(guid);
bookmark_specifics->set_title(bookmark_info.title);
if (bookmark_info.url.empty()) {
- data->is_folder = true;
+ data.is_folder = true;
} else {
bookmark_specifics->set_url(bookmark_info.url);
}
- auto response_data = std::make_unique<syncer::UpdateResponseData>();
- response_data->entity = std::move(data);
- response_data->response_version = response_version;
+ syncer::UpdateResponseData response_data;
+ response_data.entity = std::move(data);
+ response_data.response_version = response_version;
return response_data;
}
-std::unique_ptr<syncer::UpdateResponseData> CreateUpdateResponseData(
+syncer::UpdateResponseData CreateUpdateResponseData(
const BookmarkInfo& bookmark_info,
const syncer::UniquePosition& unique_position,
int response_version) {
@@ -305,7 +305,7 @@
CreateUpdateResponseData({kNodeId, kTitle, kUrl, kBookmarkBarId,
/*server_tag=*/std::string()},
kRandomPosition, /*response_version=*/1));
- updates[0]->response_version++;
+ updates[0].response_version++;
EXPECT_CALL(*schedule_save_closure(), Run());
processor()->OnUpdateReceived(CreateDummyModelTypeState(),
@@ -499,14 +499,13 @@
// Push an update that is encrypted with the new encryption key.
const std::string kNodeId = "node_id";
- std::unique_ptr<syncer::UpdateResponseData> response_data =
- CreateUpdateResponseData(
- {kNodeId, "title", "http://www.url.com", /*parent_id=*/kBookmarkBarId,
- /*server_tag=*/std::string()},
- syncer::UniquePosition::InitialPosition(
- syncer::UniquePosition::RandomSuffix()),
- /*response_version=*/0);
- response_data->encryption_key_name = kEncryptionKeyName;
+ syncer::UpdateResponseData response_data = CreateUpdateResponseData(
+ {kNodeId, "title", "http://www.url.com", /*parent_id=*/kBookmarkBarId,
+ /*server_tag=*/std::string()},
+ syncer::UniquePosition::InitialPosition(
+ syncer::UniquePosition::RandomSuffix()),
+ /*response_version=*/0);
+ response_data.encryption_key_name = kEncryptionKeyName;
syncer::UpdateResponseDataList updates;
updates.push_back(std::move(response_data));
diff --git a/components/sync_bookmarks/bookmark_remote_updates_handler.cc b/components/sync_bookmarks/bookmark_remote_updates_handler.cc
index c3127571..55fb8b6 100644
--- a/components/sync_bookmarks/bookmark_remote_updates_handler.cc
+++ b/components/sync_bookmarks/bookmark_remote_updates_handler.cc
@@ -108,7 +108,7 @@
bookmarks::BookmarkModel* model,
SyncedBookmarkTracker* tracker,
favicon::FaviconService* favicon_service) {
- const syncer::EntityData& update_entity = *update.entity;
+ const syncer::EntityData& update_entity = update.entity;
DCHECK(!update_entity.is_deleted());
DCHECK(tracked_entity);
DCHECK(new_parent_tracked_entity);
@@ -184,7 +184,7 @@
std::unordered_set<std::string> entities_with_up_to_date_encryption;
for (const syncer::UpdateResponseData* update : ReorderUpdates(&updates)) {
- const syncer::EntityData& update_entity = *update->entity;
+ const syncer::EntityData& update_entity = update->entity;
// Only non deletions and non premanent node should have valid specifics and
// unique positions.
if (!update_entity.is_deleted() &&
@@ -368,9 +368,8 @@
parent_to_children;
// Add only non-deletions to |id_to_updates|.
- for (const std::unique_ptr<syncer::UpdateResponseData>& update : *updates) {
- DCHECK(update);
- const syncer::EntityData& update_entity = *update->entity;
+ for (const syncer::UpdateResponseData& update : *updates) {
+ const syncer::EntityData& update_entity = update.entity;
// Ignore updates to root nodes.
if (update_entity.parent_id == "0") {
continue;
@@ -378,13 +377,13 @@
if (update_entity.is_deleted()) {
continue;
}
- id_to_updates[update_entity.id] = update.get();
+ id_to_updates[update_entity.id] = &update;
}
// Iterate over |id_to_updates| and construct |roots| and
// |parent_to_children|.
for (const std::pair<base::StringPiece, const syncer::UpdateResponseData*>&
pair : id_to_updates) {
- const syncer::EntityData& update_entity = *pair.second->entity;
+ const syncer::EntityData& update_entity = pair.second->entity;
parent_to_children[update_entity.parent_id].push_back(update_entity.id);
// If this entity's parent has no pending update, add it to |roots|.
if (id_to_updates.count(update_entity.parent_id) == 0) {
@@ -401,16 +400,15 @@
int root_node_updates_count = 0;
// Add deletions.
- for (const std::unique_ptr<syncer::UpdateResponseData>& update : *updates) {
- DCHECK(update);
- const syncer::EntityData& update_entity = *update->entity;
+ for (const syncer::UpdateResponseData& update : *updates) {
+ const syncer::EntityData& update_entity = update.entity;
// Ignore updates to root nodes.
if (update_entity.parent_id == "0") {
root_node_updates_count++;
continue;
}
if (update_entity.is_deleted()) {
- ordered_updates.push_back(update.get());
+ ordered_updates.push_back(&update);
}
}
// All non root updates should have been included in |ordered_updates|.
@@ -420,7 +418,7 @@
bool BookmarkRemoteUpdatesHandler::ProcessCreate(
const syncer::UpdateResponseData& update) {
- const syncer::EntityData& update_entity = *update.entity;
+ const syncer::EntityData& update_entity = update.entity;
DCHECK(!update_entity.is_deleted());
if (!update_entity.server_defined_unique_tag.empty()) {
DLOG(ERROR)
@@ -437,7 +435,11 @@
// not populate GUID field and if the originator_client_item_id is not of
// valid GUID format to replace it, the field is left blank.
if (!base::IsValidGUID(update_entity.specifics.bookmark().guid())) {
- update.entity->specifics.mutable_bookmark()->set_guid(base::GenerateGUID());
+ // TODO(crbug.com/978430): Seems that's not the correct place for making any
+ // changes to |update|, need a proper place for generating GUID.
+ const_cast<syncer::UpdateResponseData&>(update)
+ .entity.specifics.mutable_bookmark()
+ ->set_guid(base::GenerateGUID());
}
const bookmarks::BookmarkNode* parent_node = GetParentNode(update_entity);
@@ -473,7 +475,7 @@
void BookmarkRemoteUpdatesHandler::ProcessUpdate(
const syncer::UpdateResponseData& update,
const SyncedBookmarkTracker::Entity* tracked_entity) {
- const syncer::EntityData& update_entity = *update.entity;
+ const syncer::EntityData& update_entity = update.entity;
// Can only update existing nodes.
DCHECK(tracked_entity);
DCHECK_EQ(tracked_entity,
@@ -552,7 +554,7 @@
void BookmarkRemoteUpdatesHandler::ProcessConflict(
const syncer::UpdateResponseData& update,
const SyncedBookmarkTracker::Entity* tracked_entity) {
- const syncer::EntityData& update_entity = *update.entity;
+ const syncer::EntityData& update_entity = update.entity;
// TODO(crbug.com/516866): Handle the case of conflict as a result of
// re-encryption request.
diff --git a/components/sync_bookmarks/bookmark_remote_updates_handler_unittest.cc b/components/sync_bookmarks/bookmark_remote_updates_handler_unittest.cc
index 32d29a8c..1510aab 100644
--- a/components/sync_bookmarks/bookmark_remote_updates_handler_unittest.cc
+++ b/components/sync_bookmarks/bookmark_remote_updates_handler_unittest.cc
@@ -47,7 +47,7 @@
const char kOtherBookmarksId[] = "other_bookmarks_id";
const char kOtherBookmarksTag[] = "other_bookmarks";
-std::unique_ptr<syncer::UpdateResponseData> CreateUpdateResponseData(
+syncer::UpdateResponseData CreateUpdateResponseData(
const std::string& server_id,
const std::string& parent_id,
const std::string& guid,
@@ -55,28 +55,28 @@
bool is_deletion,
int version,
const syncer::UniquePosition& unique_position) {
- auto data = std::make_unique<syncer::EntityData>();
- data->id = server_id;
- data->parent_id = parent_id;
- data->unique_position = unique_position.ToProto();
+ syncer::EntityData data;
+ data.id = server_id;
+ data.parent_id = parent_id;
+ data.unique_position = unique_position.ToProto();
// EntityData would be considered a deletion if its specifics hasn't been set.
if (!is_deletion) {
sync_pb::BookmarkSpecifics* bookmark_specifics =
- data->specifics.mutable_bookmark();
+ data.specifics.mutable_bookmark();
bookmark_specifics->set_guid(guid);
bookmark_specifics->set_title(title);
}
- data->is_folder = true;
- auto response_data = std::make_unique<syncer::UpdateResponseData>();
- response_data->entity = std::move(data);
- response_data->response_version = version;
+ data.is_folder = true;
+ syncer::UpdateResponseData response_data;
+ response_data.entity = std::move(data);
+ response_data.response_version = version;
return response_data;
}
// Overload that assigns a random GUID. Should only be used when GUID is not
// relevant.
-std::unique_ptr<syncer::UpdateResponseData> CreateUpdateResponseData(
+syncer::UpdateResponseData CreateUpdateResponseData(
const std::string& server_id,
const std::string& parent_id,
const std::string& title,
@@ -89,7 +89,7 @@
// Overload that assign a random position. Should only be used when position
// is not relevant.
-std::unique_ptr<syncer::UpdateResponseData> CreateUpdateResponseData(
+syncer::UpdateResponseData CreateUpdateResponseData(
const std::string& server_id,
const std::string& parent_id,
bool is_deletion,
@@ -100,36 +100,36 @@
syncer::UniquePosition::RandomSuffix()));
}
-std::unique_ptr<syncer::UpdateResponseData> CreateBookmarkRootUpdateData() {
- auto data = std::make_unique<syncer::EntityData>();
- data->id = syncer::ModelTypeToRootTag(syncer::BOOKMARKS);
- data->parent_id = kRootParentId;
- data->server_defined_unique_tag =
+syncer::UpdateResponseData CreateBookmarkRootUpdateData() {
+ syncer::EntityData data;
+ data.id = syncer::ModelTypeToRootTag(syncer::BOOKMARKS);
+ data.parent_id = kRootParentId;
+ data.server_defined_unique_tag =
syncer::ModelTypeToRootTag(syncer::BOOKMARKS);
- data->specifics.mutable_bookmark();
+ data.specifics.mutable_bookmark();
- auto response_data = std::make_unique<syncer::UpdateResponseData>();
- response_data->entity = std::move(data);
+ syncer::UpdateResponseData response_data;
+ response_data.entity = std::move(data);
// Similar to what's done in the loopback_server.
- response_data->response_version = 0;
+ response_data.response_version = 0;
return response_data;
}
-std::unique_ptr<syncer::UpdateResponseData> CreatePermanentFolderUpdateData(
+syncer::UpdateResponseData CreatePermanentFolderUpdateData(
const std::string& id,
const std::string& tag) {
- auto data = std::make_unique<syncer::EntityData>();
- data->id = id;
- data->parent_id = "root_id";
- data->server_defined_unique_tag = tag;
+ syncer::EntityData data;
+ data.id = id;
+ data.parent_id = "root_id";
+ data.server_defined_unique_tag = tag;
- data->specifics.mutable_bookmark();
+ data.specifics.mutable_bookmark();
- auto response_data = std::make_unique<syncer::UpdateResponseData>();
- response_data->entity = std::move(data);
+ syncer::UpdateResponseData response_data;
+ response_data.entity = std::move(data);
// Similar to what's done in the loopback_server.
- response_data->response_version = 0;
+ response_data.response_version = 0;
return response_data;
}
@@ -246,12 +246,12 @@
// This is test is over verifying since the order requirements are
// within subtrees only. (e.g it doesn't matter whether node1 comes before or
// after node4). However, it's implemented this way for simplicity.
- EXPECT_THAT(ordered_updates[0]->entity->id, Eq(ids[4]));
- EXPECT_THAT(ordered_updates[1]->entity->id, Eq(ids[5]));
- EXPECT_THAT(ordered_updates[2]->entity->id, Eq(ids[0]));
- EXPECT_THAT(ordered_updates[3]->entity->id, Eq(ids[1]));
- EXPECT_THAT(ordered_updates[4]->entity->id, Eq(ids[2]));
- EXPECT_THAT(ordered_updates[5]->entity->id, Eq(ids[6]));
+ EXPECT_THAT(ordered_updates[0]->entity.id, Eq(ids[4]));
+ EXPECT_THAT(ordered_updates[1]->entity.id, Eq(ids[5]));
+ EXPECT_THAT(ordered_updates[2]->entity.id, Eq(ids[0]));
+ EXPECT_THAT(ordered_updates[3]->entity.id, Eq(ids[1]));
+ EXPECT_THAT(ordered_updates[4]->entity.id, Eq(ids[2]));
+ EXPECT_THAT(ordered_updates[5]->entity.id, Eq(ids[6]));
}
TEST_F(BookmarkRemoteUpdatesHandlerWithInitialMergeTest,
@@ -720,25 +720,25 @@
const GURL kIconUrl("http://www.icon-url.com");
syncer::UpdateResponseDataList updates;
- auto data = std::make_unique<syncer::EntityData>();
- data->id = "server_id";
- data->parent_id = kBookmarkBarId;
- data->unique_position = syncer::UniquePosition::InitialPosition(
- syncer::UniquePosition::RandomSuffix())
- .ToProto();
+ syncer::EntityData data;
+ data.id = "server_id";
+ data.parent_id = kBookmarkBarId;
+ data.unique_position = syncer::UniquePosition::InitialPosition(
+ syncer::UniquePosition::RandomSuffix())
+ .ToProto();
sync_pb::BookmarkSpecifics* bookmark_specifics =
- data->specifics.mutable_bookmark();
+ data.specifics.mutable_bookmark();
bookmark_specifics->set_guid(base::GenerateGUID());
// Use the server id as the title for simplicity.
bookmark_specifics->set_title(kTitle);
bookmark_specifics->set_url(kUrl.spec());
bookmark_specifics->set_icon_url(kIconUrl.spec());
bookmark_specifics->set_favicon("PNG");
- data->is_folder = false;
- auto response_data = std::make_unique<syncer::UpdateResponseData>();
- response_data->entity = std::move(data);
+ data.is_folder = false;
+ syncer::UpdateResponseData response_data;
+ response_data.entity = std::move(data);
// Similar to what's done in the loopback_server.
- response_data->response_version = 0;
+ response_data.response_version = 0;
updates.push_back(std::move(response_data));
@@ -759,23 +759,23 @@
const GURL kUrl("http://www.url.com");
syncer::UpdateResponseDataList updates;
- auto data = std::make_unique<syncer::EntityData>();
- data->id = "server_id";
- data->parent_id = kBookmarkBarId;
- data->unique_position = syncer::UniquePosition::InitialPosition(
- syncer::UniquePosition::RandomSuffix())
- .ToProto();
+ syncer::EntityData data;
+ data.id = "server_id";
+ data.parent_id = kBookmarkBarId;
+ data.unique_position = syncer::UniquePosition::InitialPosition(
+ syncer::UniquePosition::RandomSuffix())
+ .ToProto();
sync_pb::BookmarkSpecifics* bookmark_specifics =
- data->specifics.mutable_bookmark();
+ data.specifics.mutable_bookmark();
bookmark_specifics->set_guid(base::GenerateGUID());
// Use the server id as the title for simplicity.
bookmark_specifics->set_title(kTitle);
bookmark_specifics->set_url(kUrl.spec());
- data->is_folder = false;
- auto response_data = std::make_unique<syncer::UpdateResponseData>();
- response_data->entity = std::move(data);
+ data.is_folder = false;
+ syncer::UpdateResponseData response_data;
+ response_data.entity = std::move(data);
// Similar to what's done in the loopback_server.
- response_data->response_version = 0;
+ response_data.response_version = 0;
updates.push_back(std::move(response_data));
@@ -833,21 +833,21 @@
// Now receive an update with the actual server id.
syncer::UpdateResponseDataList updates;
- auto data = std::make_unique<syncer::EntityData>();
- data->id = kSyncId;
- data->originator_cache_guid = kCacheGuid;
- data->originator_client_item_id = kOriginatorClientItemId;
+ syncer::EntityData data;
+ data.id = kSyncId;
+ data.originator_cache_guid = kCacheGuid;
+ data.originator_client_item_id = kOriginatorClientItemId;
// Set the other required fields.
- data->unique_position = syncer::UniquePosition::InitialPosition(
- syncer::UniquePosition::RandomSuffix())
- .ToProto();
- data->specifics = specifics;
- data->is_folder = true;
+ data.unique_position = syncer::UniquePosition::InitialPosition(
+ syncer::UniquePosition::RandomSuffix())
+ .ToProto();
+ data.specifics = specifics;
+ data.is_folder = true;
- auto response_data = std::make_unique<syncer::UpdateResponseData>();
- response_data->entity = std::move(data);
+ syncer::UpdateResponseData response_data;
+ response_data.entity = std::move(data);
// Similar to what's done in the loopback_server.
- response_data->response_version = 0;
+ response_data.response_version = 0;
updates.push_back(std::move(response_data));
testing::NiceMock<favicon::MockFaviconService> favicon_service;
@@ -880,11 +880,11 @@
const std::string kId0 = "id0";
syncer::UpdateResponseDataList updates;
- std::unique_ptr<syncer::UpdateResponseData> response_data =
+ syncer::UpdateResponseData response_data =
CreateUpdateResponseData(/*server_id=*/kId0,
/*parent_id=*/kBookmarkBarId,
/*is_deletion=*/false);
- response_data->encryption_key_name = "out_of_date_encryption_key_name";
+ response_data.encryption_key_name = "out_of_date_encryption_key_name";
updates.push_back(std::move(response_data));
BookmarkRemoteUpdatesHandler updates_handler(bookmark_model.get(),
@@ -933,11 +933,11 @@
const std::string kId = "id";
const std::string kTitle = "title";
syncer::UpdateResponseDataList updates;
- std::unique_ptr<syncer::UpdateResponseData> response_data =
+ syncer::UpdateResponseData response_data =
CreateUpdateResponseData(/*server_id=*/kId,
/*parent_id=*/kBookmarkBarId,
/*is_deletion=*/false);
- response_data->encryption_key_name = "encryption_key_name";
+ response_data.encryption_key_name = "encryption_key_name";
updates.push_back(std::move(response_data));
BookmarkRemoteUpdatesHandler updates_handler(bookmark_model.get(),
@@ -961,14 +961,14 @@
// Push a remote deletion for the same entity with an out of date encryption
// key name.
updates.clear();
- std::unique_ptr<syncer::UpdateResponseData> response_data2 =
+ syncer::UpdateResponseData response_data2 =
CreateUpdateResponseData(/*server_id=*/kId,
/*parent_id=*/kBookmarkBarId,
/*is_deletion=*/true);
- response_data2->encryption_key_name = "out_of_date_encryption_key_name";
+ response_data2.encryption_key_name = "out_of_date_encryption_key_name";
// Increment the server version to make sure the update isn't discarded as
// reflection.
- response_data2->response_version++;
+ response_data2.response_version++;
updates.push_back(std::move(response_data2));
base::HistogramTester histogram_tester;
@@ -996,14 +996,14 @@
EXPECT_THAT(tracker()->GetEntityForSyncId(kId0)->IsUnsynced(), Eq(false));
// Push another update to for the same entity.
- std::unique_ptr<syncer::UpdateResponseData> response_data =
+ syncer::UpdateResponseData response_data =
CreateUpdateResponseData(/*server_id=*/kId0,
/*parent_id=*/kBookmarkBarId,
/*is_deletion=*/false);
// Increment the server version to make sure the update isn't discarded as
// reflection.
- response_data->response_version++;
+ response_data.response_version++;
syncer::UpdateResponseDataList new_updates;
new_updates.push_back(std::move(response_data));
updates_handler()->Process(new_updates,
diff --git a/components/sync_device_info/device_info_sync_bridge_unittest.cc b/components/sync_device_info/device_info_sync_bridge_unittest.cc
index f967316..28c5576 100644
--- a/components/sync_device_info/device_info_sync_bridge_unittest.cc
+++ b/components/sync_device_info/device_info_sync_bridge_unittest.cc
@@ -253,10 +253,9 @@
}
// Creates an EntityData around a copy of the given specifics.
-std::unique_ptr<EntityData> SpecificsToEntity(
- const DeviceInfoSpecifics& specifics) {
- auto data = std::make_unique<EntityData>();
- *data->specifics.mutable_device_info() = specifics;
+EntityData SpecificsToEntity(const DeviceInfoSpecifics& specifics) {
+ EntityData data;
+ *data.specifics.mutable_device_info() = specifics;
return data;
}
diff --git a/components/sync_sessions/session_sync_bridge_unittest.cc b/components/sync_sessions/session_sync_bridge_unittest.cc
index fa5198e..aa6305b0 100644
--- a/components/sync_sessions/session_sync_bridge_unittest.cc
+++ b/components/sync_sessions/session_sync_bridge_unittest.cc
@@ -78,22 +78,21 @@
result_listener);
}
-std::unique_ptr<syncer::EntityData> SpecificsToEntity(
- const sync_pb::SessionSpecifics& specifics,
- base::Time mtime = base::Time::Now()) {
- auto data = std::make_unique<syncer::EntityData>();
- data->client_tag_hash = syncer::ClientTagHash::FromUnhashed(
+syncer::EntityData SpecificsToEntity(const sync_pb::SessionSpecifics& specifics,
+ base::Time mtime = base::Time::Now()) {
+ syncer::EntityData data;
+ data.client_tag_hash = syncer::ClientTagHash::FromUnhashed(
syncer::SESSIONS, SessionStore::GetClientTag(specifics));
- *data->specifics.mutable_session() = specifics;
- data->modification_time = mtime;
+ *data.specifics.mutable_session() = specifics;
+ data.modification_time = mtime;
return data;
}
-std::unique_ptr<syncer::UpdateResponseData> SpecificsToUpdateResponse(
+syncer::UpdateResponseData SpecificsToUpdateResponse(
const sync_pb::SessionSpecifics& specifics,
base::Time mtime = base::Time::Now()) {
- auto data = std::make_unique<syncer::UpdateResponseData>();
- data->entity = SpecificsToEntity(specifics, mtime);
+ syncer::UpdateResponseData data;
+ data.entity = SpecificsToEntity(specifics, mtime);
return data;
}
@@ -106,16 +105,15 @@
return storage_key_to_data;
}
-std::unique_ptr<syncer::UpdateResponseData> CreateTombstone(
- const std::string& client_tag) {
- auto tombstone = std::make_unique<syncer::EntityData>();
+syncer::UpdateResponseData CreateTombstone(const std::string& client_tag) {
+ syncer::EntityData tombstone;
- tombstone->client_tag_hash =
+ tombstone.client_tag_hash =
syncer::ClientTagHash::FromUnhashed(syncer::SESSIONS, client_tag);
- auto data = std::make_unique<syncer::UpdateResponseData>();
- data->entity = std::move(tombstone);
- data->response_version = 2;
+ syncer::UpdateResponseData data;
+ data.entity = std::move(tombstone);
+ data.response_version = 2;
return data;
}