Commit afce451f authored by tim@chromium.org's avatar tim@chromium.org

sync: we can't lookup empty client tag nodes, so don't allow creating them

BUG=none
TEST=SyncApiTest.EmptyTags


Review URL: http://codereview.chromium.org/7970018

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@102432 0039d316-1c4b-4281-b951-d872f2087c98
parent 965202b4
...@@ -564,6 +564,17 @@ TEST_F(SyncApiTest, BaseNodeGetDetailsAsValue) { ...@@ -564,6 +564,17 @@ TEST_F(SyncApiTest, BaseNodeGetDetailsAsValue) {
} }
} }
TEST_F(SyncApiTest, EmptyTags) {
WriteTransaction trans(FROM_HERE, test_user_share_.user_share());
ReadNode root_node(&trans);
root_node.InitByRootLookup();
WriteNode node(&trans);
std::string empty_tag;
EXPECT_FALSE(node.InitUniqueByCreation(
syncable::TYPED_URLS, root_node, empty_tag));
EXPECT_FALSE(node.InitByTagLookup(empty_tag));
}
namespace { namespace {
class TestHttpPostProviderInterface : public HttpPostProviderInterface { class TestHttpPostProviderInterface : public HttpPostProviderInterface {
......
...@@ -394,6 +394,10 @@ bool WriteNode::InitUniqueByCreation(syncable::ModelType model_type, ...@@ -394,6 +394,10 @@ bool WriteNode::InitUniqueByCreation(syncable::ModelType model_type,
const BaseNode& parent, const BaseNode& parent,
const std::string& tag) { const std::string& tag) {
DCHECK(!entry_) << "Init called twice"; DCHECK(!entry_) << "Init called twice";
if (tag.empty()) {
LOG(WARNING) << "InitUniqueByCreation failed due to empty tag.";
return false;
}
const std::string hash = GenerateSyncableHash(model_type, tag); const std::string hash = GenerateSyncableHash(model_type, tag);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment