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