OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CONTENT_COMMON_BLUETOOTH_BLUETOOTH_DEVICE_ID_STRUCT_TRAITS_H_ |
| 6 #define CONTENT_COMMON_BLUETOOTH_BLUETOOTH_DEVICE_ID_STRUCT_TRAITS_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/strings/string_piece.h" |
| 11 #include "content/common/bluetooth/bluetooth_device_id.h" |
| 12 #include "content/common/bluetooth/bluetooth_device_id.mojom.h" |
| 13 |
| 14 namespace mojo { |
| 15 |
| 16 template <> |
| 17 struct StructTraits<content::mojom::BluetoothDeviceId, |
| 18 content::BluetoothDeviceId> { |
| 19 static const std::string& device_id( |
| 20 const content::BluetoothDeviceId& device_id) { |
| 21 return device_id.str(); |
| 22 } |
| 23 |
| 24 static bool Read(content::mojom::BluetoothDeviceIdDataView input, |
| 25 content::BluetoothDeviceId* output) { |
| 26 std::string result; |
| 27 |
| 28 if (!input.ReadDeviceId(&result)) |
| 29 return false; |
| 30 if (!content::BluetoothDeviceId::IsValid(result)) |
| 31 return false; |
| 32 |
| 33 *output = content::BluetoothDeviceId(std::move(result)); |
| 34 return true; |
| 35 } |
| 36 }; |
| 37 |
| 38 } // namespace mojo |
| 39 |
| 40 #endif // CONTENT_COMMON_BLUETOOTH_BLUETOOTH_DEVICE_ID_STRUCT_TRAITS_H_ |
OLD | NEW |