Chromium Code Reviews| Index: sync/syncable/directory.cc |
| diff --git a/sync/syncable/directory.cc b/sync/syncable/directory.cc |
| index 644a4e20eefc5913b2a29365d807d83484b7d295..d6f1adb25a48dd610d896c01b7548d5f27f68551 100644 |
| --- a/sync/syncable/directory.cc |
| +++ b/sync/syncable/directory.cc |
| @@ -8,6 +8,7 @@ |
| #include "base/perftimer.h" |
| #include "base/stl_util.h" |
| #include "base/string_number_conversions.h" |
| +#include "sync/internal_api/public/base/node_ordinal.h" |
| #include "sync/internal_api/public/util/unrecoverable_error_handler.h" |
| #include "sync/syncable/base_transaction.h" |
| #include "sync/syncable/entry.h" |
| @@ -50,10 +51,10 @@ bool ParentIdAndHandleIndexer::Comparator::operator() ( |
| if (cmp != 0) |
| return cmp < 0; |
| - int64 a_position = a->ref(SERVER_POSITION_IN_PARENT); |
| - int64 b_position = b->ref(SERVER_POSITION_IN_PARENT); |
| - if (a_position != b_position) |
| - return a_position < b_position; |
| + NodeOrdinal a_position = a->ref(SERVER_ORDINAL_IN_PARENT); |
|
akalin
2012/10/05 00:57:59
use const ref
vishwath
2012/10/05 18:34:49
Done.
|
| + NodeOrdinal b_position = b->ref(SERVER_ORDINAL_IN_PARENT); |
|
akalin
2012/10/05 00:57:59
here too
vishwath
2012/10/05 18:34:49
Done.
|
| + if (!a_position.Equals(b_position)) |
| + return a_position.LessThan(b_position); |
| cmp = a->ref(ID).compare(b->ref(ID)); |
| return cmp < 0; |
| @@ -1132,8 +1133,11 @@ Id Directory::ComputePrevIdFromServerPosition( |
| // Find the natural insertion point in the parent_id_child_index, and |
| // work back from there, filtering out ineligible candidates. |
| - ParentIdChildIndex::iterator sibling = LocateInParentChildIndex(lock, |
| - parent_id, entry->ref(SERVER_POSITION_IN_PARENT), entry->ref(ID)); |
| + ParentIdChildIndex::iterator sibling = LocateInParentChildIndex( |
| + lock, |
| + parent_id, |
| + NodeOrdinalToInt64(entry->ref(SERVER_ORDINAL_IN_PARENT)), |
| + entry->ref(ID)); |
| ParentIdChildIndex::iterator first_sibling = |
| GetParentChildIndexLowerBound(lock, parent_id); |
| @@ -1176,7 +1180,8 @@ Directory::ParentIdChildIndex::iterator Directory::LocateInParentChildIndex( |
| int64 position_in_parent, |
| const Id& item_id_for_tiebreaking) { |
| kernel_->needle.put(PARENT_ID, parent_id); |
| - kernel_->needle.put(SERVER_POSITION_IN_PARENT, position_in_parent); |
| + kernel_->needle.put(SERVER_ORDINAL_IN_PARENT, |
| + Int64ToNodeOrdinal(position_in_parent)); |
| kernel_->needle.put(ID, item_id_for_tiebreaking); |
| return kernel_->parent_id_child_index->lower_bound(&kernel_->needle); |
| } |