summaryrefslogtreecommitdiffstats
path: root/sync/internal_api
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/internal_api
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/internal_api')
-rw-r--r--sync/internal_api/base_node.cc6
-rw-r--r--sync/internal_api/sync_manager_impl_unittest.cc5
-rw-r--r--sync/internal_api/sync_rollback_manager_base.cc2
-rw-r--r--sync/internal_api/test/test_entry_factory.cc2
-rw-r--r--sync/internal_api/write_node.cc2
5 files changed, 10 insertions, 7 deletions
diff --git a/sync/internal_api/base_node.cc b/sync/internal_api/base_node.cc
index 57dbb22..b43c6ca 100644
--- a/sync/internal_api/base_node.cc
+++ b/sync/internal_api/base_node.cc
@@ -177,21 +177,21 @@ bool BaseNode::HasChildren() const {
int64 BaseNode::GetPredecessorId() const {
syncable::Id id_string = GetEntry()->GetPredecessorId();
- if (id_string.IsRoot())
+ if (id_string.IsNull())
return kInvalidId;
return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string);
}
int64 BaseNode::GetSuccessorId() const {
syncable::Id id_string = GetEntry()->GetSuccessorId();
- if (id_string.IsRoot())
+ if (id_string.IsNull())
return kInvalidId;
return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string);
}
int64 BaseNode::GetFirstChildId() const {
syncable::Id id_string = GetEntry()->GetFirstChildId();
- if (id_string.IsRoot())
+ if (id_string.IsNull())
return kInvalidId;
return IdToMetahandle(GetTransaction()->GetWrappedTrans(), id_string);
}
diff --git a/sync/internal_api/sync_manager_impl_unittest.cc b/sync/internal_api/sync_manager_impl_unittest.cc
index ac5b31a..e6a1fa9 100644
--- a/sync/internal_api/sync_manager_impl_unittest.cc
+++ b/sync/internal_api/sync_manager_impl_unittest.cc
@@ -155,7 +155,10 @@ int64 MakeServerNodeForType(UserShare* share,
entry.PutBaseVersion(1);
entry.PutServerVersion(1);
entry.PutIsUnappliedUpdate(false);
- entry.PutServerParentId(syncable::GetNullId());
+ // TODO(stanisc): setting parent ID might be unnecessary once
+ // empty parent ID is supported.
+ entry.PutParentId(syncable::Id::GetRoot());
+ entry.PutServerParentId(syncable::Id::GetRoot());
entry.PutServerIsDir(true);
entry.PutIsDir(true);
entry.PutServerSpecifics(specifics);
diff --git a/sync/internal_api/sync_rollback_manager_base.cc b/sync/internal_api/sync_rollback_manager_base.cc
index baedec0..587ea56 100644
--- a/sync/internal_api/sync_rollback_manager_base.cc
+++ b/sync/internal_api/sync_rollback_manager_base.cc
@@ -270,7 +270,7 @@ bool SyncRollbackManagerBase::InitTypeRootNode(ModelType type) {
if (!entry.good())
return false;
- entry.PutParentId(syncable::Id());
+ entry.PutParentId(syncable::Id::GetRoot());
entry.PutBaseVersion(1);
entry.PutUniqueServerTag(ModelTypeToRootTag(type));
entry.PutNonUniqueName(ModelTypeToString(type));
diff --git a/sync/internal_api/test/test_entry_factory.cc b/sync/internal_api/test/test_entry_factory.cc
index d2e6b73..8941040 100644
--- a/sync/internal_api/test/test_entry_factory.cc
+++ b/sync/internal_api/test/test_entry_factory.cc
@@ -76,7 +76,7 @@ int64 TestEntryFactory::CreateUnappliedNewItem(
entry.PutServerVersion(GetNextRevision());
entry.PutIsUnappliedUpdate(true);
entry.PutServerNonUniqueName(item_id);
- entry.PutServerParentId(syncable::GetNullId());
+ entry.PutServerParentId(syncable::Id::GetRoot());
entry.PutServerIsDir(is_unique);
entry.PutServerSpecifics(specifics);
if (is_unique) { // For top-level nodes.
diff --git a/sync/internal_api/write_node.cc b/sync/internal_api/write_node.cc
index b1f0872..4aab598 100644
--- a/sync/internal_api/write_node.cc
+++ b/sync/internal_api/write_node.cc
@@ -461,7 +461,7 @@ bool WriteNode::SetPosition(const BaseNode& new_parent,
// Filter out redundant changes if both the parent and the predecessor match.
if (new_parent_id == entry_->GetParentId()) {
const syncable::Id& old = entry_->GetPredecessorId();
- if ((!predecessor && old.IsRoot()) ||
+ if ((!predecessor && old.IsNull()) ||
(predecessor && (old == predecessor->GetEntry()->GetId()))) {
return true;
}