sync_string_conversions.cc 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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
  3. // found in the LICENSE file.
  4. #include "components/sync/engine/sync_string_conversions.h"
  5. #include "base/notreached.h"
  6. #define ENUM_CASE(x) \
  7. case x: \
  8. return #x
  9. namespace syncer {
  10. const char* ConnectionStatusToString(ConnectionStatus status) {
  11. switch (status) {
  12. ENUM_CASE(CONNECTION_NOT_ATTEMPTED);
  13. ENUM_CASE(CONNECTION_OK);
  14. ENUM_CASE(CONNECTION_AUTH_ERROR);
  15. ENUM_CASE(CONNECTION_SERVER_ERROR);
  16. }
  17. NOTREACHED();
  18. return "INVALID_CONNECTION_STATUS";
  19. }
  20. const char* PassphraseTypeToString(PassphraseType type) {
  21. switch (type) {
  22. ENUM_CASE(PassphraseType::kImplicitPassphrase);
  23. ENUM_CASE(PassphraseType::kKeystorePassphrase);
  24. ENUM_CASE(PassphraseType::kFrozenImplicitPassphrase);
  25. ENUM_CASE(PassphraseType::kCustomPassphrase);
  26. ENUM_CASE(PassphraseType::kTrustedVaultPassphrase);
  27. }
  28. NOTREACHED();
  29. return "INVALID_PASSPHRASE_TYPE";
  30. }
  31. const char* KeyDerivationMethodToString(KeyDerivationMethod method) {
  32. switch (method) {
  33. ENUM_CASE(KeyDerivationMethod::PBKDF2_HMAC_SHA1_1003);
  34. ENUM_CASE(KeyDerivationMethod::SCRYPT_8192_8_11);
  35. ENUM_CASE(KeyDerivationMethod::UNSUPPORTED);
  36. }
  37. NOTREACHED();
  38. return "INVALID_KEY_DERIVATION_METHOD";
  39. }
  40. #undef ENUM_CASE
  41. } // namespace syncer