diff options
Diffstat (limited to 'sync/engine')
-rw-r--r-- | sync/engine/build_commit_command.cc | 9 | ||||
-rw-r--r-- | sync/engine/process_commit_response_command.cc | 14 | ||||
-rw-r--r-- | sync/engine/process_updates_command.cc | 8 | ||||
-rw-r--r-- | sync/engine/syncer.cc | 11 | ||||
-rw-r--r-- | sync/engine/syncer_unittest.cc | 15 | ||||
-rw-r--r-- | sync/engine/syncer_util.cc | 10 |
6 files changed, 50 insertions, 17 deletions
diff --git a/sync/engine/build_commit_command.cc b/sync/engine/build_commit_command.cc index 8e51ddb..bfa5b9c 100644 --- a/sync/engine/build_commit_command.cc +++ b/sync/engine/build_commit_command.cc @@ -22,6 +22,11 @@ #include "sync/syncable/write_transaction.h" #include "sync/util/time.h" +// TODO(vishwath): Remove this include after node positions have +// shifted to completely using Ordinals. +// See http://crbug.com/145412 . +#include "sync/internal_api/public/base/node_ordinal.h" + using std::set; using std::string; using std::vector; @@ -31,7 +36,7 @@ namespace syncer { using sessions::SyncSession; using syncable::Entry; using syncable::IS_DEL; -using syncable::SERVER_POSITION_IN_PARENT; +using syncable::SERVER_ORDINAL_IN_PARENT; using syncable::IS_UNAPPLIED_UPDATE; using syncable::IS_UNSYNCED; using syncable::Id; @@ -231,7 +236,7 @@ int64 BuildCommitCommand::FindAnchorPosition(syncable::IdField direction, syncable::GET_BY_ID, next_id); if (!next_entry.Get(IS_UNSYNCED) && !next_entry.Get(IS_UNAPPLIED_UPDATE)) { - return next_entry.Get(SERVER_POSITION_IN_PARENT); + return NodeOrdinalToInt64(next_entry.Get(SERVER_ORDINAL_IN_PARENT)); } next_id = next_entry.Get(direction); } diff --git a/sync/engine/process_commit_response_command.cc b/sync/engine/process_commit_response_command.cc index 2f84619..200a710 100644 --- a/sync/engine/process_commit_response_command.cc +++ b/sync/engine/process_commit_response_command.cc @@ -22,6 +22,11 @@ #include "sync/syncable/write_transaction.h" #include "sync/util/time.h" +// TODO(vishwath): Remove this include after node positions have +// shifted to completely using Ordinals. +// See http://crbug.com/145412 . +#include "sync/internal_api/public/base/node_ordinal.h" + using std::set; using std::string; using std::vector; @@ -45,7 +50,7 @@ using syncable::IS_UNSYNCED; using syncable::PARENT_ID; using syncable::SERVER_IS_DEL; using syncable::SERVER_PARENT_ID; -using syncable::SERVER_POSITION_IN_PARENT; +using syncable::SERVER_ORDINAL_IN_PARENT; using syncable::SERVER_VERSION; using syncable::SYNCER; using syncable::SYNCING; @@ -368,8 +373,9 @@ void ProcessCommitResponseCommand::UpdateServerFieldsAfterCommit( ProtoTimeToTime(committed_entry.mtime())); local_entry->Put(syncable::SERVER_CTIME, ProtoTimeToTime(committed_entry.ctime())); - local_entry->Put(syncable::SERVER_POSITION_IN_PARENT, - entry_response.position_in_parent()); + local_entry->Put(syncable::SERVER_ORDINAL_IN_PARENT, + Int64ToNodeOrdinal(entry_response.position_in_parent())); + // TODO(nick): The server doesn't set entry_response.server_parent_id in // practice; to update SERVER_PARENT_ID appropriately here we'd need to // get the post-commit ID of the parent indicated by @@ -417,7 +423,7 @@ void ProcessCommitResponseCommand::OverrideClientFieldsAfterCommit( if (entry_response.has_position_in_parent()) { // The SERVER_ field should already have been written. DCHECK_EQ(entry_response.position_in_parent(), - local_entry->Get(SERVER_POSITION_IN_PARENT)); + NodeOrdinalToInt64(local_entry->Get(SERVER_ORDINAL_IN_PARENT))); // We just committed successfully, so we assume that the position // value we got applies to the PARENT_ID we submitted. diff --git a/sync/engine/process_updates_command.cc b/sync/engine/process_updates_command.cc index de6be0f..0bf03f1 100644 --- a/sync/engine/process_updates_command.cc +++ b/sync/engine/process_updates_command.cc @@ -19,6 +19,11 @@ #include "sync/syncable/write_transaction.h" #include "sync/util/cryptographer.h" +// TODO(vishwath): Remove this include after node positions have +// shifted to completely using Ordinals. +// See http://crbug.com/145412 . +#include "sync/internal_api/public/base/node_ordinal.h" + using std::vector; namespace syncer { @@ -152,7 +157,8 @@ ServerUpdateProcessingResult ProcessUpdatesCommand::ProcessUpdate( (SyncableIdFromProto(update.parent_id_string()) == target_entry.Get(syncable::SERVER_PARENT_ID)) && (update.position_in_parent() == - target_entry.Get(syncable::SERVER_POSITION_IN_PARENT)) && + NodeOrdinalToInt64( + target_entry.Get(syncable::SERVER_ORDINAL_IN_PARENT))) && update.has_specifics() && update.specifics().has_encrypted() && !cryptographer->CanDecrypt(update.specifics().encrypted())) { sync_pb::EntitySpecifics prev_specifics = diff --git a/sync/engine/syncer.cc b/sync/engine/syncer.cc index af8e3a9..8e178cb 100644 --- a/sync/engine/syncer.cc +++ b/sync/engine/syncer.cc @@ -27,6 +27,11 @@ #include "sync/syncable/mutable_entry.h" #include "sync/syncable/syncable-inl.h" +// TODO(vishwath): Remove this include after node positions have +// shifted to completely using Ordinals. +// See http://crbug.com/145412 . +#include "sync/internal_api/public/base/node_ordinal.h" + using base::Time; using base::TimeDelta; using sync_pb::ClientCommand; @@ -43,7 +48,7 @@ using syncable::SERVER_IS_DIR; using syncable::SERVER_MTIME; using syncable::SERVER_NON_UNIQUE_NAME; using syncable::SERVER_PARENT_ID; -using syncable::SERVER_POSITION_IN_PARENT; +using syncable::SERVER_ORDINAL_IN_PARENT; using syncable::SERVER_SPECIFICS; using syncable::SERVER_VERSION; @@ -241,7 +246,7 @@ void CopyServerFields(syncable::Entry* src, syncable::MutableEntry* dest) { dest->Put(SERVER_IS_DEL, src->Get(SERVER_IS_DEL)); dest->Put(IS_UNAPPLIED_UPDATE, src->Get(IS_UNAPPLIED_UPDATE)); dest->Put(SERVER_SPECIFICS, src->Get(SERVER_SPECIFICS)); - dest->Put(SERVER_POSITION_IN_PARENT, src->Get(SERVER_POSITION_IN_PARENT)); + dest->Put(SERVER_ORDINAL_IN_PARENT, src->Get(SERVER_ORDINAL_IN_PARENT)); } void ClearServerData(syncable::MutableEntry* entry) { @@ -254,7 +259,7 @@ void ClearServerData(syncable::MutableEntry* entry) { entry->Put(SERVER_IS_DEL, false); entry->Put(IS_UNAPPLIED_UPDATE, false); entry->Put(SERVER_SPECIFICS, sync_pb::EntitySpecifics::default_instance()); - entry->Put(SERVER_POSITION_IN_PARENT, 0); + entry->Put(SERVER_ORDINAL_IN_PARENT, Int64ToNodeOrdinal(0)); } } // namespace syncer diff --git a/sync/engine/syncer_unittest.cc b/sync/engine/syncer_unittest.cc index c57def1..2519a6a 100644 --- a/sync/engine/syncer_unittest.cc +++ b/sync/engine/syncer_unittest.cc @@ -33,6 +33,7 @@ #include "sync/engine/traffic_recorder.h" #include "sync/internal_api/public/base/model_type.h" #include "sync/internal_api/public/engine/model_safe_worker.h" +#include "sync/internal_api/public/base/node_ordinal.h" #include "sync/protocol/bookmark_specifics.pb.h" #include "sync/protocol/nigori_specifics.pb.h" #include "sync/protocol/preference_specifics.pb.h" @@ -96,7 +97,7 @@ using syncable::PREV_ID; using syncable::BASE_SERVER_SPECIFICS; using syncable::SERVER_IS_DEL; using syncable::SERVER_PARENT_ID; -using syncable::SERVER_POSITION_IN_PARENT; +using syncable::SERVER_ORDINAL_IN_PARENT; using syncable::SERVER_SPECIFICS; using syncable::SERVER_VERSION; using syncable::UNIQUE_CLIENT_TAG; @@ -2224,7 +2225,7 @@ TEST_F(SyncerTest, CommitsUpdateDoesntAlterEntry) { SyncShareNudge(); syncable::Id id; int64 version; - int64 server_position_in_parent; + NodeOrdinal server_ordinal_in_parent; { syncable::ReadTransaction trans(FROM_HERE, directory()); Entry entry(&trans, syncable::GET_BY_HANDLE, entry_metahandle); @@ -2232,14 +2233,16 @@ TEST_F(SyncerTest, CommitsUpdateDoesntAlterEntry) { id = entry.Get(ID); EXPECT_TRUE(id.ServerKnows()); version = entry.Get(BASE_VERSION); - server_position_in_parent = entry.Get(SERVER_POSITION_IN_PARENT); + server_ordinal_in_parent = entry.Get(SERVER_ORDINAL_IN_PARENT); } sync_pb::SyncEntity* update = mock_server_->AddUpdateFromLastCommit(); EXPECT_EQ("Pete", update->name()); EXPECT_EQ(id.GetServerId(), update->id_string()); EXPECT_EQ(root_id_.GetServerId(), update->parent_id_string()); EXPECT_EQ(version, update->version()); - EXPECT_EQ(server_position_in_parent, update->position_in_parent()); + EXPECT_EQ( + NodeOrdinalToInt64(server_ordinal_in_parent), + update->position_in_parent()); SyncShareNudge(); { syncable::ReadTransaction trans(FROM_HERE, directory()); @@ -4490,7 +4493,9 @@ class SyncerPositionUpdateTest : public SyncerTest { Entry entry_with_id(&trans, GET_BY_ID, id); EXPECT_TRUE(entry_with_id.good()); EXPECT_EQ(prev_id, entry_with_id.Get(PREV_ID)); - EXPECT_EQ(i->first, entry_with_id.Get(SERVER_POSITION_IN_PARENT)); + EXPECT_EQ( + i->first, + NodeOrdinalToInt64(entry_with_id.Get(SERVER_ORDINAL_IN_PARENT))); if (next == position_map_.end()) { EXPECT_EQ(Id(), entry_with_id.Get(NEXT_ID)); } else { diff --git a/sync/engine/syncer_util.cc b/sync/engine/syncer_util.cc index 0dad3f8..cdc1b7a 100644 --- a/sync/engine/syncer_util.cc +++ b/sync/engine/syncer_util.cc @@ -29,6 +29,11 @@ #include "sync/util/cryptographer.h" #include "sync/util/time.h" +// TODO(vishwath): Remove this include after node positions have +// shifted to completely uing Ordinals. +// See http://crbug.com/145412 . +#include "sync/internal_api/public/base/node_ordinal.h" + namespace syncer { using syncable::BASE_VERSION; @@ -58,7 +63,7 @@ using syncable::SERVER_IS_DIR; using syncable::SERVER_MTIME; using syncable::SERVER_NON_UNIQUE_NAME; using syncable::SERVER_PARENT_ID; -using syncable::SERVER_POSITION_IN_PARENT; +using syncable::SERVER_ORDINAL_IN_PARENT; using syncable::SERVER_SPECIFICS; using syncable::SERVER_VERSION; using syncable::UNIQUE_CLIENT_TAG; @@ -351,7 +356,8 @@ void UpdateServerFieldsFromUpdate( target); } if (update.has_position_in_parent()) - target->Put(SERVER_POSITION_IN_PARENT, update.position_in_parent()); + target->Put(SERVER_ORDINAL_IN_PARENT, + Int64ToNodeOrdinal(update.position_in_parent())); target->Put(SERVER_IS_DEL, update.deleted()); // We only mark the entry as unapplied if its version is greater than the |