| 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/strings/stringprintf.h" | 8 #include "base/strings/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 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 case sync_pb::SyncEnums::THROTTLED: | 115 case sync_pb::SyncEnums::THROTTLED: |
| 116 return THROTTLED; | 116 return THROTTLED; |
| 117 case sync_pb::SyncEnums::CLEAR_PENDING: | 117 case sync_pb::SyncEnums::CLEAR_PENDING: |
| 118 return CLEAR_PENDING; | 118 return CLEAR_PENDING; |
| 119 case sync_pb::SyncEnums::TRANSIENT_ERROR: | 119 case sync_pb::SyncEnums::TRANSIENT_ERROR: |
| 120 return TRANSIENT_ERROR; | 120 return TRANSIENT_ERROR; |
| 121 case sync_pb::SyncEnums::MIGRATION_DONE: | 121 case sync_pb::SyncEnums::MIGRATION_DONE: |
| 122 return MIGRATION_DONE; | 122 return MIGRATION_DONE; |
| 123 case sync_pb::SyncEnums::DISABLED_BY_ADMIN: | 123 case sync_pb::SyncEnums::DISABLED_BY_ADMIN: |
| 124 return DISABLED_BY_ADMIN; | 124 return DISABLED_BY_ADMIN; |
| 125 case sync_pb::SyncEnums::USER_ROLLBACK: |
| 126 return USER_ROLLBACK; |
| 125 case sync_pb::SyncEnums::UNKNOWN: | 127 case sync_pb::SyncEnums::UNKNOWN: |
| 126 return UNKNOWN_ERROR; | 128 return UNKNOWN_ERROR; |
| 127 case sync_pb::SyncEnums::USER_NOT_ACTIVATED: | 129 case sync_pb::SyncEnums::USER_NOT_ACTIVATED: |
| 128 case sync_pb::SyncEnums::AUTH_INVALID: | 130 case sync_pb::SyncEnums::AUTH_INVALID: |
| 129 case sync_pb::SyncEnums::ACCESS_DENIED: | 131 case sync_pb::SyncEnums::ACCESS_DENIED: |
| 130 return INVALID_CREDENTIAL; | 132 return INVALID_CREDENTIAL; |
| 131 default: | 133 default: |
| 132 NOTREACHED(); | 134 NOTREACHED(); |
| 133 return UNKNOWN_ERROR; | 135 return UNKNOWN_ERROR; |
| 134 } | 136 } |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 // TODO(lipalani) : Rename these function names as per the CR for issue 7740067. | 326 // TODO(lipalani) : Rename these function names as per the CR for issue 7740067. |
| 325 SyncProtocolError ConvertLegacyErrorCodeToNewError( | 327 SyncProtocolError ConvertLegacyErrorCodeToNewError( |
| 326 const sync_pb::SyncEnums::ErrorType& error_type) { | 328 const sync_pb::SyncEnums::ErrorType& error_type) { |
| 327 SyncProtocolError error; | 329 SyncProtocolError error; |
| 328 error.error_type = ConvertSyncProtocolErrorTypePBToLocalType(error_type); | 330 error.error_type = ConvertSyncProtocolErrorTypePBToLocalType(error_type); |
| 329 if (error_type == sync_pb::SyncEnums::CLEAR_PENDING || | 331 if (error_type == sync_pb::SyncEnums::CLEAR_PENDING || |
| 330 error_type == sync_pb::SyncEnums::NOT_MY_BIRTHDAY) { | 332 error_type == sync_pb::SyncEnums::NOT_MY_BIRTHDAY) { |
| 331 error.action = DISABLE_SYNC_ON_CLIENT; | 333 error.action = DISABLE_SYNC_ON_CLIENT; |
| 332 } else if (error_type == sync_pb::SyncEnums::DISABLED_BY_ADMIN) { | 334 } else if (error_type == sync_pb::SyncEnums::DISABLED_BY_ADMIN) { |
| 333 error.action = STOP_SYNC_FOR_DISABLED_ACCOUNT; | 335 error.action = STOP_SYNC_FOR_DISABLED_ACCOUNT; |
| 334 } // There is no other action we can compute for legacy server. | 336 } else if (error_type == sync_pb::SyncEnums::USER_ROLLBACK) { |
| 337 error.action = DISABLE_SYNC_AND_ROLLBACK; |
| 338 } // There is no other action we can compute for legacy server. |
| 335 return error; | 339 return error; |
| 336 } | 340 } |
| 337 | 341 |
| 338 } // namespace | 342 } // namespace |
| 339 | 343 |
| 340 // static | 344 // static |
| 341 SyncerError SyncerProtoUtil::PostClientToServerMessage( | 345 SyncerError SyncerProtoUtil::PostClientToServerMessage( |
| 342 ClientToServerMessage* msg, | 346 ClientToServerMessage* msg, |
| 343 ClientToServerResponse* response, | 347 ClientToServerResponse* response, |
| 344 SyncSession* session) { | 348 SyncSession* session) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 460 << "MIGRATION_DONE but no types specified."; | 464 << "MIGRATION_DONE but no types specified."; |
| 461 session->delegate()->OnReceivedMigrationRequest( | 465 session->delegate()->OnReceivedMigrationRequest( |
| 462 GetTypesToMigrate(*response)); | 466 GetTypesToMigrate(*response)); |
| 463 return SERVER_RETURN_MIGRATION_DONE; | 467 return SERVER_RETURN_MIGRATION_DONE; |
| 464 case CLEAR_PENDING: | 468 case CLEAR_PENDING: |
| 465 return SERVER_RETURN_CLEAR_PENDING; | 469 return SERVER_RETURN_CLEAR_PENDING; |
| 466 case NOT_MY_BIRTHDAY: | 470 case NOT_MY_BIRTHDAY: |
| 467 return SERVER_RETURN_NOT_MY_BIRTHDAY; | 471 return SERVER_RETURN_NOT_MY_BIRTHDAY; |
| 468 case DISABLED_BY_ADMIN: | 472 case DISABLED_BY_ADMIN: |
| 469 return SERVER_RETURN_DISABLED_BY_ADMIN; | 473 return SERVER_RETURN_DISABLED_BY_ADMIN; |
| 474 case USER_ROLLBACK: |
| 475 return SERVER_RETURN_USER_ROLLBACK; |
| 470 default: | 476 default: |
| 471 NOTREACHED(); | 477 NOTREACHED(); |
| 472 return UNSET; | 478 return UNSET; |
| 473 } | 479 } |
| 474 } | 480 } |
| 475 | 481 |
| 476 // static | 482 // static |
| 477 bool SyncerProtoUtil::ShouldMaintainPosition( | 483 bool SyncerProtoUtil::ShouldMaintainPosition( |
| 478 const sync_pb::SyncEntity& sync_entity) { | 484 const sync_pb::SyncEntity& sync_entity) { |
| 479 // Maintain positions for bookmarks that are not server-defined top-level | 485 // Maintain positions for bookmarks that are not server-defined top-level |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 569 std::string SyncerProtoUtil::ClientToServerResponseDebugString( | 575 std::string SyncerProtoUtil::ClientToServerResponseDebugString( |
| 570 const ClientToServerResponse& response) { | 576 const ClientToServerResponse& response) { |
| 571 // Add more handlers as needed. | 577 // Add more handlers as needed. |
| 572 std::string output; | 578 std::string output; |
| 573 if (response.has_get_updates()) | 579 if (response.has_get_updates()) |
| 574 output.append(GetUpdatesResponseString(response.get_updates())); | 580 output.append(GetUpdatesResponseString(response.get_updates())); |
| 575 return output; | 581 return output; |
| 576 } | 582 } |
| 577 | 583 |
| 578 } // namespace syncer | 584 } // namespace syncer |
| OLD | NEW |