OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/browser/sync/engine/syncer_util.h" | 5 #include "chrome/browser/sync/engine/syncer_util.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
808 // Ignore unapplied updates -- they might not even be server-siblings. | 808 // Ignore unapplied updates -- they might not even be server-siblings. |
809 if (candidate.Get(IS_UNAPPLIED_UPDATE)) { | 809 if (candidate.Get(IS_UNAPPLIED_UPDATE)) { |
810 continue; | 810 continue; |
811 } | 811 } |
812 | 812 |
813 // Unsynced items don't have a valid server position. | 813 // Unsynced items don't have a valid server position. |
814 if (!candidate.Get(IS_UNSYNCED)) { | 814 if (!candidate.Get(IS_UNSYNCED)) { |
815 // If |candidate| is after |update_entry| according to the server | 815 // If |candidate| is after |update_entry| according to the server |
816 // ordering, then we're done. ID is the tiebreaker. | 816 // ordering, then we're done. ID is the tiebreaker. |
817 if ((candidate.Get(SERVER_POSITION_IN_PARENT) > position_in_parent) || | 817 if ((candidate.Get(SERVER_POSITION_IN_PARENT) > position_in_parent) || |
818 (candidate.Get(SERVER_POSITION_IN_PARENT) == position_in_parent) && | 818 ((candidate.Get(SERVER_POSITION_IN_PARENT) == position_in_parent) && |
819 (candidate.Get(ID) > update_item->Get(ID))) { | 819 (candidate.Get(ID) > update_item->Get(ID)))) { |
820 return closest_sibling; | 820 return closest_sibling; |
821 } | 821 } |
822 } | 822 } |
823 | 823 |
824 // We can't trust the SERVER_ fields of unsynced items, but they are | 824 // We can't trust the SERVER_ fields of unsynced items, but they are |
825 // potentially legitimate local predecessors. In the case where | 825 // potentially legitimate local predecessors. In the case where |
826 // |update_item| and an unsynced item wind up in the same insertion | 826 // |update_item| and an unsynced item wind up in the same insertion |
827 // position, we need to choose how to order them. The following check puts | 827 // position, we need to choose how to order them. The following check puts |
828 // the unapplied update first; removing it would put the unsynced item(s) | 828 // the unapplied update first; removing it would put the unsynced item(s) |
829 // first. | 829 // first. |
830 if (candidate.Get(IS_UNSYNCED)) { | 830 if (candidate.Get(IS_UNSYNCED)) { |
831 continue; | 831 continue; |
832 } | 832 } |
833 | 833 |
834 // |update_entry| is considered to be somewhere after |candidate|, so store | 834 // |update_entry| is considered to be somewhere after |candidate|, so store |
835 // it as the upper bound. | 835 // it as the upper bound. |
836 closest_sibling = candidate.Get(ID); | 836 closest_sibling = candidate.Get(ID); |
837 } | 837 } |
838 | 838 |
839 return closest_sibling; | 839 return closest_sibling; |
840 } | 840 } |
841 | 841 |
842 } // namespace browser_sync | 842 } // namespace browser_sync |
OLD | NEW |