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

Unified Diff: ui/events/devices/mojo/input_device_struct_traits.h

Issue 2069823004: Fix InputDevice StructTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mojo_device
Patch Set: Run gn format. Created 4 years, 6 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
« no previous file with comments | « ui/events/devices/mojo/input_device.typemap ('k') | ui/events/devices/mojo/input_device_struct_traits.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/events/devices/mojo/input_device_struct_traits.h
diff --git a/ui/events/devices/mojo/input_device_struct_traits.h b/ui/events/devices/mojo/input_device_struct_traits.h
index d2945bb6ba07c317a3f467d708975b0680c82ff5..c4f890ac2af7d924e4966041d5cb018aba75f876 100644
--- a/ui/events/devices/mojo/input_device_struct_traits.h
+++ b/ui/events/devices/mojo/input_device_struct_traits.h
@@ -16,18 +16,18 @@
namespace mojo {
template <>
+struct EnumTraits<ui::mojom::InputDeviceType, ui::InputDeviceType> {
+ static ui::mojom::InputDeviceType ToMojom(ui::InputDeviceType type);
+ static bool FromMojom(ui::mojom::InputDeviceType type,
+ ui::InputDeviceType* output);
+};
+
+template <>
struct StructTraits<ui::mojom::InputDevice, ui::InputDevice> {
static int32_t id(const ui::InputDevice& device) { return device.id; }
- static ui::mojom::InputDeviceType type(const ui::InputDevice& device) {
- switch (device.type) {
- case ui::INPUT_DEVICE_INTERNAL:
- return ui::mojom::InputDeviceType::INPUT_DEVICE_INTERNAL;
- case ui::INPUT_DEVICE_EXTERNAL:
- return ui::mojom::InputDeviceType::INPUT_DEVICE_EXTERNAL;
- case ui::INPUT_DEVICE_UNKNOWN:
- return ui::mojom::InputDeviceType::INPUT_DEVICE_UNKNOWN;
- }
+ static ui::InputDeviceType type(const ui::InputDevice& device) {
+ return device.type;
}
static const std::string& name(const ui::InputDevice& device) {
@@ -46,37 +46,7 @@ struct StructTraits<ui::mojom::InputDevice, ui::InputDevice> {
return device.product_id;
}
- static bool Read(ui::mojom::InputDeviceDataView data, ui::InputDevice* out) {
- out->id = data.id();
-
- switch (data.type()) {
- case ui::mojom::InputDeviceType::INPUT_DEVICE_INTERNAL:
- out->type = ui::INPUT_DEVICE_INTERNAL;
- break;
- case ui::mojom::InputDeviceType::INPUT_DEVICE_EXTERNAL:
- out->type = ui::INPUT_DEVICE_EXTERNAL;
- break;
- case ui::mojom::InputDeviceType::INPUT_DEVICE_UNKNOWN:
- out->type = ui::INPUT_DEVICE_UNKNOWN;
- break;
- default:
- // Who knows what values might come over the wire, fail if invalid.
- return false;
- }
-
- if (!data.ReadName(&out->name))
- return false;
-
- base::StringPiece sys_path_string;
- if (!data.ReadSysPath(&sys_path_string))
- return false;
- out->sys_path = base::FilePath::FromUTF8Unsafe(sys_path_string);
-
- out->vendor_id = data.vendor_id();
- out->product_id = data.product_id();
-
- return true;
- }
+ static bool Read(ui::mojom::InputDeviceDataView data, ui::InputDevice* out);
};
template <>
@@ -95,17 +65,7 @@ struct StructTraits<ui::mojom::TouchscreenDevice, ui::TouchscreenDevice> {
}
static bool Read(ui::mojom::TouchscreenDeviceDataView data,
- ui::TouchscreenDevice* out) {
- if (!data.ReadInputDevice(static_cast<ui::InputDevice*>(out)))
- return false;
-
- if (!data.ReadSize(&out->size))
- return false;
-
- out->touch_points = data.touch_points();
-
- return true;
- }
+ ui::TouchscreenDevice* out);
};
} // namespace mojo
« no previous file with comments | « ui/events/devices/mojo/input_device.typemap ('k') | ui/events/devices/mojo/input_device_struct_traits.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698