Index: components/web_bluetooth/public/interfaces/web_bluetooth_device_id_struct_traits.h |
diff --git a/components/web_bluetooth/public/interfaces/web_bluetooth_device_id_struct_traits.h b/components/web_bluetooth/public/interfaces/web_bluetooth_device_id_struct_traits.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4524f4abd946903038c9af218ba2dc5ef7237cc6 |
--- /dev/null |
+++ b/components/web_bluetooth/public/interfaces/web_bluetooth_device_id_struct_traits.h |
@@ -0,0 +1,39 @@ |
+// 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 COMPONENTS_WEB_BLUETOOTH_PUBLIC_INTERFACES_WEB_BLUETOOTH_DEVICE_ID_STRUCT_TRAITS_H_ |
+#define COMPONENTS_WEB_BLUETOOTH_PUBLIC_INTERFACES_WEB_BLUETOOTH_DEVICE_ID_STRUCT_TRAITS_H_ |
+ |
+#include <string> |
+ |
+#include "components/web_bluetooth/public/interfaces/web_bluetooth_device_id.mojom.h" |
+#include "components/web_bluetooth/web_bluetooth_device_id.h" |
+ |
+namespace mojo { |
+ |
+template <> |
+struct StructTraits<web_bluetooth::mojom::WebBluetoothDeviceId, |
+ web_bluetooth::WebBluetoothDeviceId> { |
+ static const std::string& device_id( |
+ const web_bluetooth::WebBluetoothDeviceId& device_id) { |
+ return device_id.str(); |
+ } |
+ |
+ static bool Read(web_bluetooth::mojom::WebBluetoothDeviceIdDataView input, |
+ web_bluetooth::WebBluetoothDeviceId* output) { |
+ std::string result; |
+ |
+ if (!input.ReadDeviceId(&result)) |
+ return false; |
+ if (!web_bluetooth::WebBluetoothDeviceId::IsValid(result)) |
+ return false; |
+ |
+ *output = web_bluetooth::WebBluetoothDeviceId(std::move(result)); |
+ return true; |
+ } |
+}; |
+ |
+} // namespace mojo |
+ |
+#endif // COMPONENTS_WEB_BLUETOOTH_PUBLIC_INTERFACES_WEB_BLUETOOTH_DEVICE_ID_STRUCT_TRAITS_H_ |