Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(359)

Side by Side Diff: sync/internal_api/public/util/sync_string_conversions.cc

Issue 10824410: [Sync] Refactor passphrase state handling (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
OLDNEW
« no previous file with comments | « sync/internal_api/public/util/sync_string_conversions.h ('k') | sync/internal_api/sync_encryption_handler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698