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

Unified Diff: sync/syncable/syncable_util.cc

Issue 867793003: Remove dependency on server generated type root folders (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added ScopedKernelLock to Directory::HasEmptyDownloadProgress Created 5 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
« sync/syncable/syncable_id.cc ('K') | « sync/syncable/syncable_id.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sync/syncable/syncable_util.cc
diff --git a/sync/syncable/syncable_util.cc b/sync/syncable/syncable_util.cc
index d92aa47ed46d1e633da74123d3191010c46c27de..a8aca33747e4431bb5553363ac74c6a705d59197 100644
--- a/sync/syncable/syncable_util.cc
+++ b/sync/syncable/syncable_util.cc
@@ -28,8 +28,11 @@ int GetUnsyncedEntries(BaseTransaction* trans,
bool IsLegalNewParent(BaseTransaction* trans, const Id& entry_id,
const Id& new_parent_id) {
+ DCHECK(!entry_id.IsNull());
if (entry_id.IsRoot())
return false;
+ if (new_parent_id.IsNull())
+ return true;
Nicolas Zea 2015/01/26 23:21:53 Should this be false here for bookmarks?
stanisc 2015/01/28 07:30:06 Yes, I agree. I'll see if this check could be done
stanisc 2015/01/29 00:27:37 Done.
// we have to ensure that the entry is not an ancestor of the new parent.
Id ancestor_id = new_parent_id;
while (!ancestor_id.IsRoot()) {
@@ -66,11 +69,14 @@ void ChangeEntryIDAndUpdateChildren(
while (i != children.end()) {
ModelNeutralMutableEntry child_entry(trans, GET_BY_HANDLE, *i++);
CHECK(child_entry.good());
- // Use the unchecked setter here to avoid touching the child's
- // UNIQUE_POSITION field. In this case, UNIQUE_POSITION among the
- // children will be valid after the loop, since we update all the children
- // at once.
- child_entry.PutParentIdPropertyOnly(new_id);
+ // Change the parent ID of the entry unless it was unset (implicit)
+ if (!child_entry.GetParentId().IsNull()) {
+ // Use the unchecked setter here to avoid touching the child's
+ // UNIQUE_POSITION field. In this case, UNIQUE_POSITION among the
+ // children will be valid after the loop, since we update all the
+ // children at once.
+ child_entry.PutParentIdPropertyOnly(new_id);
+ }
}
}
}
« sync/syncable/syncable_id.cc ('K') | « sync/syncable/syncable_id.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698