Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "remoting/protocol/errors.h" | 5 #include "remoting/protocol/errors.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 | 8 |
| 9 namespace remoting { | 9 namespace remoting { |
| 10 namespace protocol { | 10 namespace protocol { |
| 11 | 11 |
| 12 #define MAP_STRING_LITERAL(x) \ | |
|
Sergey Ulanov
2016/06/02 09:26:03
We don't use define like this for NameMapElement d
Hzj_jie
2016/06/02 22:00:18
Done.
| |
| 13 { x, #x } | |
| 14 const NameMapElement<ErrorCode> kErrorCodes[] = { | |
|
Sergey Ulanov
2016/06/02 09:26:03
nit: kErrorCodeNames
Hzj_jie
2016/06/02 22:00:18
Done.
| |
| 15 MAP_STRING_LITERAL(OK), | |
| 16 MAP_STRING_LITERAL(PEER_IS_OFFLINE), | |
| 17 MAP_STRING_LITERAL(SESSION_REJECTED), | |
| 18 MAP_STRING_LITERAL(INCOMPATIBLE_PROTOCOL), | |
| 19 MAP_STRING_LITERAL(AUTHENTICATION_FAILED), | |
| 20 MAP_STRING_LITERAL(INVALID_ACCOUNT), | |
| 21 MAP_STRING_LITERAL(CHANNEL_CONNECTION_ERROR), | |
| 22 MAP_STRING_LITERAL(SIGNALING_ERROR), | |
| 23 MAP_STRING_LITERAL(SIGNALING_TIMEOUT), | |
| 24 MAP_STRING_LITERAL(HOST_OVERLOAD), | |
| 25 MAP_STRING_LITERAL(MAX_SESSION_LENGTH), | |
| 26 MAP_STRING_LITERAL(HOST_CONFIGURATION_ERROR), | |
| 27 MAP_STRING_LITERAL(UNKNOWN_ERROR), | |
| 28 }; | |
| 29 | |
| 12 #define RETURN_STRING_LITERAL(x) \ | 30 #define RETURN_STRING_LITERAL(x) \ |
|
Sergey Ulanov
2016/06/02 09:26:03
This define can be removed.
Hzj_jie
2016/06/02 22:00:18
Done.
| |
| 13 case x: \ | 31 case x: \ |
| 14 return #x; | 32 return #x; |
| 15 | 33 |
| 16 const char* ErrorCodeToString(ErrorCode error) { | 34 const char* ErrorCodeToString(ErrorCode error) { |
| 17 switch (error) { | 35 return ValueToName(kErrorCodes, error); |
| 18 RETURN_STRING_LITERAL(OK); | |
| 19 RETURN_STRING_LITERAL(PEER_IS_OFFLINE); | |
| 20 RETURN_STRING_LITERAL(SESSION_REJECTED); | |
| 21 RETURN_STRING_LITERAL(INCOMPATIBLE_PROTOCOL); | |
| 22 RETURN_STRING_LITERAL(AUTHENTICATION_FAILED); | |
| 23 RETURN_STRING_LITERAL(INVALID_ACCOUNT); | |
| 24 RETURN_STRING_LITERAL(CHANNEL_CONNECTION_ERROR); | |
| 25 RETURN_STRING_LITERAL(SIGNALING_ERROR); | |
| 26 RETURN_STRING_LITERAL(SIGNALING_TIMEOUT); | |
| 27 RETURN_STRING_LITERAL(HOST_OVERLOAD); | |
| 28 RETURN_STRING_LITERAL(MAX_SESSION_LENGTH); | |
| 29 RETURN_STRING_LITERAL(HOST_CONFIGURATION_ERROR); | |
| 30 RETURN_STRING_LITERAL(UNKNOWN_ERROR); | |
| 31 } | |
| 32 NOTREACHED(); | |
| 33 return nullptr; | |
| 34 } | 36 } |
| 35 | 37 |
| 36 } // namespace protocol | 38 } // namespace protocol |
| 37 } // namespace remoting | 39 } // namespace remoting |
| OLD | NEW |