summaryrefslogtreecommitdiffstats
path: root/sync/engine
diff options
context:
space:
mode:
authorrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-26 22:58:00 +0000
committerrlarocque@chromium.org <rlarocque@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-26 22:58:00 +0000
commit65e022eeecdde17380365097d983b5cb2499bdf0 (patch)
treef13891293c73c03bf55406dcc8ede90d6a7833ba /sync/engine
parentc536d0ad364d28121e47c0d0237a0cc462a79342 (diff)
downloadchromium_src-65e022eeecdde17380365097d983b5cb2499bdf0.zip
chromium_src-65e022eeecdde17380365097d983b5cb2499bdf0.tar.gz
chromium_src-65e022eeecdde17380365097d983b5cb2499bdf0.tar.bz2
sync: Stop supporting parent IDs for some types
Makes non-bookmarks nodes no longer send up a parent ID for each of their commits. This is part of an update to the sync protocol that will eventually allow both the client and server to remove support for type root nodes. Note that the client still expects to receive type root nodes from the server. That expectation will be removed in a future CL. BUG=373869 Review URL: https://codereview.chromium.org/310993002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@280148 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'sync/engine')
-rw-r--r--sync/engine/commit_util.cc5
-rw-r--r--sync/engine/directory_commit_contribution_unittest.cc62
2 files changed, 66 insertions, 1 deletions
diff --git a/sync/engine/commit_util.cc b/sync/engine/commit_util.cc
index 36b7c06..ad29e4f 100644
--- a/sync/engine/commit_util.cc
+++ b/sync/engine/commit_util.cc
@@ -128,7 +128,10 @@ void BuildCommitItem(
} else {
new_parent_id = meta_entry.GetParentId();
}
- sync_entry->set_parent_id_string(SyncableIdToProto(new_parent_id));
+
+ if (meta_entry.ShouldMaintainHierarchy()) {
+ sync_entry->set_parent_id_string(SyncableIdToProto(new_parent_id));
+ }
// If our parent has changed, send up the old one so the server
// can correctly deal with multiple parents.
diff --git a/sync/engine/directory_commit_contribution_unittest.cc b/sync/engine/directory_commit_contribution_unittest.cc
index b342b54..894db97 100644
--- a/sync/engine/directory_commit_contribution_unittest.cc
+++ b/sync/engine/directory_commit_contribution_unittest.cc
@@ -274,6 +274,68 @@ TEST_F(DirectoryCommitContributionTest, DeletedBookmarksWithSpecifics) {
bm_cc->CleanUp();
}
+// Test that bookmarks support hierarchy.
+TEST_F(DirectoryCommitContributionTest, HierarchySupport_Bookmark) {
+
+ // Create a normal-looking bookmark item.
+ int64 bm1;
+ {
+ syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir());
+ bm1 = CreateSyncedItem(&trans, BOOKMARKS, "bm1");
+ syncable::MutableEntry e(&trans, syncable::GET_BY_HANDLE, bm1);
+
+ sync_pb::EntitySpecifics specifics;
+ sync_pb::BookmarkSpecifics* bm_specifics = specifics.mutable_bookmark();
+ bm_specifics->set_url("http://www.chrome.com");
+ bm_specifics->set_title("Chrome");
+ e.PutSpecifics(specifics);
+
+ e.PutIsDel(false);
+ e.PutIsUnsynced(true);
+
+ EXPECT_TRUE(e.ShouldMaintainHierarchy());
+ }
+
+ DirectoryTypeDebugInfoEmitter emitter(BOOKMARKS, &type_observers_);
+ scoped_ptr<DirectoryCommitContribution> bm_cc(
+ DirectoryCommitContribution::Build(dir(), BOOKMARKS, 25, &emitter));
+
+ sync_pb::ClientToServerMessage message;
+ bm_cc->AddToCommitMessage(&message);
+ const sync_pb::CommitMessage& commit_message = message.commit();
+ bm_cc->CleanUp();
+
+ ASSERT_EQ(1, commit_message.entries_size());
+ EXPECT_TRUE(commit_message.entries(0).has_parent_id_string());
+ EXPECT_FALSE(commit_message.entries(0).parent_id_string().empty());
+}
+
+// Test that preferences do not support hierarchy.
+TEST_F(DirectoryCommitContributionTest, HierarchySupport_Preferences) {
+ // Create a normal-looking prefs item.
+ int64 pref1;
+ {
+ syncable::WriteTransaction trans(FROM_HERE, syncable::UNITTEST, dir());
+ pref1 = CreateUnsyncedItem(&trans, PREFERENCES, "pref1");
+ syncable::MutableEntry e(&trans, syncable::GET_BY_HANDLE, pref1);
+
+ EXPECT_FALSE(e.ShouldMaintainHierarchy());
+ }
+
+ DirectoryTypeDebugInfoEmitter emitter(PREFERENCES, &type_observers_);
+ scoped_ptr<DirectoryCommitContribution> pref_cc(
+ DirectoryCommitContribution::Build(dir(), PREFERENCES, 25, &emitter));
+
+ sync_pb::ClientToServerMessage message;
+ pref_cc->AddToCommitMessage(&message);
+ const sync_pb::CommitMessage& commit_message = message.commit();
+ pref_cc->CleanUp();
+
+ ASSERT_EQ(1, commit_message.entries_size());
+ EXPECT_FALSE(commit_message.entries(0).has_parent_id_string());
+ EXPECT_TRUE(commit_message.entries(0).parent_id_string().empty());
+}
+
// Creates some unsynced items, pretends to commit them, and hands back a
// specially crafted response to the syncer in order to test commit response
// processing. The response simulates a succesful commit scenario.