Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "sync/engine/syncer_proto_util.h" | 5 #include "sync/engine/syncer_proto_util.h" |
| 6 | 6 |
| 7 #include "base/format_macros.h" | 7 #include "base/format_macros.h" |
| 8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
| 9 #include "google_apis/google_api_keys.h" | 9 #include "google_apis/google_api_keys.h" |
| 10 #include "sync/engine/net/server_connection_manager.h" | 10 #include "sync/engine/net/server_connection_manager.h" |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 } // namespace | 110 } // namespace |
| 111 | 111 |
| 112 // static | 112 // static |
| 113 void SyncerProtoUtil::HandleMigrationDoneResponse( | 113 void SyncerProtoUtil::HandleMigrationDoneResponse( |
| 114 const ClientToServerResponse* response, | 114 const ClientToServerResponse* response, |
| 115 sessions::SyncSession* session) { | 115 sessions::SyncSession* session) { |
| 116 LOG_IF(ERROR, 0 >= response->migrated_data_type_id_size()) | 116 LOG_IF(ERROR, 0 >= response->migrated_data_type_id_size()) |
| 117 << "MIGRATION_DONE but no types specified."; | 117 << "MIGRATION_DONE but no types specified."; |
| 118 ModelTypeSet to_migrate; | 118 ModelTypeSet to_migrate; |
| 119 for (int i = 0; i < response->migrated_data_type_id_size(); i++) { | 119 for (int i = 0; i < response->migrated_data_type_id_size(); i++) { |
| 120 to_migrate.Put(GetModelTypeFromSpecificsFieldNumber( | 120 int field_number = response->migrated_data_type_id(i); |
| 121 response->migrated_data_type_id(i))); | 121 ModelType model_type = GetModelTypeFromSpecificsFieldNumber(field_number); |
| 122 if (!IsRealDataType(model_type)) { | |
| 123 NOTREACHED() << "Unknown field number " << field_number; | |
| 124 continue; | |
| 125 } | |
| 126 to_migrate.Put(model_type); | |
| 122 } | 127 } |
| 123 // TODO(akalin): This should be a set union. | 128 // TODO(akalin): This should be a set union. |
| 124 session->mutable_status_controller()-> | 129 session->mutable_status_controller()-> |
| 125 set_types_needing_local_migration(to_migrate); | 130 set_types_needing_local_migration(to_migrate); |
| 126 } | 131 } |
| 127 | 132 |
| 128 // static | 133 // static |
| 129 bool SyncerProtoUtil::VerifyResponseBirthday(syncable::Directory* dir, | 134 bool SyncerProtoUtil::VerifyResponseBirthday(syncable::Directory* dir, |
| 130 const ClientToServerResponse* response) { | 135 const ClientToServerResponse* response) { |
| 131 | 136 |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 315 error.error_type()); | 320 error.error_type()); |
| 316 sync_protocol_error.error_description = error.error_description(); | 321 sync_protocol_error.error_description = error.error_description(); |
| 317 sync_protocol_error.url = error.url(); | 322 sync_protocol_error.url = error.url(); |
| 318 sync_protocol_error.action = ConvertClientActionPBToLocalClientAction( | 323 sync_protocol_error.action = ConvertClientActionPBToLocalClientAction( |
| 319 error.action()); | 324 error.action()); |
| 320 | 325 |
| 321 if (error.error_data_type_ids_size() > 0) { | 326 if (error.error_data_type_ids_size() > 0) { |
| 322 // THROTTLED is currently the only error code that uses |error_data_types|. | 327 // THROTTLED is currently the only error code that uses |error_data_types|. |
| 323 DCHECK_EQ(error.error_type(), sync_pb::SyncEnums::THROTTLED); | 328 DCHECK_EQ(error.error_type(), sync_pb::SyncEnums::THROTTLED); |
| 324 for (int i = 0; i < error.error_data_type_ids_size(); ++i) { | 329 for (int i = 0; i < error.error_data_type_ids_size(); ++i) { |
| 325 sync_protocol_error.error_data_types.Put( | 330 int field_number = error.error_data_type_ids(i); |
| 326 GetModelTypeFromSpecificsFieldNumber( | 331 ModelType model_type = |
| 327 error.error_data_type_ids(i))); | 332 GetModelTypeFromSpecificsFieldNumber(field_number); |
| 333 if (!IsRealDataType(model_type)) { | |
| 334 NOTREACHED() << "Unknown field number " << field_number; | |
|
tim (not reviewing)
2012/12/10 23:49:37
Is there any way to add a test for this?
akalin
2012/12/11 00:15:50
Yeah. Are you okay with doing it in another CL?
| |
| 335 continue; | |
| 336 } | |
| 337 sync_protocol_error.error_data_types.Put(model_type); | |
| 328 } | 338 } |
| 329 } | 339 } |
| 330 | 340 |
| 331 return sync_protocol_error; | 341 return sync_protocol_error; |
| 332 } | 342 } |
| 333 | 343 |
| 334 // TODO(lipalani) : Rename these function names as per the CR for issue 7740067. | 344 // TODO(lipalani) : Rename these function names as per the CR for issue 7740067. |
| 335 SyncProtocolError ConvertLegacyErrorCodeToNewError( | 345 SyncProtocolError ConvertLegacyErrorCodeToNewError( |
| 336 const sync_pb::SyncEnums::ErrorType& error_type) { | 346 const sync_pb::SyncEnums::ErrorType& error_type) { |
| 337 SyncProtocolError error; | 347 SyncProtocolError error; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 598 std::string SyncerProtoUtil::ClientToServerResponseDebugString( | 608 std::string SyncerProtoUtil::ClientToServerResponseDebugString( |
| 599 const ClientToServerResponse& response) { | 609 const ClientToServerResponse& response) { |
| 600 // Add more handlers as needed. | 610 // Add more handlers as needed. |
| 601 std::string output; | 611 std::string output; |
| 602 if (response.has_get_updates()) | 612 if (response.has_get_updates()) |
| 603 output.append(GetUpdatesResponseString(response.get_updates())); | 613 output.append(GetUpdatesResponseString(response.get_updates())); |
| 604 return output; | 614 return output; |
| 605 } | 615 } |
| 606 | 616 |
| 607 } // namespace syncer | 617 } // namespace syncer |
| OLD | NEW |