Chromium Code Reviews| 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 #ifndef REMOTING_PROTOCOL_ERROR_H_ | 5 #ifndef REMOTING_PROTOCOL_ERROR_H_ |
| 6 #define REMOTING_PROTOCOL_ERROR_H_ | 6 #define REMOTING_PROTOCOL_ERROR_H_ |
| 7 | 7 |
| 8 #include "base/logging.h" | |
| 9 | |
| 10 #define RETURN_STRING_LITERAL(x) \ | |
| 11 case x: \ | |
| 12 return #x; | |
| 13 | |
| 8 namespace remoting { | 14 namespace remoting { |
| 9 namespace protocol { | 15 namespace protocol { |
| 10 | 16 |
| 11 // The UI implementations maintain corresponding definitions of this | 17 // The UI implementations maintain corresponding definitions of this |
| 12 // enumeration in webapp/error.js and | 18 // enumeration in webapp/error.js and |
| 13 // android/java/src/org/chromium/chromoting/jni/JniInterface.java. | 19 // android/java/src/org/chromium/chromoting/jni/JniInterface.java. |
| 14 // Be sure to update these locations if you make any changes to the ordering. | 20 // Be sure to update these locations if you make any changes to the ordering. |
| 15 enum ErrorCode { | 21 enum ErrorCode { |
| 16 OK = 0, | 22 OK = 0, |
| 17 PEER_IS_OFFLINE, | 23 PEER_IS_OFFLINE, |
| 18 SESSION_REJECTED, | 24 SESSION_REJECTED, |
| 19 INCOMPATIBLE_PROTOCOL, | 25 INCOMPATIBLE_PROTOCOL, |
| 20 AUTHENTICATION_FAILED, | 26 AUTHENTICATION_FAILED, |
| 21 CHANNEL_CONNECTION_ERROR, | 27 CHANNEL_CONNECTION_ERROR, |
| 22 SIGNALING_ERROR, | 28 SIGNALING_ERROR, |
| 23 SIGNALING_TIMEOUT, | 29 SIGNALING_TIMEOUT, |
| 24 HOST_OVERLOAD, | 30 HOST_OVERLOAD, |
| 25 UNKNOWN_ERROR, | 31 UNKNOWN_ERROR, |
| 26 }; | 32 }; |
| 27 | 33 |
| 34 inline const char* ErrorCodeToString(ErrorCode error) { | |
|
joedow
2015/07/29 20:09:31
remove inline
| |
| 35 switch (error) { | |
| 36 RETURN_STRING_LITERAL(OK); | |
| 37 RETURN_STRING_LITERAL(PEER_IS_OFFLINE); | |
| 38 RETURN_STRING_LITERAL(SESSION_REJECTED); | |
| 39 RETURN_STRING_LITERAL(INCOMPATIBLE_PROTOCOL); | |
| 40 RETURN_STRING_LITERAL(AUTHENTICATION_FAILED); | |
| 41 RETURN_STRING_LITERAL(CHANNEL_CONNECTION_ERROR); | |
| 42 RETURN_STRING_LITERAL(SIGNALING_ERROR); | |
| 43 RETURN_STRING_LITERAL(SIGNALING_TIMEOUT); | |
| 44 RETURN_STRING_LITERAL(HOST_OVERLOAD); | |
| 45 RETURN_STRING_LITERAL(UNKNOWN_ERROR); | |
| 46 default: | |
| 47 LOG(ERROR) << "Unknown error: '" << error << "'"; | |
| 48 return "UNKNOWN ERROR"; | |
| 49 } | |
| 50 } | |
| 51 | |
| 28 } // namespace protocol | 52 } // namespace protocol |
| 29 } // namespace remoting | 53 } // namespace remoting |
| 30 | 54 |
| 31 #endif // REMOTING_PROTOCOL_ERROR_H_ | 55 #endif // REMOTING_PROTOCOL_ERROR_H_ |
| OLD | NEW |