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

Unified Diff: components/sync/engine_impl/test_entry_factory.cc

Issue 2630613002: [Sync] USS: Filter out tombstones for initial sync. (Closed)
Patch Set: Fix TestEntryFactory for realz. Created 3 years, 11 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
« no previous file with comments | « components/sync/engine_impl/test_entry_factory.h ('k') | components/sync/engine_impl/uss_migrator.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/sync/engine_impl/test_entry_factory.cc
diff --git a/components/sync/engine_impl/test_entry_factory.cc b/components/sync/engine_impl/test_entry_factory.cc
index 0960d869f2ff2105e19fcaa2c9dfb49e60918846..1321a876793593fb09fe438522b64eb4418a22b2 100644
--- a/components/sync/engine_impl/test_entry_factory.cc
+++ b/components/sync/engine_impl/test_entry_factory.cc
@@ -158,9 +158,6 @@ int64_t TestEntryFactory::CreateSyncedItem(
// Use the type root if it exists or the real root otherwise.
syncable::Entry root(&trans, syncable::GET_TYPE_ROOT, model_type);
syncable::Id parent_id = root.good() ? root.GetId() : TestIdFactory::root();
- syncable::Id item_id(TestIdFactory::MakeServer(name));
- int64_t version = GetNextRevision();
- base::Time now = base::Time::Now();
MutableEntry entry(&trans, syncable::CREATE, model_type, parent_id, name);
if (!entry.good()) {
@@ -168,25 +165,9 @@ int64_t TestEntryFactory::CreateSyncedItem(
return syncable::kInvalidMetaHandle;
}
- entry.PutId(item_id);
- entry.PutCtime(now);
- entry.PutMtime(now);
- entry.PutUniqueClientTag(GenerateSyncableHash(model_type, name));
- entry.PutBaseVersion(version);
- entry.PutIsUnsynced(false);
- entry.PutNonUniqueName(name);
+ PopulateEntry(parent_id, name, model_type, &entry);
entry.PutIsDir(is_folder);
- entry.PutIsDel(false);
- entry.PutParentId(parent_id);
-
- entry.PutServerCtime(now);
- entry.PutServerMtime(now);
- entry.PutServerVersion(version);
- entry.PutIsUnappliedUpdate(false);
- entry.PutServerNonUniqueName(name);
- entry.PutServerParentId(parent_id);
entry.PutServerIsDir(is_folder);
- entry.PutServerIsDel(false);
// Only rewrite the default specifics inside the entry (which have the model
// type marker already) if |specifics| actually contains data.
@@ -200,6 +181,26 @@ int64_t TestEntryFactory::CreateSyncedItem(
return entry.GetMetahandle();
}
+int64_t TestEntryFactory::CreateTombstone(const std::string& name,
+ ModelType model_type) {
+ WriteTransaction trans(FROM_HERE, UNITTEST, directory_);
+
+ // Use the type root if it exists or the real root otherwise.
+ syncable::Entry root(&trans, syncable::GET_TYPE_ROOT, model_type);
+ syncable::Id parent_id = root.good() ? root.GetId() : TestIdFactory::root();
+
+ MutableEntry entry(&trans, syncable::CREATE, model_type, parent_id, name);
+ if (!entry.good()) {
+ NOTREACHED();
+ return syncable::kInvalidMetaHandle;
+ }
+
+ PopulateEntry(parent_id, name, model_type, &entry);
+ entry.PutIsDel(true);
+ entry.PutServerIsDel(true);
+ return entry.GetMetahandle();
+}
+
int64_t TestEntryFactory::CreateTypeRootNode(ModelType model_type) {
syncable::ModelNeutralWriteTransaction trans(FROM_HERE, syncable::UNITTEST,
directory_);
@@ -343,4 +344,33 @@ int64_t TestEntryFactory::GetNextRevision() {
return next_revision_++;
}
+void TestEntryFactory::PopulateEntry(const syncable::Id& parent_id,
+ const std::string& name,
+ ModelType model_type,
+ MutableEntry* entry) {
+ syncable::Id item_id(TestIdFactory::MakeServer(name));
+ int64_t version = GetNextRevision();
+ base::Time now = base::Time::Now();
+
+ entry->PutId(item_id);
+ entry->PutCtime(now);
+ entry->PutMtime(now);
+ entry->PutUniqueClientTag(GenerateSyncableHash(model_type, name));
+ entry->PutBaseVersion(version);
+ entry->PutIsUnsynced(false);
+ entry->PutNonUniqueName(name);
+ entry->PutIsDir(false);
+ entry->PutIsDel(false);
+ entry->PutParentId(parent_id);
+
+ entry->PutServerCtime(now);
+ entry->PutServerMtime(now);
+ entry->PutServerVersion(version);
+ entry->PutIsUnappliedUpdate(false);
+ entry->PutServerNonUniqueName(name);
+ entry->PutServerParentId(parent_id);
+ entry->PutServerIsDir(false);
+ entry->PutServerIsDel(false);
+}
+
} // namespace syncer
« no previous file with comments | « components/sync/engine_impl/test_entry_factory.h ('k') | components/sync/engine_impl/uss_migrator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698