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

Unified Diff: remoting/protocol/errors.cc

Issue 2026123002: [Chromoting] Use google:remoting namespace to export remoting specific error codes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve review comments Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « remoting/protocol/errors.h ('k') | remoting/protocol/jingle_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/errors.cc
diff --git a/remoting/protocol/errors.cc b/remoting/protocol/errors.cc
index 067d919e23df34b5f1d89e44dc1bbbffcefae814..e92da682817632b386ffa3d593bedff7183b27bd 100644
--- a/remoting/protocol/errors.cc
+++ b/remoting/protocol/errors.cc
@@ -5,32 +5,37 @@
#include "remoting/protocol/errors.h"
#include "base/logging.h"
+#include "remoting/protocol/name_value_map.h"
namespace remoting {
namespace protocol {
-#define RETURN_STRING_LITERAL(x) \
-case x: \
-return #x;
+namespace {
+
+const NameMapElement<ErrorCode> kErrorCodeNames[] = {
+ { OK, "OK" },
+ { PEER_IS_OFFLINE, "PEER_IS_OFFLINE" },
+ { SESSION_REJECTED, "SESSION_REJECTED" },
+ { INCOMPATIBLE_PROTOCOL, "INCOMPATIBLE_PROTOCOL" },
+ { AUTHENTICATION_FAILED, "AUTHENTICATION_FAILED" },
+ { INVALID_ACCOUNT, "INVALID_ACCOUNT" },
+ { CHANNEL_CONNECTION_ERROR, "CHANNEL_CONNECTION_ERROR" },
+ { SIGNALING_ERROR, "SIGNALING_ERROR" },
+ { SIGNALING_TIMEOUT, "SIGNALING_TIMEOUT" },
+ { HOST_OVERLOAD, "HOST_OVERLOAD" },
+ { MAX_SESSION_LENGTH, "MAX_SESSION_LENGTH" },
+ { HOST_CONFIGURATION_ERROR, "HOST_CONFIGURATION_ERROR" },
+ { UNKNOWN_ERROR, "UNKNOWN_ERROR" },
+};
+
+} // namespace
const char* ErrorCodeToString(ErrorCode error) {
- switch (error) {
- RETURN_STRING_LITERAL(OK);
- RETURN_STRING_LITERAL(PEER_IS_OFFLINE);
- RETURN_STRING_LITERAL(SESSION_REJECTED);
- RETURN_STRING_LITERAL(INCOMPATIBLE_PROTOCOL);
- RETURN_STRING_LITERAL(AUTHENTICATION_FAILED);
- RETURN_STRING_LITERAL(INVALID_ACCOUNT);
- RETURN_STRING_LITERAL(CHANNEL_CONNECTION_ERROR);
- RETURN_STRING_LITERAL(SIGNALING_ERROR);
- RETURN_STRING_LITERAL(SIGNALING_TIMEOUT);
- RETURN_STRING_LITERAL(HOST_OVERLOAD);
- RETURN_STRING_LITERAL(MAX_SESSION_LENGTH);
- RETURN_STRING_LITERAL(HOST_CONFIGURATION_ERROR);
- RETURN_STRING_LITERAL(UNKNOWN_ERROR);
- }
- NOTREACHED();
- return nullptr;
+ return ValueToName(kErrorCodeNames, error);
+}
+
+bool ParseErrorCode(const std::string& name, ErrorCode* result) {
+ return NameToValue(kErrorCodeNames, name, result);
}
} // namespace protocol
« no previous file with comments | « remoting/protocol/errors.h ('k') | remoting/protocol/jingle_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698