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

Unified Diff: device/gamepad/public/interfaces/gamepad_struct_traits.cc

Issue 2808093006: [Device Service] Move Gamepad Blink headers to be part of the Gamepad client library (Closed)
Patch Set: rebase and address comments Created 3 years, 8 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/gamepad/public/interfaces/gamepad_struct_traits.cc
diff --git a/device/gamepad/public/interfaces/gamepad_struct_traits.cc b/device/gamepad/public/interfaces/gamepad_struct_traits.cc
index 3d02a272199f34f268ef29e17793d3a9d7d9b22d..2a97cea2d95af8f83dda000855a4eae958164a17 100644
--- a/device/gamepad/public/interfaces/gamepad_struct_traits.cc
+++ b/device/gamepad/public/interfaces/gamepad_struct_traits.cc
@@ -9,16 +9,16 @@ namespace mojo {
// static
void StructTraits<
device::mojom::GamepadQuaternionDataView,
- blink::WebGamepadQuaternion>::SetToNull(blink::WebGamepadQuaternion* out) {
- memset(out, 0, sizeof(blink::WebGamepadQuaternion));
+ device::GamepadQuaternion>::SetToNull(device::GamepadQuaternion* out) {
+ memset(out, 0, sizeof(device::GamepadQuaternion));
out->not_null = false;
}
// static
bool StructTraits<device::mojom::GamepadQuaternionDataView,
- blink::WebGamepadQuaternion>::
+ device::GamepadQuaternion>::
Read(device::mojom::GamepadQuaternionDataView data,
- blink::WebGamepadQuaternion* out) {
+ device::GamepadQuaternion* out) {
out->not_null = true;
out->x = data.x();
out->y = data.y();
@@ -29,17 +29,16 @@ bool StructTraits<device::mojom::GamepadQuaternionDataView,
// static
void StructTraits<device::mojom::GamepadVectorDataView,
- blink::WebGamepadVector>::SetToNull(blink::WebGamepadVector*
- out) {
- memset(out, 0, sizeof(blink::WebGamepadVector));
+ device::GamepadVector>::SetToNull(device::GamepadVector*
+ out) {
+ memset(out, 0, sizeof(device::GamepadVector));
out->not_null = false;
}
// static
-bool StructTraits<
- device::mojom::GamepadVectorDataView,
- blink::WebGamepadVector>::Read(device::mojom::GamepadVectorDataView data,
- blink::WebGamepadVector* out) {
+bool StructTraits<device::mojom::GamepadVectorDataView, device::GamepadVector>::
+ Read(device::mojom::GamepadVectorDataView data,
+ device::GamepadVector* out) {
out->not_null = true;
out->x = data.x();
out->y = data.y();
@@ -48,10 +47,9 @@ bool StructTraits<
}
// static
-bool StructTraits<
- device::mojom::GamepadButtonDataView,
- blink::WebGamepadButton>::Read(device::mojom::GamepadButtonDataView data,
- blink::WebGamepadButton* out) {
+bool StructTraits<device::mojom::GamepadButtonDataView, device::GamepadButton>::
+ Read(device::mojom::GamepadButtonDataView data,
+ device::GamepadButton* out) {
out->pressed = data.pressed();
out->touched = data.touched();
out->value = data.value();
@@ -60,15 +58,14 @@ bool StructTraits<
// static
void StructTraits<device::mojom::GamepadPoseDataView,
- blink::WebGamepadPose>::SetToNull(blink::WebGamepadPose*
- out) {
- memset(out, 0, sizeof(blink::WebGamepadPose));
+ device::GamepadPose>::SetToNull(device::GamepadPose* out) {
+ memset(out, 0, sizeof(device::GamepadPose));
out->not_null = false;
}
// static
-bool StructTraits<device::mojom::GamepadPoseDataView, blink::WebGamepadPose>::
- Read(device::mojom::GamepadPoseDataView data, blink::WebGamepadPose* out) {
+bool StructTraits<device::mojom::GamepadPoseDataView, device::GamepadPose>::
+ Read(device::mojom::GamepadPoseDataView data, device::GamepadPose* out) {
out->not_null = true;
if (!data.ReadOrientation(&out->orientation)) {
return false;
@@ -97,14 +94,14 @@ bool StructTraits<device::mojom::GamepadPoseDataView, blink::WebGamepadPose>::
// static
device::mojom::GamepadHand
-EnumTraits<device::mojom::GamepadHand, blink::WebGamepadHand>::ToMojom(
- blink::WebGamepadHand input) {
+EnumTraits<device::mojom::GamepadHand, device::GamepadHand>::ToMojom(
+ device::GamepadHand input) {
switch (input) {
- case blink::WebGamepadHand::kGamepadHandNone:
+ case device::GamepadHand::kNone:
return device::mojom::GamepadHand::GamepadHandNone;
- case blink::WebGamepadHand::kGamepadHandLeft:
+ case device::GamepadHand::kLeft:
return device::mojom::GamepadHand::GamepadHandLeft;
- case blink::WebGamepadHand::kGamepadHandRight:
+ case device::GamepadHand::kRight:
return device::mojom::GamepadHand::GamepadHandRight;
}
@@ -113,18 +110,18 @@ EnumTraits<device::mojom::GamepadHand, blink::WebGamepadHand>::ToMojom(
}
// static
-bool EnumTraits<device::mojom::GamepadHand, blink::WebGamepadHand>::FromMojom(
+bool EnumTraits<device::mojom::GamepadHand, device::GamepadHand>::FromMojom(
device::mojom::GamepadHand input,
- blink::WebGamepadHand* output) {
+ device::GamepadHand* output) {
switch (input) {
case device::mojom::GamepadHand::GamepadHandNone:
- *output = blink::WebGamepadHand::kGamepadHandNone;
+ *output = device::GamepadHand::kNone;
return true;
case device::mojom::GamepadHand::GamepadHandLeft:
- *output = blink::WebGamepadHand::kGamepadHandLeft;
+ *output = device::GamepadHand::kLeft;
return true;
case device::mojom::GamepadHand::GamepadHandRight:
- *output = blink::WebGamepadHand::kGamepadHandRight;
+ *output = device::GamepadHand::kRight;
return true;
}
@@ -134,10 +131,10 @@ bool EnumTraits<device::mojom::GamepadHand, blink::WebGamepadHand>::FromMojom(
// static
ConstCArray<uint16_t>
-StructTraits<device::mojom::GamepadDataView, blink::WebGamepad>::id(
- const blink::WebGamepad& r) {
+StructTraits<device::mojom::GamepadDataView, device::Gamepad>::id(
+ const device::Gamepad& r) {
size_t id_length = 0;
- while (id_length < blink::WebGamepad::kIdLengthCap && r.id[id_length] != 0) {
+ while (id_length < device::Gamepad::kIdLengthCap && r.id[id_length] != 0) {
id_length++;
}
return {id_length, reinterpret_cast<const uint16_t*>(&r.id[0])};
@@ -145,10 +142,10 @@ StructTraits<device::mojom::GamepadDataView, blink::WebGamepad>::id(
// static
ConstCArray<uint16_t>
-StructTraits<device::mojom::GamepadDataView, blink::WebGamepad>::mapping(
- const blink::WebGamepad& r) {
+StructTraits<device::mojom::GamepadDataView, device::Gamepad>::mapping(
+ const device::Gamepad& r) {
size_t mapping_length = 0;
- while (mapping_length < blink::WebGamepad::kMappingLengthCap &&
+ while (mapping_length < device::Gamepad::kMappingLengthCap &&
r.mapping[mapping_length] != 0) {
mapping_length++;
}
@@ -156,14 +153,13 @@ StructTraits<device::mojom::GamepadDataView, blink::WebGamepad>::mapping(
}
// static
-bool StructTraits<device::mojom::GamepadDataView, blink::WebGamepad>::Read(
+bool StructTraits<device::mojom::GamepadDataView, device::Gamepad>::Read(
device::mojom::GamepadDataView data,
- blink::WebGamepad* out) {
+ device::Gamepad* out) {
out->connected = data.connected();
- memset(&out->id[0], 0,
- blink::WebGamepad::kIdLengthCap * sizeof(blink::WebUChar));
- CArray<uint16_t> id = {0, blink::WebGamepad::kIdLengthCap,
+ memset(&out->id[0], 0, device::Gamepad::kIdLengthCap * sizeof(device::UChar));
+ CArray<uint16_t> id = {0, device::Gamepad::kIdLengthCap,
reinterpret_cast<uint16_t*>(&out->id[0])};
if (!data.ReadId(&id)) {
return false;
@@ -171,15 +167,15 @@ bool StructTraits<device::mojom::GamepadDataView, blink::WebGamepad>::Read(
out->timestamp = data.timestamp();
- CArray<double> axes = {0, blink::WebGamepad::kAxesLengthCap, &out->axes[0]};
+ CArray<double> axes = {0, device::Gamepad::kAxesLengthCap, &out->axes[0]};
if (!data.ReadAxes(&axes)) {
return false;
}
// static_cast is safe when "data.ReadAxes(&axes)" above returns true.
out->axes_length = static_cast<unsigned>(axes.size);
- CArray<blink::WebGamepadButton> buttons = {
- 0, blink::WebGamepad::kButtonsLengthCap, &out->buttons[0]};
+ CArray<device::GamepadButton> buttons = {
+ 0, device::Gamepad::kButtonsLengthCap, &out->buttons[0]};
if (!data.ReadButtons(&buttons)) {
return false;
}
@@ -187,8 +183,8 @@ bool StructTraits<device::mojom::GamepadDataView, blink::WebGamepad>::Read(
out->buttons_length = static_cast<unsigned>(buttons.size);
memset(&out->mapping[0], 0,
- blink::WebGamepad::kMappingLengthCap * sizeof(blink::WebUChar));
- CArray<uint16_t> mapping = {0, blink::WebGamepad::kMappingLengthCap,
+ device::Gamepad::kMappingLengthCap * sizeof(device::UChar));
+ CArray<uint16_t> mapping = {0, device::Gamepad::kMappingLengthCap,
reinterpret_cast<uint16_t*>(&out->mapping[0])};
if (!data.ReadMapping(&mapping)) {
return false;
@@ -198,7 +194,7 @@ bool StructTraits<device::mojom::GamepadDataView, blink::WebGamepad>::Read(
return false;
}
- blink::WebGamepadHand hand;
+ device::GamepadHand hand;
if (!data.ReadHand(&hand)) {
return false;
}

Powered by Google App Engine
This is Rietveld 408576698