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..a5b08bc544aacf4f9d8df7f68c73ff39753ba508 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; |
joedow
2015/07/29 17:07:02
I'm personally not a fan of macros like this for a
tonychun
2015/07/29 18:30:33
Done.
|
+ |
namespace remoting { |
class SignalStrategy; |
@@ -64,6 +69,20 @@ class ConnectionToHost { |
const protocol::TransportRoute& route) = 0; |
}; |
+ static const char* ConnectionStateToFriendlyString(State state) { |
+ switch (state) { |
+ RETURN_STRING_LITERAL(INITIALIZING); |
+ RETURN_STRING_LITERAL(CONNECTING); |
+ RETURN_STRING_LITERAL(AUTHENTICATED); |
+ RETURN_STRING_LITERAL(CONNECTED); |
+ RETURN_STRING_LITERAL(CLOSED); |
+ RETURN_STRING_LITERAL(FAILED); |
+ default: |
+ LOG(ERROR) << "Unknown connection state: '" << state << "'"; |
+ return "UNKNOWN"; |
+ } |
+ } |
+ |
virtual ~ConnectionToHost() {} |
// Allows to set a custom protocol configuration (e.g. for tests). Cannot be |