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

Unified Diff: remoting/protocol/connection_to_host.h

Issue 1238343002: Added ConnectionTimeObserver to calculate the times to authenticate and connect. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made ToString methods into functions. Made code more readable and removed multiple defines in chromoting_instance.cc Created 5 years, 5 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
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

Powered by Google App Engine
This is Rietveld 408576698