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

Side by Side Diff: components/sync/engine_impl/test_entry_factory.cc

Issue 2630613002: [Sync] USS: Filter out tombstones for initial sync. (Closed)
Patch Set: 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 unified diff | Download patch
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/sync/engine_impl/test_entry_factory.h" 5 #include "components/sync/engine_impl/test_entry_factory.h"
6 6
7 #include "components/sync/base/hash_util.h" 7 #include "components/sync/base/hash_util.h"
8 #include "components/sync/base/model_type.h" 8 #include "components/sync/base/model_type.h"
9 #include "components/sync/syncable/directory.h" 9 #include "components/sync/syncable/directory.h"
10 #include "components/sync/syncable/entry.h" 10 #include "components/sync/syncable/entry.h"
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 if (specifics.ByteSize() > 0) { 193 if (specifics.ByteSize() > 0) {
194 entry.PutSpecifics(specifics); 194 entry.PutSpecifics(specifics);
195 entry.PutServerSpecifics(specifics); 195 entry.PutServerSpecifics(specifics);
196 } else { 196 } else {
197 entry.PutServerSpecifics(entry.GetSpecifics()); 197 entry.PutServerSpecifics(entry.GetSpecifics());
198 } 198 }
199 199
200 return entry.GetMetahandle(); 200 return entry.GetMetahandle();
201 } 201 }
202 202
203 int64_t TestEntryFactory::CreateTombstone(const std::string& name,
skym 2017/01/13 16:31:23 It seems like there's a lot of duplicated logic be
maxbogue 2017/01/17 22:02:26 Done.
204 ModelType model_type) {
205 WriteTransaction trans(FROM_HERE, UNITTEST, directory_);
206
207 // Use the type root if it exists or the real root otherwise.
208 syncable::Entry root(&trans, syncable::GET_TYPE_ROOT, model_type);
209 syncable::Id parent_id = root.good() ? root.GetId() : TestIdFactory::root();
210 syncable::Id item_id(TestIdFactory::MakeServer(name));
211 int64_t version = GetNextRevision();
212 base::Time now = base::Time::Now();
213
214 MutableEntry entry(&trans, syncable::CREATE, model_type, parent_id, name);
215 if (!entry.good()) {
216 NOTREACHED();
217 return syncable::kInvalidMetaHandle;
218 }
219
220 entry.PutId(item_id);
221 entry.PutCtime(now);
222 entry.PutMtime(now);
223 entry.PutUniqueClientTag(GenerateSyncableHash(model_type, name));
224 entry.PutBaseVersion(version);
225 entry.PutIsUnsynced(false);
226 entry.PutNonUniqueName(name);
227 entry.PutIsDir(false);
228 entry.PutIsDel(true);
229 entry.PutParentId(parent_id);
230
231 entry.PutServerCtime(now);
232 entry.PutServerMtime(now);
233 entry.PutServerVersion(version);
234 entry.PutIsUnappliedUpdate(false);
235 entry.PutServerNonUniqueName(name);
236 entry.PutServerParentId(parent_id);
237 entry.PutServerIsDir(false);
238 entry.PutServerIsDel(true);
239
240 return entry.GetMetahandle();
241 }
242
203 int64_t TestEntryFactory::CreateTypeRootNode(ModelType model_type) { 243 int64_t TestEntryFactory::CreateTypeRootNode(ModelType model_type) {
204 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, syncable::UNITTEST, 244 syncable::ModelNeutralWriteTransaction trans(FROM_HERE, syncable::UNITTEST,
205 directory_); 245 directory_);
206 sync_pb::EntitySpecifics specifics; 246 sync_pb::EntitySpecifics specifics;
207 AddDefaultFieldValue(model_type, &specifics); 247 AddDefaultFieldValue(model_type, &specifics);
208 syncable::ModelNeutralMutableEntry entry( 248 syncable::ModelNeutralMutableEntry entry(
209 &trans, syncable::CREATE_NEW_TYPE_ROOT, model_type); 249 &trans, syncable::CREATE_NEW_TYPE_ROOT, model_type);
210 DCHECK(entry.good()); 250 DCHECK(entry.good());
211 entry.PutServerIsDir(true); 251 entry.PutServerIsDir(true);
212 entry.PutUniqueServerTag(ModelTypeToRootTag(model_type)); 252 entry.PutUniqueServerTag(ModelTypeToRootTag(model_type));
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
337 return false; 377 return false;
338 } 378 }
339 return entry.GetIsUnappliedUpdate(); 379 return entry.GetIsUnappliedUpdate();
340 } 380 }
341 381
342 int64_t TestEntryFactory::GetNextRevision() { 382 int64_t TestEntryFactory::GetNextRevision() {
343 return next_revision_++; 383 return next_revision_++;
344 } 384 }
345 385
346 } // namespace syncer 386 } // namespace syncer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698