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

Unified Diff: components/cast_channel/cast_channel_enum.cc

Issue 2891923004: [cast_channel] Make cast_channel related files not depend on "cast_channel.h" (Closed)
Patch Set: rename cast_channel_type to cast_channel_enum Created 3 years, 7 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: components/cast_channel/cast_channel_enum.cc
diff --git a/components/cast_channel/cast_channel_enum.cc b/components/cast_channel/cast_channel_enum.cc
new file mode 100644
index 0000000000000000000000000000000000000000..baedb199c65c022f6ffdfb5af6b4fc5b611e5104
--- /dev/null
+++ b/components/cast_channel/cast_channel_enum.cc
@@ -0,0 +1,56 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "components/cast_channel/cast_channel_enum.h"
+
+#include "base/logging.h"
+
+namespace cast_channel {
+
+#define CAST_CHANNEL_TYPE_TO_STRING(enum) \
+ case enum: \
+ return #enum
+
+std::string ReadyStateToString(ReadyState ready_state) {
+ switch (ready_state) {
+ CAST_CHANNEL_TYPE_TO_STRING(ReadyState::NONE);
+ CAST_CHANNEL_TYPE_TO_STRING(ReadyState::CONNECTING);
+ CAST_CHANNEL_TYPE_TO_STRING(ReadyState::OPEN);
+ CAST_CHANNEL_TYPE_TO_STRING(ReadyState::CLOSING);
+ CAST_CHANNEL_TYPE_TO_STRING(ReadyState::CLOSED);
+
+ default:
imcheng 2017/05/26 17:43:36 Maybe get rid of the default case? It will help us
zhaobin 2017/05/27 03:08:38 Done.
+ NOTREACHED();
mark a. foltz 2017/05/26 16:56:42 Also << "Unknown ready_state " << ready_state her
zhaobin 2017/05/27 03:08:38 Done.
+ }
+}
+
+std::string ChannelErrorToString(ChannelError channel_error) {
+ switch (channel_error) {
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelError::NONE);
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelError::CHANNEL_NOT_OPEN);
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelError::AUTHENTICATION_ERROR);
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelError::CONNECT_ERROR);
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelError::SOCKET_ERROR);
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelError::TRANSPORT_ERROR);
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelError::INVALID_MESSAGE);
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelError::INVALID_CHANNEL_ID);
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelError::CONNECT_TIMEOUT);
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelError::PING_TIMEOUT);
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelError::UNKNOWN);
+
+ default:
+ NOTREACHED();
+ }
+}
+
+std::string ChannelAuthTypeToString(ChannelAuthType channel_auth) {
+ switch (channel_auth) {
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelAuthType::NONE);
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelAuthType::SSL_VERIFIED);
+ default:
+ NOTREACHED();
+ }
+}
+
+} // namespace cast_channel

Powered by Google App Engine
This is Rietveld 408576698