summaryrefslogtreecommitdiffstats
path: root/sync/syncable/directory.cc
diff options
context:
space:
mode:
authorstanisc <stanisc@chromium.org>2014-12-22 16:02:38 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-23 00:03:31 +0000
commit60c25aebaf6c3bbc90c9c82f83a752ca58c7ddce (patch)
treeba1e9704812c4df07936e70948e3e52aa0c532b2 /sync/syncable/directory.cc
parent5794dbf611e14653d3ccfc8778b9052b0c129909 (diff)
downloadchromium_src-60c25aebaf6c3bbc90c9c82f83a752ca58c7ddce.zip
chromium_src-60c25aebaf6c3bbc90c9c82f83a752ca58c7ddce.tar.gz
chromium_src-60c25aebaf6c3bbc90c9c82f83a752ca58c7ddce.tar.bz2
Enable Null Syncable ID which is different than Root ID.
This patch prepares sync codebase for supporting datatypes with implicit permanent forlders by introducing an empty/unset syncable ID. There was a notion of Null ID before but it was equivalent to the root ID which caused some confusion in the code - a Null ID would sometimes be used where a "root" would be appropriate and vice versa. See the following code fragment for an example: // TODO(sync): We could use null here, but to ease conversion we use "r". // fix this, this is madness :) inline bool IsNull() const { return IsRoot(); } This change will be followed by one or two separate changes that will actually remove dependencies on PARENT_ID and SERVER_PARENT_ID and use a different way to organize nodes in the directory based on node's datatype rather than parent ID. This change impacts the following: 1) The default ID value in EntryKernel ID fields and elsewhere is Null ID and not Root ID as it used to be. 2) This means that some tests that depended on Root ID being set implicitly in PARENT_ID and SERVER_PARENT_ID now need to set these IDs explicitly. 3) Node's GetPredecessorId, GetSuccessorId, and GetFirstChildId methods now return a null ID rather than a root ID when there is no predecessor, successor, or children. 4) Small changed throughout the code to make sure that null IDs and root IDs are used accordingly (now that they are no longer equivalent). 5) Changed some validation methods to accept Null IDs to avoid large changes in the test code. BUG=438313 Review URL: https://codereview.chromium.org/805633004 Cr-Commit-Position: refs/heads/master@{#309495}
Diffstat (limited to 'sync/syncable/directory.cc')
-rw-r--r--sync/syncable/directory.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/sync/syncable/directory.cc b/sync/syncable/directory.cc
index 9c59409..22c3f46 100644
--- a/sync/syncable/directory.cc
+++ b/sync/syncable/directory.cc
@@ -1192,6 +1192,7 @@ bool Directory::CheckTreeInvariants(syncable::BaseTransaction* trans,
trans))
return false;
int safety_count = handles.size() + 1;
+ // TODO(stanisc): handle items with Null parentid
while (!parentid.IsRoot()) {
Entry parent(trans, GET_BY_ID, parentid);
if (!SyncAssert(parent.good(), FROM_HERE,
@@ -1392,13 +1393,13 @@ void Directory::PutPredecessor(EntryKernel* e, EntryKernel* predecessor) {
if (!siblings) {
// This parent currently has no other children.
- DCHECK(predecessor->ref(ID).IsRoot());
+ DCHECK(predecessor == NULL);
UniquePosition pos = UniquePosition::InitialPosition(suffix);
e->put(UNIQUE_POSITION, pos);
return;
}
- if (predecessor->ref(ID).IsRoot()) {
+ if (predecessor == NULL) {
// We have at least one sibling, and we're inserting to the left of them.
UniquePosition successor_pos = (*siblings->begin())->ref(UNIQUE_POSITION);