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

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

Issue 79673003: Refactor CastSocket code for the following: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 11 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 | « no previous file | chrome/browser/extensions/api/cast_channel/cast_socket.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/cast_channel/cast_message_util.cc
===================================================================
--- chrome/browser/extensions/api/cast_channel/cast_message_util.cc (revision 243975)
+++ chrome/browser/extensions/api/cast_channel/cast_message_util.cc (working copy)
@@ -26,6 +26,9 @@
bool MessageInfoToCastMessage(const MessageInfo& message,
CastMessage* message_proto) {
DCHECK(message_proto);
+ if (!message.data)
+ return false;
+
message_proto->set_protocol_version(CastMessage_ProtocolVersion_CASTV2_1_0);
message_proto->set_source_id(message.source_id);
message_proto->set_destination_id(message.destination_id);
@@ -35,26 +38,26 @@
std::string data;
base::BinaryValue* real_value;
switch (message.data->GetType()) {
- // JS string
- case base::Value::TYPE_STRING:
- if (message.data->GetAsString(&data)) {
- message_proto->set_payload_type(CastMessage_PayloadType_STRING);
- message_proto->set_payload_utf8(data);
- }
- break;
- // JS ArrayBuffer
- case base::Value::TYPE_BINARY:
- real_value = static_cast<base::BinaryValue*>(message.data.get());
- if (real_value->GetBuffer()) {
- message_proto->set_payload_type(CastMessage_PayloadType_BINARY);
- message_proto->set_payload_binary(real_value->GetBuffer(),
- real_value->GetSize());
- }
- break;
- default:
- // Unknown value type. message_proto will remain uninitialized because
- // payload_type is unset.
- break;
+ // JS string
+ case base::Value::TYPE_STRING:
+ if (message.data->GetAsString(&data)) {
+ message_proto->set_payload_type(CastMessage_PayloadType_STRING);
+ message_proto->set_payload_utf8(data);
+ }
+ break;
+ // JS ArrayBuffer
+ case base::Value::TYPE_BINARY:
+ real_value = static_cast<base::BinaryValue*>(message.data.get());
+ if (real_value->GetBuffer()) {
+ message_proto->set_payload_type(CastMessage_PayloadType_BINARY);
+ message_proto->set_payload_binary(real_value->GetBuffer(),
+ real_value->GetSize());
+ }
+ break;
+ default:
+ // Unknown value type. message_proto will remain uninitialized because
+ // payload_type is unset.
+ break;
}
return message_proto->IsInitialized();
}
« no previous file with comments | « no previous file | chrome/browser/extensions/api/cast_channel/cast_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698