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