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

Unified Diff: content/renderer/gamepad_shared_memory_reader.cc

Issue 316013007: Fix race condition in gamepad that prevents it to work without a rAF loop (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/gamepad_shared_memory_reader.cc
diff --git a/content/renderer/gamepad_shared_memory_reader.cc b/content/renderer/gamepad_shared_memory_reader.cc
index f1b1e835144c85ab26a7ee33fb1599d07a809e0a..3bfe0d0e89553987468333d0aabfe6f16d7b1516 100644
--- a/content/renderer/gamepad_shared_memory_reader.cc
+++ b/content/renderer/gamepad_shared_memory_reader.cc
@@ -101,16 +101,12 @@ void GamepadSharedMemoryReader::SampleGamepads(blink::WebGamepads& gamepads) {
memcpy(&gamepads, &read_into, sizeof(gamepads));
if (!ever_interacted_with_) {
- if (GamepadsHaveUserGesture(gamepads)) {
- ever_interacted_with_ = true;
- } else {
- // Clear the connected flag if the user hasn't interacted with any of the
- // gamepads to prevent fingerprinting. The actual data is not cleared.
- // WebKit will only copy out data into the JS buffers for connected
- // gamepads so this is sufficient.
- for (unsigned i = 0; i < blink::WebGamepads::itemsLengthCap; i++)
- gamepads.items[i].connected = false;
- }
+ // Clear the connected flag if the user hasn't interacted with any of the
+ // gamepads to prevent fingerprinting. The actual data is not cleared.
+ // WebKit will only copy out data into the JS buffers for connected
+ // gamepads so this is sufficient.
+ for (unsigned i = 0; i < blink::WebGamepads::itemsLengthCap; i++)
+ gamepads.items[i].connected = false;
}
}
@@ -144,6 +140,9 @@ bool GamepadSharedMemoryReader::OnControlMessageReceived(
void GamepadSharedMemoryReader::OnGamepadConnected(
int index,
const blink::WebGamepad& gamepad) {
+ // The browser already checks if the user actually interacted with a device.
+ ever_interacted_with_ = true;
+
if (gamepad_listener_)
gamepad_listener_->didConnectGamepad(index, gamepad);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698