| 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/internal_api/public/util/sync_string_conversions.h" | 5 #include "sync/internal_api/public/util/sync_string_conversions.h" |
| 6 | 6 |
| 7 #define ENUM_CASE(x) case x: return #x |
| 8 |
| 7 namespace syncer { | 9 namespace syncer { |
| 8 | 10 |
| 9 const char* ConnectionStatusToString(ConnectionStatus status) { | 11 const char* ConnectionStatusToString(ConnectionStatus status) { |
| 10 switch (status) { | 12 switch (status) { |
| 11 case CONNECTION_OK: | 13 ENUM_CASE(CONNECTION_OK); |
| 12 return "CONNECTION_OK"; | 14 ENUM_CASE(CONNECTION_AUTH_ERROR); |
| 13 case CONNECTION_AUTH_ERROR: | 15 ENUM_CASE(CONNECTION_SERVER_ERROR); |
| 14 return "CONNECTION_AUTH_ERROR"; | |
| 15 case CONNECTION_SERVER_ERROR: | |
| 16 return "CONNECTION_SERVER_ERROR"; | |
| 17 default: | 16 default: |
| 18 NOTREACHED(); | 17 NOTREACHED(); |
| 19 return "INVALID_CONNECTION_STATUS"; | 18 return "INVALID_CONNECTION_STATUS"; |
| 20 } | 19 } |
| 21 } | 20 } |
| 22 | 21 |
| 23 // Helper function that converts a PassphraseRequiredReason value to a string. | 22 // Helper function that converts a PassphraseRequiredReason value to a string. |
| 24 const char* PassphraseRequiredReasonToString( | 23 const char* PassphraseRequiredReasonToString( |
| 25 PassphraseRequiredReason reason) { | 24 PassphraseRequiredReason reason) { |
| 26 switch (reason) { | 25 switch (reason) { |
| 27 case REASON_PASSPHRASE_NOT_REQUIRED: | 26 ENUM_CASE(REASON_PASSPHRASE_NOT_REQUIRED); |
| 28 return "REASON_PASSPHRASE_NOT_REQUIRED"; | 27 ENUM_CASE(REASON_ENCRYPTION); |
| 29 case REASON_ENCRYPTION: | 28 ENUM_CASE(REASON_DECRYPTION); |
| 30 return "REASON_ENCRYPTION"; | |
| 31 case REASON_DECRYPTION: | |
| 32 return "REASON_DECRYPTION"; | |
| 33 default: | 29 default: |
| 34 NOTREACHED(); | 30 NOTREACHED(); |
| 35 return "INVALID_REASON"; | 31 return "INVALID_REASON"; |
| 36 } | 32 } |
| 37 } | 33 } |
| 38 | 34 |
| 35 const char* PassphraseStateToString(PassphraseState state) { |
| 36 switch (state) { |
| 37 ENUM_CASE(IMPLICIT_PASSPHRASE); |
| 38 ENUM_CASE(KEYSTORE_PASSPHRASE); |
| 39 ENUM_CASE(FROZEN_IMPLICIT_PASSPHRASE); |
| 40 ENUM_CASE(CUSTOM_PASSPHRASE); |
| 41 default: |
| 42 NOTREACHED(); |
| 43 return "INVALID_PASSPHRASE_STATE"; |
| 44 } |
| 45 } |
| 46 |
| 39 } // namespace syncer | 47 } // namespace syncer |
| OLD | NEW |