Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: device/usb/public/interfaces/device_manager_struct_traits.h

Issue 2615353002: Typemap device.usb.DeviceFilter to device::UsbDeviceFilter. (Closed)
Patch Set: Addressed juncai@'s feedback. Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2017 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 DEVICE_USB_PUBLIC_INTERFACES_DEVICE_MANAGER_STRUCT_TRAITS_H_
6 #define DEVICE_USB_PUBLIC_INTERFACES_DEVICE_MANAGER_STRUCT_TRAITS_H_
7
8 #include "device/usb/public/interfaces/device_manager.mojom.h"
9 #include "device/usb/usb_device_filter.h"
10
11 namespace mojo {
12
13 template <>
14 struct StructTraits<device::usb::DeviceFilterDataView,
15 device::UsbDeviceFilter> {
16 static bool has_vendor_id(const device::UsbDeviceFilter& filter) {
17 return filter.vendor_id.has_value();
18 }
19
20 static uint16_t vendor_id(const device::UsbDeviceFilter& filter) {
21 return filter.vendor_id.value_or(0);
22 }
23
24 static bool has_product_id(const device::UsbDeviceFilter& filter) {
25 return filter.product_id.has_value();
26 }
27
28 static uint16_t product_id(const device::UsbDeviceFilter& filter) {
29 return filter.product_id.value_or(0);
30 }
31
32 static bool has_class_code(const device::UsbDeviceFilter& filter) {
33 return filter.interface_class.has_value();
34 }
35
36 static uint8_t class_code(const device::UsbDeviceFilter& filter) {
37 return filter.interface_class.value_or(0);
38 }
39
40 static bool has_subclass_code(const device::UsbDeviceFilter& filter) {
41 return filter.interface_subclass.has_value();
42 }
43
44 static uint8_t subclass_code(const device::UsbDeviceFilter& filter) {
45 return filter.interface_subclass.value_or(0);
46 }
47
48 static bool has_protocol_code(const device::UsbDeviceFilter& filter) {
49 return filter.interface_protocol.has_value();
50 }
51
52 static uint8_t protocol_code(const device::UsbDeviceFilter& filter) {
53 return filter.interface_protocol.value_or(0);
54 }
55
56 static bool Read(device::usb::DeviceFilterDataView input,
57 device::UsbDeviceFilter* output);
58 };
59
60 } // namespace mojo
61
62 #endif // DEVICE_USB_PUBLIC_INTERFACES_DEVICE_MANAGER_STRUCT_TRAITS_H_
OLDNEW
« no previous file with comments | « device/usb/public/interfaces/device_manager.typemap ('k') | device/usb/public/interfaces/device_manager_struct_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698