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

Unified Diff: Source/modules/gamepad/GamepadDispatcher.cpp

Issue 336693004: Deduplicate DeviceEvent* classes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: derive from *Base 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
Index: Source/modules/gamepad/GamepadDispatcher.cpp
diff --git a/Source/modules/gamepad/GamepadDispatcher.cpp b/Source/modules/gamepad/GamepadDispatcher.cpp
index 0749ad1a1bf2b053cf061c28c307b502c92b3f29..e0a099d9c2ce3970381aa69b9137824872be6b30 100644
--- a/Source/modules/gamepad/GamepadDispatcher.cpp
+++ b/Source/modules/gamepad/GamepadDispatcher.cpp
@@ -17,19 +17,8 @@ GamepadDispatcher& GamepadDispatcher::instance()
return gamepadDispatcher;
}
-void GamepadDispatcher::addClient(NavigatorGamepad* client)
-{
- addController(client);
-}
-
-void GamepadDispatcher::removeClient(NavigatorGamepad* client)
-{
- removeController(client);
-}
-
void GamepadDispatcher::sampleGamepads(blink::WebGamepads& gamepads)
{
- ASSERT(!m_controllers.isEmpty());
blink::Platform::current()->sampleGamepads(gamepads);
}
@@ -53,18 +42,18 @@ void GamepadDispatcher::didDisconnectGamepad(unsigned index, const blink::WebGam
void GamepadDispatcher::dispatchDidConnectOrDisconnectGamepad(unsigned index, const blink::WebGamepad& gamepad, bool connected)
{
- {
- TemporaryChange<bool> changeIsDispatching(m_isDispatching, true);
- // Don't fire controllers removed or added during event dispatch.
- size_t size = m_controllers.size();
- for (size_t i = 0; i < size; ++i) {
- if (m_controllers[i])
- static_cast<NavigatorGamepad*>(m_controllers[i])->didConnectOrDisconnectGamepad(index, gamepad, connected);
- }
- }
+ ASSERT(index < blink::WebGamepads::itemsLengthCap);
+ ASSERT(connected == gamepad.connected);
+
+ m_latestGamepad = gamepad;
+ m_latestGamepadIndex = index;
+ notifyControllers();
+}
- if (m_needsPurge)
- purgeControllers();
+const blink::WebGamepad& GamepadDispatcher::latestGamepadEventData(unsigned &index) const
+{
+ index = m_latestGamepadIndex;
+ return m_latestGamepad;
}
void GamepadDispatcher::startListening()

Powered by Google App Engine
This is Rietveld 408576698