| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <algorithm> | 5 #include <algorithm> |
| 6 #include <cctype> | 6 #include <cctype> |
| 7 #include <iomanip> | 7 #include <iomanip> |
| 8 #include <ios> | 8 #include <ios> |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <sstream> | 10 #include <sstream> |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 TypeConverter<arc::mojom::BluetoothSdpAttributePtr, | 120 TypeConverter<arc::mojom::BluetoothSdpAttributePtr, |
| 121 bluez::BluetoothServiceAttributeValueBlueZ>:: | 121 bluez::BluetoothServiceAttributeValueBlueZ>:: |
| 122 Convert(const bluez::BluetoothServiceAttributeValueBlueZ& attr_bluez, | 122 Convert(const bluez::BluetoothServiceAttributeValueBlueZ& attr_bluez, |
| 123 size_t depth) { | 123 size_t depth) { |
| 124 auto result = arc::mojom::BluetoothSdpAttribute::New(); | 124 auto result = arc::mojom::BluetoothSdpAttribute::New(); |
| 125 result->type = attr_bluez.type(); | 125 result->type = attr_bluez.type(); |
| 126 result->type_size = 0; | 126 result->type_size = 0; |
| 127 | 127 |
| 128 switch (result->type) { | 128 switch (result->type) { |
| 129 case bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE: | 129 case bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE: |
| 130 result->value.Append(base::Value::CreateNullValue()); | 130 result->value.Append(base::MakeUnique<base::Value>()); |
| 131 break; | 131 break; |
| 132 case bluez::BluetoothServiceAttributeValueBlueZ::UINT: | 132 case bluez::BluetoothServiceAttributeValueBlueZ::UINT: |
| 133 case bluez::BluetoothServiceAttributeValueBlueZ::INT: | 133 case bluez::BluetoothServiceAttributeValueBlueZ::INT: |
| 134 case bluez::BluetoothServiceAttributeValueBlueZ::UUID: | 134 case bluez::BluetoothServiceAttributeValueBlueZ::UUID: |
| 135 case bluez::BluetoothServiceAttributeValueBlueZ::STRING: | 135 case bluez::BluetoothServiceAttributeValueBlueZ::STRING: |
| 136 case bluez::BluetoothServiceAttributeValueBlueZ::URL: | 136 case bluez::BluetoothServiceAttributeValueBlueZ::URL: |
| 137 case bluez::BluetoothServiceAttributeValueBlueZ::BOOL: | 137 case bluez::BluetoothServiceAttributeValueBlueZ::BOOL: |
| 138 result->type_size = attr_bluez.size(); | 138 result->type_size = attr_bluez.size(); |
| 139 result->value.Append(attr_bluez.value().CreateDeepCopy()); | 139 result->value.Append(attr_bluez.value().CreateDeepCopy()); |
| 140 break; | 140 break; |
| 141 case bluez::BluetoothServiceAttributeValueBlueZ::SEQUENCE: | 141 case bluez::BluetoothServiceAttributeValueBlueZ::SEQUENCE: |
| 142 if (depth + 1 >= arc::kBluetoothSDPMaxDepth) { | 142 if (depth + 1 >= arc::kBluetoothSDPMaxDepth) { |
| 143 result->type = bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE; | 143 result->type = bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE; |
| 144 result->type_size = 0; | 144 result->type_size = 0; |
| 145 result->value.Append(base::Value::CreateNullValue()); | 145 result->value.Append(base::MakeUnique<base::Value>()); |
| 146 return result; | 146 return result; |
| 147 } | 147 } |
| 148 for (const auto& child : attr_bluez.sequence()) { | 148 for (const auto& child : attr_bluez.sequence()) { |
| 149 result->sequence.push_back(Convert(child, depth + 1)); | 149 result->sequence.push_back(Convert(child, depth + 1)); |
| 150 } | 150 } |
| 151 result->type_size = result->sequence.size(); | 151 result->type_size = result->sequence.size(); |
| 152 result->value.Clear(); | 152 result->value.Clear(); |
| 153 break; | 153 break; |
| 154 default: | 154 default: |
| 155 NOTREACHED(); | 155 NOTREACHED(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 170 return bluez::BluetoothServiceAttributeValueBlueZ(); | 170 return bluez::BluetoothServiceAttributeValueBlueZ(); |
| 171 case bluez::BluetoothServiceAttributeValueBlueZ::UINT: | 171 case bluez::BluetoothServiceAttributeValueBlueZ::UINT: |
| 172 case bluez::BluetoothServiceAttributeValueBlueZ::INT: | 172 case bluez::BluetoothServiceAttributeValueBlueZ::INT: |
| 173 case bluez::BluetoothServiceAttributeValueBlueZ::UUID: | 173 case bluez::BluetoothServiceAttributeValueBlueZ::UUID: |
| 174 case bluez::BluetoothServiceAttributeValueBlueZ::STRING: | 174 case bluez::BluetoothServiceAttributeValueBlueZ::STRING: |
| 175 case bluez::BluetoothServiceAttributeValueBlueZ::URL: | 175 case bluez::BluetoothServiceAttributeValueBlueZ::URL: |
| 176 case bluez::BluetoothServiceAttributeValueBlueZ::BOOL: { | 176 case bluez::BluetoothServiceAttributeValueBlueZ::BOOL: { |
| 177 if (attr->value.GetSize() != 1) { | 177 if (attr->value.GetSize() != 1) { |
| 178 return bluez::BluetoothServiceAttributeValueBlueZ( | 178 return bluez::BluetoothServiceAttributeValueBlueZ( |
| 179 bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE, 0, | 179 bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE, 0, |
| 180 base::Value::CreateNullValue()); | 180 base::MakeUnique<base::Value>()); |
| 181 } | 181 } |
| 182 | 182 |
| 183 std::unique_ptr<base::Value> value; | 183 std::unique_ptr<base::Value> value; |
| 184 attr->value.Remove(0, &value); | 184 attr->value.Remove(0, &value); |
| 185 | 185 |
| 186 return bluez::BluetoothServiceAttributeValueBlueZ( | 186 return bluez::BluetoothServiceAttributeValueBlueZ( |
| 187 type, static_cast<size_t>(attr->type_size), std::move(value)); | 187 type, static_cast<size_t>(attr->type_size), std::move(value)); |
| 188 } | 188 } |
| 189 case bluez::BluetoothServiceAttributeValueBlueZ::SEQUENCE: { | 189 case bluez::BluetoothServiceAttributeValueBlueZ::SEQUENCE: { |
| 190 if (depth + 1 >= arc::kBluetoothSDPMaxDepth || attr->sequence.empty()) { | 190 if (depth + 1 >= arc::kBluetoothSDPMaxDepth || attr->sequence.empty()) { |
| 191 return bluez::BluetoothServiceAttributeValueBlueZ( | 191 return bluez::BluetoothServiceAttributeValueBlueZ( |
| 192 bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE, 0, | 192 bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE, 0, |
| 193 base::Value::CreateNullValue()); | 193 base::MakeUnique<base::Value>()); |
| 194 } | 194 } |
| 195 | 195 |
| 196 auto bluez_sequence = base::MakeUnique< | 196 auto bluez_sequence = base::MakeUnique< |
| 197 bluez::BluetoothServiceAttributeValueBlueZ::Sequence>(); | 197 bluez::BluetoothServiceAttributeValueBlueZ::Sequence>(); |
| 198 for (const auto& child : attr->sequence) { | 198 for (const auto& child : attr->sequence) { |
| 199 bluez_sequence->push_back(Convert(child, depth + 1)); | 199 bluez_sequence->push_back(Convert(child, depth + 1)); |
| 200 } | 200 } |
| 201 return bluez::BluetoothServiceAttributeValueBlueZ( | 201 return bluez::BluetoothServiceAttributeValueBlueZ( |
| 202 std::move(bluez_sequence)); | 202 std::move(bluez_sequence)); |
| 203 break; | 203 break; |
| 204 } | 204 } |
| 205 default: | 205 default: |
| 206 NOTREACHED(); | 206 NOTREACHED(); |
| 207 } | 207 } |
| 208 return bluez::BluetoothServiceAttributeValueBlueZ( | 208 return bluez::BluetoothServiceAttributeValueBlueZ( |
| 209 bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE, 0, | 209 bluez::BluetoothServiceAttributeValueBlueZ::NULLTYPE, 0, |
| 210 base::Value::CreateNullValue()); | 210 base::MakeUnique<base::Value>()); |
| 211 } | 211 } |
| 212 | 212 |
| 213 // static | 213 // static |
| 214 arc::mojom::BluetoothSdpRecordPtr | 214 arc::mojom::BluetoothSdpRecordPtr |
| 215 TypeConverter<arc::mojom::BluetoothSdpRecordPtr, | 215 TypeConverter<arc::mojom::BluetoothSdpRecordPtr, |
| 216 bluez::BluetoothServiceRecordBlueZ>:: | 216 bluez::BluetoothServiceRecordBlueZ>:: |
| 217 Convert(const bluez::BluetoothServiceRecordBlueZ& record_bluez) { | 217 Convert(const bluez::BluetoothServiceRecordBlueZ& record_bluez) { |
| 218 arc::mojom::BluetoothSdpRecordPtr result = | 218 arc::mojom::BluetoothSdpRecordPtr result = |
| 219 arc::mojom::BluetoothSdpRecord::New(); | 219 arc::mojom::BluetoothSdpRecord::New(); |
| 220 | 220 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 default: | 258 default: |
| 259 NOTREACHED(); | 259 NOTREACHED(); |
| 260 break; | 260 break; |
| 261 } | 261 } |
| 262 } | 262 } |
| 263 | 263 |
| 264 return record_bluez; | 264 return record_bluez; |
| 265 } | 265 } |
| 266 | 266 |
| 267 } // namespace mojo | 267 } // namespace mojo |
| OLD | NEW |