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

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: fix windows compile errors 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
« no previous file with comments | « components/cast_channel/cast_channel_enum.h ('k') | extensions/browser/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9e426adc148127d7ec7bafd184bd4bdf767878f1
--- /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);
+ }
+ NOTREACHED() << "Unknown ready_state " << ReadyStateToString(ready_state);
+ return "Unknown ready_state";
+}
+
+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::CAST_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);
+ }
+ NOTREACHED() << "Unknown channel_error "
+ << ChannelErrorToString(channel_error);
+ return "Unknown channel_error";
+}
+
+std::string ChannelAuthTypeToString(ChannelAuthType channel_auth) {
+ switch (channel_auth) {
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelAuthType::NONE);
+ CAST_CHANNEL_TYPE_TO_STRING(ChannelAuthType::SSL_VERIFIED);
+ }
+ NOTREACHED() << "Unknown channel_auth "
+ << ChannelAuthTypeToString(channel_auth);
+ return "Unknown channel_auth";
+}
+
+} // namespace cast_channel
« no previous file with comments | « components/cast_channel/cast_channel_enum.h ('k') | extensions/browser/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698