| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "components/sync/engine_impl/directory_update_handler.h" | 5 #include "components/sync/engine_impl/directory_update_handler.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 729 | 729 |
| 730 // Re-parent from root to "Y" | 730 // Re-parent from root to "Y" |
| 731 entry.PutServerVersion(entry_factory()->GetNextRevision()); | 731 entry.PutServerVersion(entry_factory()->GetNextRevision()); |
| 732 entry.PutIsUnappliedUpdate(true); | 732 entry.PutIsUnappliedUpdate(true); |
| 733 entry.PutServerParentId(TestIdFactory::MakeServer("Y")); | 733 entry.PutServerParentId(TestIdFactory::MakeServer("Y")); |
| 734 } | 734 } |
| 735 | 735 |
| 736 // Item 'Y' is child of 'X'. | 736 // Item 'Y' is child of 'X'. |
| 737 entry_factory()->CreateUnsyncedItem(TestIdFactory::MakeServer("Y"), | 737 entry_factory()->CreateUnsyncedItem(TestIdFactory::MakeServer("Y"), |
| 738 TestIdFactory::MakeServer("X"), "Y", true, | 738 TestIdFactory::MakeServer("X"), "Y", true, |
| 739 BOOKMARKS, NULL); | 739 BOOKMARKS, nullptr); |
| 740 | 740 |
| 741 // If the server's update were applied, we would have X be a child of Y, and Y | 741 // If the server's update were applied, we would have X be a child of Y, and Y |
| 742 // as a child of X. That's a directory loop. The UpdateApplicator should | 742 // as a child of X. That's a directory loop. The UpdateApplicator should |
| 743 // prevent the update from being applied and note that this is a hierarchy | 743 // prevent the update from being applied and note that this is a hierarchy |
| 744 // conflict. | 744 // conflict. |
| 745 | 745 |
| 746 StatusController status; | 746 StatusController status; |
| 747 ApplyBookmarkUpdates(&status); | 747 ApplyBookmarkUpdates(&status); |
| 748 | 748 |
| 749 // This should count as a hierarchy conflict. | 749 // This should count as a hierarchy conflict. |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 // Delete it on the server. | 812 // Delete it on the server. |
| 813 entry.PutServerVersion(entry_factory()->GetNextRevision()); | 813 entry.PutServerVersion(entry_factory()->GetNextRevision()); |
| 814 entry.PutIsUnappliedUpdate(true); | 814 entry.PutIsUnappliedUpdate(true); |
| 815 entry.PutServerParentId(TestIdFactory::root()); | 815 entry.PutServerParentId(TestIdFactory::root()); |
| 816 entry.PutServerIsDel(true); | 816 entry.PutServerIsDel(true); |
| 817 } | 817 } |
| 818 | 818 |
| 819 // Create a local child of the server-deleted directory. | 819 // Create a local child of the server-deleted directory. |
| 820 entry_factory()->CreateUnsyncedItem(TestIdFactory::MakeServer("child"), | 820 entry_factory()->CreateUnsyncedItem(TestIdFactory::MakeServer("child"), |
| 821 TestIdFactory::MakeServer("parent"), | 821 TestIdFactory::MakeServer("parent"), |
| 822 "child", false, BOOKMARKS, NULL); | 822 "child", false, BOOKMARKS, nullptr); |
| 823 | 823 |
| 824 // The server's request to delete the directory must be ignored, otherwise our | 824 // The server's request to delete the directory must be ignored, otherwise our |
| 825 // unsynced new child would be orphaned. This is a hierarchy conflict. | 825 // unsynced new child would be orphaned. This is a hierarchy conflict. |
| 826 | 826 |
| 827 StatusController status; | 827 StatusController status; |
| 828 ApplyBookmarkUpdates(&status); | 828 ApplyBookmarkUpdates(&status); |
| 829 | 829 |
| 830 // This should count as a hierarchy conflict. | 830 // This should count as a hierarchy conflict. |
| 831 const UpdateCounters& counters = GetBookmarksUpdateCounters(); | 831 const UpdateCounters& counters = GetBookmarksUpdateCounters(); |
| 832 EXPECT_EQ(1, counters.num_hierarchy_conflict_application_failures); | 832 EXPECT_EQ(1, counters.num_hierarchy_conflict_application_failures); |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1153 const UpdateCounters& counters = GetArticlesUpdateCounters(); | 1153 const UpdateCounters& counters = GetArticlesUpdateCounters(); |
| 1154 EXPECT_EQ(1, counters.num_updates_applied); | 1154 EXPECT_EQ(1, counters.num_updates_applied); |
| 1155 EXPECT_EQ(1, counters.num_local_overwrites); | 1155 EXPECT_EQ(1, counters.num_local_overwrites); |
| 1156 EXPECT_EQ(0, counters.num_server_overwrites); | 1156 EXPECT_EQ(0, counters.num_server_overwrites); |
| 1157 local_metadata = entry_factory()->GetLocalAttachmentMetadataForItem(handle); | 1157 local_metadata = entry_factory()->GetLocalAttachmentMetadataForItem(handle); |
| 1158 EXPECT_EQ(server_metadata.SerializeAsString(), | 1158 EXPECT_EQ(server_metadata.SerializeAsString(), |
| 1159 local_metadata.SerializeAsString()); | 1159 local_metadata.SerializeAsString()); |
| 1160 } | 1160 } |
| 1161 | 1161 |
| 1162 } // namespace syncer | 1162 } // namespace syncer |
| OLD | NEW |