Chromium Code Reviews| Index: content/common/bluetooth/bluetooth_device_id_struct_traits.h |
| diff --git a/content/common/bluetooth/bluetooth_device_id_struct_traits.h b/content/common/bluetooth/bluetooth_device_id_struct_traits.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..627dd9a6f6d2651defd86d6cdbf6c5cff35fd5b6 |
| --- /dev/null |
| +++ b/content/common/bluetooth/bluetooth_device_id_struct_traits.h |
| @@ -0,0 +1,40 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CONTENT_COMMON_BLUETOOTH_BLUETOOTH_DEVICE_ID_STRUCT_TRAITS_H_ |
| +#define CONTENT_COMMON_BLUETOOTH_BLUETOOTH_DEVICE_ID_STRUCT_TRAITS_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/strings/string_piece.h" |
| +#include "content/common/bluetooth/bluetooth_device_id.h" |
| +#include "content/common/bluetooth/bluetooth_device_id.mojom.h" |
| + |
| +namespace mojo { |
| + |
| +template <> |
| +struct StructTraits<content::mojom::BluetoothDeviceId, |
| + content::BluetoothDeviceId> { |
| + static const std::string& device_id( |
| + const content::BluetoothDeviceId& device_id) { |
| + return device_id.str(); |
| + } |
| + |
| + static bool Read(content::mojom::BluetoothDeviceIdDataView input, |
| + content::BluetoothDeviceId* output) { |
| + std::string result; |
| + |
| + if (!input.ReadDeviceId(&result)) |
| + return false; |
| + if (!content::BluetoothDeviceId::IsValid(result)) |
| + return false; |
| + |
| + *output = content::BluetoothDeviceId(result); |
|
Jeffrey Yasskin
2016/06/03 17:22:05
std::move(result)?
ortuno
2016/06/06 22:22:59
Done.
|
| + return true; |
| + } |
| +}; |
| + |
| +} // namespace mojo |
| + |
| +#endif // CONTENT_COMMON_BLUETOOTH_BLUETOOTH_DEVICE_ID_STRUCT_TRAITS_H_ |