Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(39)

Unified Diff: components/sync/test/fake_server/fake_server.cc

Issue 2328393002: [Sync] Add a sanity integration test for USS. (Closed)
Patch Set: Rebase. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: components/sync/test/fake_server/fake_server.cc
diff --git a/components/sync/test/fake_server/fake_server.cc b/components/sync/test/fake_server/fake_server.cc
index 1bd66687dbec547afb0ee9d74f6367d58de6194c..8642ad3ead88e7ba805f6ad19f7c6771b54ac830 100644
--- a/components/sync/test/fake_server/fake_server.cc
+++ b/components/sync/test/fake_server/fake_server.cc
@@ -100,7 +100,7 @@ class UpdateSieve {
}
ModelTypeToVersionMap::const_iterator it =
- request_from_version_.find(entity.GetModelType());
+ request_from_version_.find(entity.model_type());
return it == request_from_version_.end() ? false : it->second < version;
}
@@ -232,7 +232,7 @@ void FakeServer::UpdateEntityVersion(FakeServerEntity* entity) {
void FakeServer::SaveEntity(std::unique_ptr<FakeServerEntity> entity) {
UpdateEntityVersion(entity.get());
- entities_[entity->GetId()] = std::move(entity);
+ entities_[entity->id()] = std::move(entity);
}
void FakeServer::HandleCommand(const string& request,
@@ -368,7 +368,7 @@ bool FakeServer::HandleGetUpdatesRequest(
max_response_version =
std::max(max_response_version, response_entity->version());
- if (entity.GetModelType() == syncer::NIGORI) {
+ if (entity.model_type() == syncer::NIGORI) {
send_encryption_keys_based_on_nigori =
response_entity->specifics().nigori().passphrase_type() ==
sync_pb::NigoriSpecifics::KEYSTORE_PASSPHRASE;
@@ -399,7 +399,8 @@ string FakeServer::CommitEntity(
std::unique_ptr<FakeServerEntity> entity;
if (client_entity.deleted()) {
- entity = TombstoneEntity::Create(client_entity.id_string());
+ entity = TombstoneEntity::Create(client_entity.id_string(),
+ client_entity.client_defined_unique_tag());
DeleteChildren(client_entity.id_string());
} else if (GetModelType(client_entity) == syncer::NIGORI) {
// NIGORI is the only permanent item type that should be updated by the
@@ -427,7 +428,7 @@ string FakeServer::CommitEntity(
return string();
}
- const std::string id = entity->GetId();
+ const std::string id = entity->id();
SaveEntity(std::move(entity));
BuildEntryResponseForSuccessfulCommit(id, entry_response);
return id;
@@ -440,7 +441,7 @@ void FakeServer::BuildEntryResponseForSuccessfulCommit(
CHECK(iter != entities_.end());
const FakeServerEntity& entity = *iter->second;
entry_response->set_response_type(sync_pb::CommitResponse::SUCCESS);
- entry_response->set_id_string(entity.GetId());
+ entry_response->set_id_string(entity.id());
if (entity.IsDeleted()) {
entry_response->set_version(entity.GetVersion() + 1);
@@ -467,16 +468,17 @@ bool FakeServer::IsChild(const string& id, const string& potential_parent_id) {
}
void FakeServer::DeleteChildren(const string& id) {
- std::set<string> tombstones_ids;
+ std::vector<std::unique_ptr<FakeServerEntity>> tombstones;
// Find all the children of id.
- for (auto& entity : entities_) {
+ for (const auto& entity : entities_) {
if (IsChild(entity.first, id)) {
- tombstones_ids.insert(entity.first);
+ tombstones.push_back(TombstoneEntity::Create(
+ entity.first, entity.second->client_defined_unique_tag()));
}
}
- for (auto& tombstone_id : tombstones_ids) {
- SaveEntity(TombstoneEntity::Create(tombstone_id));
+ for (auto& tombstone : tombstones) {
+ SaveEntity(std::move(tombstone));
}
}
@@ -512,7 +514,7 @@ bool FakeServer::HandleCommitRequest(const sync_pb::CommitMessage& commit,
EntityMap::const_iterator iter = entities_.find(entity_id);
CHECK(iter != entities_.end());
- committed_model_types.Put(iter->second->GetModelType());
+ committed_model_types.Put(iter->second->model_type());
}
FOR_EACH_OBSERVER(Observer, observers_,
@@ -542,7 +544,7 @@ FakeServer::GetEntitiesAsDictionaryValue() {
continue;
}
base::ListValue* list_value;
- if (!dictionary->GetList(ModelTypeToString(entity.GetModelType()),
+ if (!dictionary->GetList(ModelTypeToString(entity.model_type()),
&list_value)) {
return std::unique_ptr<base::DictionaryValue>();
}
@@ -562,7 +564,7 @@ std::vector<sync_pb::SyncEntity> FakeServer::GetSyncEntitiesByModelType(
for (EntityMap::const_iterator it = entities_.begin(); it != entities_.end();
++it) {
const FakeServerEntity& entity = *it->second;
- if (!IsDeletedOrPermanent(entity) && entity.GetModelType() == model_type) {
+ if (!IsDeletedOrPermanent(entity) && entity.model_type() == model_type) {
sync_pb::SyncEntity sync_entity;
entity.SerializeAsProto(&sync_entity);
sync_entities.push_back(sync_entity);
@@ -581,7 +583,7 @@ bool FakeServer::ModifyEntitySpecifics(
const sync_pb::EntitySpecifics& updated_specifics) {
EntityMap::const_iterator iter = entities_.find(id);
if (iter == entities_.end() ||
- iter->second->GetModelType() !=
+ iter->second->model_type() !=
GetModelTypeFromSpecifics(updated_specifics)) {
return false;
}
@@ -598,7 +600,7 @@ bool FakeServer::ModifyBookmarkEntity(
const sync_pb::EntitySpecifics& updated_specifics) {
EntityMap::const_iterator iter = entities_.find(id);
if (iter == entities_.end() ||
- iter->second->GetModelType() != syncer::BOOKMARKS ||
+ iter->second->model_type() != syncer::BOOKMARKS ||
GetModelTypeFromSpecifics(updated_specifics) != syncer::BOOKMARKS) {
return false;
}
@@ -713,8 +715,8 @@ std::string FakeServer::GetBookmarkBarFolderId() const {
++it) {
FakeServerEntity* entity = it->second.get();
if (entity->GetName() == kBookmarkBarFolderName && entity->IsFolder() &&
- entity->GetModelType() == syncer::BOOKMARKS) {
- return entity->GetId();
+ entity->model_type() == syncer::BOOKMARKS) {
+ return entity->id();
}
}
NOTREACHED() << "Bookmark Bar entity not found.";
« no previous file with comments | « components/sync/test/fake_server/bookmark_entity.cc ('k') | components/sync/test/fake_server/fake_server_entity.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698