Index: remoting/protocol/connection_to_host.h |
diff --git a/remoting/protocol/connection_to_host.h b/remoting/protocol/connection_to_host.h |
index a20bd22605986474c53152c975dc089c8bd99b20..b7b2dd40937157bd65e6132d039fed4f3a8b29cc 100644 |
--- a/remoting/protocol/connection_to_host.h |
+++ b/remoting/protocol/connection_to_host.h |
@@ -8,10 +8,15 @@ |
#include <string> |
#include "base/callback_forward.h" |
+#include "base/logging.h" |
#include "base/memory/ref_counted.h" |
#include "base/memory/scoped_ptr.h" |
#include "remoting/protocol/errors.h" |
+#define RETURN_STRING_LITERAL(x) \ |
+case x: \ |
+return #x; |
+ |
namespace remoting { |
class SignalStrategy; |
@@ -106,6 +111,20 @@ class ConnectionToHost { |
virtual State state() const = 0; |
}; |
+inline const char* ConnectionStateToString(ConnectionToHost::State state) { |
joedow
2015/07/29 20:09:31
I'd remove the inline here. This function is call
|
+ switch (state) { |
+ RETURN_STRING_LITERAL(ConnectionToHost::INITIALIZING); |
+ RETURN_STRING_LITERAL(ConnectionToHost::CONNECTING); |
+ RETURN_STRING_LITERAL(ConnectionToHost::AUTHENTICATED); |
+ RETURN_STRING_LITERAL(ConnectionToHost::CONNECTED); |
+ RETURN_STRING_LITERAL(ConnectionToHost::CLOSED); |
+ RETURN_STRING_LITERAL(ConnectionToHost::FAILED); |
+ default: |
+ LOG(ERROR) << "Unknown connection state: '" << state << "'"; |
+ return "ConnectionToHost::UNKNOWN"; |
+ } |
+} |
+ |
} // namespace protocol |
} // namespace remoting |