Home | History | Annotate | Download | only in util
      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 
      5 #include "sync/internal_api/public/util/sync_string_conversions.h"
      6 
      7 #define ENUM_CASE(x) case x: return #x
      8 
      9 namespace syncer {
     10 
     11 const char* ConnectionStatusToString(ConnectionStatus status) {
     12   switch (status) {
     13     ENUM_CASE(CONNECTION_OK);
     14     ENUM_CASE(CONNECTION_AUTH_ERROR);
     15     ENUM_CASE(CONNECTION_SERVER_ERROR);
     16     default:
     17       NOTREACHED();
     18       return "INVALID_CONNECTION_STATUS";
     19   }
     20 }
     21 
     22 // Helper function that converts a PassphraseRequiredReason value to a string.
     23 const char* PassphraseRequiredReasonToString(
     24     PassphraseRequiredReason reason) {
     25   switch (reason) {
     26     ENUM_CASE(REASON_PASSPHRASE_NOT_REQUIRED);
     27     ENUM_CASE(REASON_ENCRYPTION);
     28     ENUM_CASE(REASON_DECRYPTION);
     29     default:
     30       NOTREACHED();
     31       return "INVALID_REASON";
     32   }
     33 }
     34 
     35 const char* PassphraseTypeToString(PassphraseType type) {
     36   switch (type) {
     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_TYPE";
     44   }
     45 }
     46 
     47 const char* BootstrapTokenTypeToString(BootstrapTokenType type) {
     48   switch (type) {
     49     ENUM_CASE(PASSPHRASE_BOOTSTRAP_TOKEN);
     50     ENUM_CASE(KEYSTORE_BOOTSTRAP_TOKEN);
     51     default:
     52       NOTREACHED();
     53       return "INVALID_BOOTSTRAP_TOKEN_TYPE";
     54   }
     55 }
     56 
     57 }  // namespace syncer
     58