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 COMPONENTS_WEB_BLUETOOTH_PUBLIC_INTERFACES_WEB_BLUETOOTH_DEVICE_ID_STRUC
T_TRAITS_H_ |
| 6 #define COMPONENTS_WEB_BLUETOOTH_PUBLIC_INTERFACES_WEB_BLUETOOTH_DEVICE_ID_STRUC
T_TRAITS_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "components/web_bluetooth/public/interfaces/web_bluetooth_device_id.moj
om.h" |
| 11 #include "components/web_bluetooth/web_bluetooth_device_id.h" |
| 12 |
| 13 namespace mojo { |
| 14 |
| 15 template <> |
| 16 struct StructTraits<web_bluetooth::mojom::WebBluetoothDeviceId, |
| 17 web_bluetooth::WebBluetoothDeviceId> { |
| 18 static const std::string& device_id( |
| 19 const web_bluetooth::WebBluetoothDeviceId& device_id) { |
| 20 return device_id.str(); |
| 21 } |
| 22 |
| 23 static bool Read(web_bluetooth::mojom::WebBluetoothDeviceIdDataView input, |
| 24 web_bluetooth::WebBluetoothDeviceId* output) { |
| 25 std::string result; |
| 26 |
| 27 if (!input.ReadDeviceId(&result)) |
| 28 return false; |
| 29 if (!web_bluetooth::WebBluetoothDeviceId::IsValid(result)) |
| 30 return false; |
| 31 |
| 32 *output = web_bluetooth::WebBluetoothDeviceId(std::move(result)); |
| 33 return true; |
| 34 } |
| 35 }; |
| 36 |
| 37 } // namespace mojo |
| 38 |
| 39 #endif // COMPONENTS_WEB_BLUETOOTH_PUBLIC_INTERFACES_WEB_BLUETOOTH_DEVICE_ID_ST
RUCT_TRAITS_H_ |
OLD | NEW |