Chromium Code Reviews| Index: sync/engine/syncer_proto_util.cc |
| diff --git a/sync/engine/syncer_proto_util.cc b/sync/engine/syncer_proto_util.cc |
| index 8a20b95067620ef6ac8a59dacf6e8024898adab4..25695913d414ac1b080557c191c436eab661c570 100644 |
| --- a/sync/engine/syncer_proto_util.cc |
| +++ b/sync/engine/syncer_proto_util.cc |
| @@ -19,10 +19,13 @@ |
| #include "sync/syncable/directory.h" |
| #include "sync/syncable/entry.h" |
| #include "sync/syncable/syncable-inl.h" |
| +#include "sync/syncable/syncable_proto_util.h" |
| #include "sync/util/time.h" |
| using std::string; |
| using std::stringstream; |
| +using sync_pb::ClientToServerMessage; |
| +using sync_pb::ClientToServerResponse; |
| namespace syncer { |
| @@ -107,7 +110,7 @@ SyncerError ServerConnectionErrorAsSyncerError( |
| // static |
| void SyncerProtoUtil::HandleMigrationDoneResponse( |
| - const sync_pb::ClientToServerResponse* response, |
| + const ClientToServerResponse* response, |
| sessions::SyncSession* session) { |
| LOG_IF(ERROR, 0 >= response->migrated_data_type_id_size()) |
| << "MIGRATION_DONE but no types specified."; |
| @@ -165,6 +168,9 @@ bool SyncerProtoUtil::PostAndProcessHeaders(ServerConnectionManager* scm, |
| const ClientToServerMessage& msg, |
| ClientToServerResponse* response) { |
| ServerConnectionManager::PostBufferParams params; |
| + DCHECK(msg.has_protocol_version()); |
| + DCHECK_EQ(msg.protocol_version(), |
| + ClientToServerMessage::default_instance().protocol_version()); |
| msg.SerializeToString(¶ms.buffer_in); |
| ScopedServerStatusWatcher server_status_watcher(scm, ¶ms.response); |
| @@ -199,7 +205,7 @@ bool SyncerProtoUtil::PostAndProcessHeaders(ServerConnectionManager* scm, |
| } |
| base::TimeDelta SyncerProtoUtil::GetThrottleDelay( |
| - const sync_pb::ClientToServerResponse& response) { |
| + const ClientToServerResponse& response) { |
| base::TimeDelta throttle_delay = |
| base::TimeDelta::FromSeconds(kSyncDelayAfterThrottled); |
| if (response.has_client_command()) { |
| @@ -289,7 +295,7 @@ syncer::ClientAction ConvertClientActionPBToLocalClientAction( |
| } |
| syncer::SyncProtocolError ConvertErrorPBToLocalType( |
| - const sync_pb::ClientToServerResponse::Error& error) { |
| + const ClientToServerResponse::Error& error) { |
| syncer::SyncProtocolError sync_protocol_error; |
| sync_protocol_error.error_type = ConvertSyncProtocolErrorTypePBToLocalType( |
| error.error_type()); |
| @@ -415,10 +421,10 @@ SyncerError SyncerProtoUtil::PostClientToServerMessage( |
| // static |
| bool SyncerProtoUtil::Compare(const syncable::Entry& local_entry, |
| - const SyncEntity& server_entry) { |
| + const sync_pb::SyncEntity& server_entry) { |
| const std::string name = NameFromSyncEntity(server_entry); |
| - CHECK(local_entry.Get(ID) == server_entry.id()) << |
| + CHECK(local_entry.Get(ID) == SyncableIdFromProto(server_entry.id_string())) << |
|
akalin
2012/07/11 01:42:22
CHECK_EQ?
rlarocque
2012/07/11 19:22:16
Done.
|
| " SyncerProtoUtil::Compare precondition not met."; |
| CHECK(server_entry.version() == local_entry.Get(BASE_VERSION)) << |
| " SyncerProtoUtil::Compare precondition not met."; |
| @@ -439,11 +445,12 @@ bool SyncerProtoUtil::Compare(const syncable::Entry& local_entry, |
| LOG(WARNING) << "Client name mismatch"; |
| return false; |
| } |
| - if (local_entry.Get(PARENT_ID) != server_entry.parent_id()) { |
| + if (local_entry.Get(PARENT_ID) != |
| + SyncableIdFromProto(server_entry.parent_id_string())) { |
| LOG(WARNING) << "Parent ID mismatch"; |
| return false; |
| } |
| - if (local_entry.Get(IS_DIR) != server_entry.IsFolder()) { |
| + if (local_entry.Get(IS_DIR) != IsFolder(server_entry)) { |
| LOG(WARNING) << "Dir field mismatch"; |
| return false; |
| } |
| @@ -492,7 +499,7 @@ const std::string& SyncerProtoUtil::NameFromSyncEntity( |
| // static |
| const std::string& SyncerProtoUtil::NameFromCommitEntryResponse( |
| - const CommitResponse_EntryResponse& entry) { |
| + const sync_pb::CommitResponse_EntryResponse& entry) { |
| if (entry.has_non_unique_name()) |
| return entry.non_unique_name(); |
| return entry.name(); |
| @@ -534,7 +541,7 @@ std::string GetUpdatesResponseString( |
| } // namespace |
| std::string SyncerProtoUtil::ClientToServerResponseDebugString( |
| - const sync_pb::ClientToServerResponse& response) { |
| + const ClientToServerResponse& response) { |
| // Add more handlers as needed. |
| std::string output; |
| if (response.has_get_updates()) |