| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "extensions/browser/api/cast_channel/cast_message_util.h" | 5 #include "extensions/browser/api/cast_channel/cast_message_util.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 message->namespace_ = message_proto.namespace_(); | 79 message->namespace_ = message_proto.namespace_(); |
| 80 // Determine the type of the payload and fill base::Value appropriately. | 80 // Determine the type of the payload and fill base::Value appropriately. |
| 81 std::unique_ptr<base::Value> value; | 81 std::unique_ptr<base::Value> value; |
| 82 switch (message_proto.payload_type()) { | 82 switch (message_proto.payload_type()) { |
| 83 case CastMessage_PayloadType_STRING: | 83 case CastMessage_PayloadType_STRING: |
| 84 if (message_proto.has_payload_utf8()) | 84 if (message_proto.has_payload_utf8()) |
| 85 value.reset(new base::Value(message_proto.payload_utf8())); | 85 value.reset(new base::Value(message_proto.payload_utf8())); |
| 86 break; | 86 break; |
| 87 case CastMessage_PayloadType_BINARY: | 87 case CastMessage_PayloadType_BINARY: |
| 88 if (message_proto.has_payload_binary()) | 88 if (message_proto.has_payload_binary()) |
| 89 value = base::BinaryValue::CreateWithCopiedBuffer( | 89 value = base::Value::CreateWithCopiedBuffer( |
| 90 message_proto.payload_binary().data(), | 90 message_proto.payload_binary().data(), |
| 91 message_proto.payload_binary().size()); | 91 message_proto.payload_binary().size()); |
| 92 break; | 92 break; |
| 93 default: | 93 default: |
| 94 // Unknown payload type. value will remain unset. | 94 // Unknown payload type. value will remain unset. |
| 95 break; | 95 break; |
| 96 } | 96 } |
| 97 if (value.get()) { | 97 if (value.get()) { |
| 98 DCHECK(!message->data.get()); | 98 DCHECK(!message->data.get()); |
| 99 message->data = std::move(value); | 99 message->data = std::move(value); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 message_proto->set_payload_binary(auth_message_string); | 151 message_proto->set_payload_binary(auth_message_string); |
| 152 } | 152 } |
| 153 | 153 |
| 154 bool IsAuthMessage(const CastMessage& message) { | 154 bool IsAuthMessage(const CastMessage& message) { |
| 155 return message.namespace_() == kAuthNamespace; | 155 return message.namespace_() == kAuthNamespace; |
| 156 } | 156 } |
| 157 | 157 |
| 158 } // namespace cast_channel | 158 } // namespace cast_channel |
| 159 } // namespace api | 159 } // namespace api |
| 160 } // namespace extensions | 160 } // namespace extensions |
| OLD | NEW |