| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 value = base::BinaryValue::CreateWithCopiedBuffer( | 92 value = base::BinaryValue::CreateWithCopiedBuffer( |
| 93 message_proto.payload_binary().data(), | 93 message_proto.payload_binary().data(), |
| 94 message_proto.payload_binary().size()); | 94 message_proto.payload_binary().size()); |
| 95 break; | 95 break; |
| 96 default: | 96 default: |
| 97 // Unknown payload type. value will remain unset. | 97 // Unknown payload type. value will remain unset. |
| 98 break; | 98 break; |
| 99 } | 99 } |
| 100 if (value.get()) { | 100 if (value.get()) { |
| 101 DCHECK(!message->data.get()); | 101 DCHECK(!message->data.get()); |
| 102 message->data.reset(value.release()); | 102 message->data = std::move(value); |
| 103 return true; | 103 return true; |
| 104 } else { | 104 } else { |
| 105 return false; | 105 return false; |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 std::string CastMessageToString(const CastMessage& message_proto) { | 109 std::string CastMessageToString(const CastMessage& message_proto) { |
| 110 std::string out("{"); | 110 std::string out("{"); |
| 111 out += "namespace = " + message_proto.namespace_(); | 111 out += "namespace = " + message_proto.namespace_(); |
| 112 out += ", sourceId = " + message_proto.source_id(); | 112 out += ", sourceId = " + message_proto.source_id(); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 message_proto->set_payload_binary(auth_message_string); | 153 message_proto->set_payload_binary(auth_message_string); |
| 154 } | 154 } |
| 155 | 155 |
| 156 bool IsAuthMessage(const CastMessage& message) { | 156 bool IsAuthMessage(const CastMessage& message) { |
| 157 return message.namespace_() == kAuthNamespace; | 157 return message.namespace_() == kAuthNamespace; |
| 158 } | 158 } |
| 159 | 159 |
| 160 } // namespace cast_channel | 160 } // namespace cast_channel |
| 161 } // namespace api | 161 } // namespace api |
| 162 } // namespace extensions | 162 } // namespace extensions |
| OLD | NEW |