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 class Error { | |
joedow
2015/07/29 17:07:02
Adding a helper method to ConnectionToHost felt fi
tonychun
2015/07/29 18:30:33
Done.
| |
35 public: | |
36 static const char* ProtocolErrorToFriendlyString(ErrorCode error) { | |
37 switch (error) { | |
38 RETURN_STRING_LITERAL(OK); | |
39 RETURN_STRING_LITERAL(PEER_IS_OFFLINE); | |
40 RETURN_STRING_LITERAL(SESSION_REJECTED); | |
41 RETURN_STRING_LITERAL(INCOMPATIBLE_PROTOCOL); | |
42 RETURN_STRING_LITERAL(AUTHENTICATION_FAILED); | |
43 RETURN_STRING_LITERAL(CHANNEL_CONNECTION_ERROR); | |
44 RETURN_STRING_LITERAL(SIGNALING_ERROR); | |
45 RETURN_STRING_LITERAL(SIGNALING_TIMEOUT); | |
46 RETURN_STRING_LITERAL(HOST_OVERLOAD); | |
47 RETURN_STRING_LITERAL(UNKNOWN_ERROR); | |
48 default: | |
49 LOG(ERROR) << "Unknown error: '" << error << "'"; | |
50 return "UNKNOWN ERROR"; | |
51 } | |
52 } | |
53 }; | |
54 | |
55 | |
28 } // namespace protocol | 56 } // namespace protocol |
29 } // namespace remoting | 57 } // namespace remoting |
30 | 58 |
31 #endif // REMOTING_PROTOCOL_ERROR_H_ | 59 #endif // REMOTING_PROTOCOL_ERROR_H_ |
OLD | NEW |