diff options
author | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-03 20:45:28 +0000 |
---|---|---|
committer | rlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-06-03 20:45:28 +0000 |
commit | 65e95b761e3a5a284b85b62968f9d5629828ad54 (patch) | |
tree | 3da236126fc4a2f05a10adebfdeef8b6d02705c1 /components/sync_driver/generic_change_processor.cc | |
parent | 1084f4d4971a2a620aac25d193b6942ca1faa69a (diff) | |
download | chromium_src-65e95b761e3a5a284b85b62968f9d5629828ad54.zip chromium_src-65e95b761e3a5a284b85b62968f9d5629828ad54.tar.gz chromium_src-65e95b761e3a5a284b85b62968f9d5629828ad54.tar.bz2 |
sync: Specialize functions that fetch type root
Adds functions to look up the root node of a give type. This replaces
most of the use cases for the functions that look up a node by unique
server tag, so those functions have been renamed to indicate their
near-deprecation.
This is part of the effort to remove the client's dependence on the
server for the creation of type root nodes. Although it's unlikely that
we can make this work for existing types, new types should be prepared
to work properly in the absence of tyep root nodes. The first step on
that path is to abstract away the mechanism by which we look up the type
roots.
Renaming the old lookup by tag functions allows us to ensure that there
no remaining cases where the code base looks up type roots by server
tag. This CL also adds a few DCHECKs to ensure type roots are never
looked up using the old lookup by server tag functions.
BUG=373869
Review URL: https://codereview.chromium.org/302173004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@274613 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/sync_driver/generic_change_processor.cc')
-rw-r--r-- | components/sync_driver/generic_change_processor.cc | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/components/sync_driver/generic_change_processor.cc b/components/sync_driver/generic_change_processor.cc index 6341ab2..7d8ef4d 100644 --- a/components/sync_driver/generic_change_processor.cc +++ b/components/sync_driver/generic_change_processor.cc @@ -223,8 +223,7 @@ syncer::SyncError GenericChangeProcessor::GetAllSyncDataReturnError( std::string type_name = syncer::ModelTypeToString(type); syncer::ReadTransaction trans(FROM_HERE, share_handle()); syncer::ReadNode root(&trans); - if (root.InitByTagLookup(syncer::ModelTypeToRootTag(type)) != - syncer::BaseNode::INIT_OK) { + if (root.InitTypeRoot(type) != syncer::BaseNode::INIT_OK) { syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, "Server did not create the top-level " + type_name + @@ -276,8 +275,7 @@ bool GenericChangeProcessor::GetDataTypeContext(syncer::ModelType type, int GenericChangeProcessor::GetSyncCountForType(syncer::ModelType type) { syncer::ReadTransaction trans(FROM_HERE, share_handle()); syncer::ReadNode root(&trans); - if (root.InitByTagLookup(syncer::ModelTypeToRootTag(type)) != - syncer::BaseNode::INIT_OK) + if (root.InitTypeRoot(type) != syncer::BaseNode::INIT_OK) return 0; // Subtract one to account for type's root node. @@ -495,8 +493,8 @@ syncer::SyncError GenericChangeProcessor::HandleActionAdd( // etc.). syncer::ReadNode root_node(&trans); const syncer::SyncDataLocal sync_data_local(change.sync_data()); - if (root_node.InitByTagLookup(syncer::ModelTypeToRootTag( - sync_data_local.GetDataType())) != syncer::BaseNode::INIT_OK) { + if (root_node.InitTypeRoot(sync_data_local.GetDataType()) != + syncer::BaseNode::INIT_OK) { syncer::SyncError error(FROM_HERE, syncer::SyncError::DATATYPE_ERROR, "Failed to look up root node for type " + type_str, @@ -704,8 +702,7 @@ bool GenericChangeProcessor::SyncModelHasUserCreatedNodes( *has_nodes = false; syncer::ReadTransaction trans(FROM_HERE, share_handle()); syncer::ReadNode type_root_node(&trans); - if (type_root_node.InitByTagLookup(syncer::ModelTypeToRootTag(type)) != - syncer::BaseNode::INIT_OK) { + if (type_root_node.InitTypeRoot(type) != syncer::BaseNode::INIT_OK) { LOG(ERROR) << err_str; return false; } |