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

Unified Diff: extensions/browser/api/cast_channel/cast_message_util.cc

Issue 555283002: Create new class "CastTransport", which encapsulates the message read and write event loops. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Code review feedback addressed. Created 6 years, 3 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: extensions/browser/api/cast_channel/cast_message_util.cc
diff --git a/extensions/browser/api/cast_channel/cast_message_util.cc b/extensions/browser/api/cast_channel/cast_message_util.cc
index edb3e11a46c78e364993ac3ad5cd88013a8419cb..0bb1fb75b5fc5050b00912200d575456cca19fad 100644
--- a/extensions/browser/api/cast_channel/cast_message_util.cc
+++ b/extensions/browser/api/cast_channel/cast_message_util.cc
@@ -62,6 +62,17 @@ bool MessageInfoToCastMessage(const MessageInfo& message,
return message_proto->IsInitialized();
}
+bool IsCastMessageValid(const CastMessage& message_proto) {
+ if (message_proto.namespace_().empty() || message_proto.source_id().empty() ||
+ message_proto.destination_id().empty()) {
+ return false;
+ }
+ return (message_proto.payload_type() == CastMessage_PayloadType_STRING &&
+ message_proto.has_payload_utf8()) ||
+ (message_proto.payload_type() == CastMessage_PayloadType_BINARY &&
+ message_proto.has_payload_binary());
+}
+
bool CastMessageToMessageInfo(const CastMessage& message_proto,
MessageInfo* message) {
DCHECK(message);

Powered by Google App Engine
This is Rietveld 408576698