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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: device/usb/public/interfaces/device_manager_struct_traits.h
diff --git a/device/usb/public/interfaces/device_manager_struct_traits.h b/device/usb/public/interfaces/device_manager_struct_traits.h
new file mode 100644
index 0000000000000000000000000000000000000000..1e5bf363c546b5d6e2ec9e5f188bba9f8272a9f9
--- /dev/null
+++ b/device/usb/public/interfaces/device_manager_struct_traits.h
@@ -0,0 +1,62 @@
+// Copyright 2017 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 DEVICE_USB_PUBLIC_INTERFACES_DEVICE_MANAGER_STRUCT_TRAITS_H_
+#define DEVICE_USB_PUBLIC_INTERFACES_DEVICE_MANAGER_STRUCT_TRAITS_H_
+
+#include "device/usb/public/interfaces/device_manager.mojom.h"
+#include "device/usb/usb_device_filter.h"
+
+namespace mojo {
+
+template <>
+struct StructTraits<device::usb::DeviceFilterDataView,
+ device::UsbDeviceFilter> {
+ static bool has_vendor_id(const device::UsbDeviceFilter& filter) {
+ return filter.vendor_id.has_value();
+ }
+
+ static uint16_t vendor_id(const device::UsbDeviceFilter& filter) {
+ return filter.vendor_id.value_or(0);
+ }
+
+ static bool has_product_id(const device::UsbDeviceFilter& filter) {
+ return filter.product_id.has_value();
+ }
+
+ static uint16_t product_id(const device::UsbDeviceFilter& filter) {
+ return filter.product_id.value_or(0);
+ }
+
+ static bool has_class_code(const device::UsbDeviceFilter& filter) {
+ return filter.interface_class.has_value();
+ }
+
+ static uint8_t class_code(const device::UsbDeviceFilter& filter) {
+ return filter.interface_class.value_or(0);
+ }
+
+ static bool has_subclass_code(const device::UsbDeviceFilter& filter) {
+ return filter.interface_subclass.has_value();
+ }
+
+ static uint8_t subclass_code(const device::UsbDeviceFilter& filter) {
+ return filter.interface_subclass.value_or(0);
+ }
+
+ static bool has_protocol_code(const device::UsbDeviceFilter& filter) {
+ return filter.interface_protocol.has_value();
+ }
+
+ static uint8_t protocol_code(const device::UsbDeviceFilter& filter) {
+ return filter.interface_protocol.value_or(0);
+ }
+
+ static bool Read(device::usb::DeviceFilterDataView input,
+ device::UsbDeviceFilter* output);
+};
+
+} // namespace mojo
+
+#endif // DEVICE_USB_PUBLIC_INTERFACES_DEVICE_MANAGER_STRUCT_TRAITS_H_
« 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