Unreviewed, rolling out r204506.
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Aug 2016 16:57:17 +0000 (16:57 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 16 Aug 2016 16:57:17 +0000 (16:57 +0000)
Broke the build

Reverted changeset:

"Cleanup WK2 platform gamepad handling."
https://bugs.webkit.org/show_bug.cgi?id=160871
http://trac.webkit.org/changeset/204506

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@204509 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
Source/WebCore/ChangeLog
Source/WebCore/platform/gamepad/GamepadProviderClient.h
Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.cpp
Source/WebCore/platform/gamepad/mac/HIDGamepadProvider.h
Source/WebKit2/ChangeLog
Source/WebKit2/Platform/Logging.h
Source/WebKit2/UIProcess/Gamepad/UIGamepadProvider.cpp
Source/WebKit2/UIProcess/Gamepad/UIGamepadProvider.h
Source/WebKit2/UIProcess/Gamepad/mac/UIGamepadProviderHID.cpp
Source/WebKit2/UIProcess/WebProcessPool.cpp
Source/WebKit2/UIProcess/WebProcessPool.h
Source/WebKit2/WebProcess/Gamepad/WebGamepadProvider.cpp
Source/WebKit2/WebProcess/Gamepad/WebGamepadProvider.h
Source/WebKit2/WebProcess/WebProcess.cpp
Source/WebKit2/WebProcess/WebProcess.h
Source/WebKit2/WebProcess/WebProcess.messages.in

index ab7b4a6..ea713ab 100644 (file)
@@ -1,3 +1,15 @@
+2016-08-16  Chris Dumez  <cdumez@apple.com>
+
+        Unreviewed, rolling out r204506.
+
+        Broke the build
+
+        Reverted changeset:
+
+        "Cleanup WK2 platform gamepad handling."
+        https://bugs.webkit.org/show_bug.cgi?id=160871
+        http://trac.webkit.org/changeset/204506
+
 2016-08-16  Darin Adler  <darin@apple.com>
 
         [Cocoa] Remove dependency on Objective-C bindings in WebKit2 editing code
index 01a2cec..1ea102a 100644 (file)
@@ -27,8 +27,6 @@
 
 #if ENABLE(GAMEPAD)
 
-#include <wtf/Vector.h>
-
 namespace WebCore {
 
 class PlatformGamepad;
@@ -37,7 +35,6 @@ class GamepadProviderClient {
 public:
     virtual ~GamepadProviderClient() { }
 
-    virtual void setInitialConnectedGamepads(const Vector<PlatformGamepad*>&) { }
     virtual void platformGamepadConnected(PlatformGamepad&) = 0;
     virtual void platformGamepadDisconnected(PlatformGamepad&) = 0;
     virtual void platformGamepadInputActivity() = 0;
index 6d10d1e..c5a435f 100644 (file)
@@ -96,17 +96,6 @@ HIDGamepadProvider::HIDGamepadProvider()
     IOHIDManagerSetDeviceMatchingMultiple(m_manager.get(), matchingArray.get());
     IOHIDManagerRegisterDeviceMatchingCallback(m_manager.get(), deviceAddedCallback, this);
     IOHIDManagerRegisterDeviceRemovalCallback(m_manager.get(), deviceRemovedCallback, this);
-
-    startMonitoringInput();
-}
-
-void HIDGamepadProvider::stopMonitoringInput()
-{
-    IOHIDManagerRegisterInputValueCallback(m_manager.get(), nullptr, nullptr);
-}
-
-void HIDGamepadProvider::startMonitoringInput()
-{
     IOHIDManagerRegisterInputValueCallback(m_manager.get(), deviceValuesChangedCallback, this);
 }
 
@@ -122,9 +111,6 @@ unsigned HIDGamepadProvider::indexForNewlyConnectedDevice()
 void HIDGamepadProvider::connectionDelayTimerFired()
 {
     m_shouldDispatchCallbacks = true;
-
-    for (auto* client : m_clients)
-        client->setInitialConnectedGamepads(m_gamepadVector);
 }
 
 void HIDGamepadProvider::openAndScheduleManager()
index 167aef5..f66154f 100644 (file)
@@ -51,9 +51,6 @@ public:
     WEBCORE_EXPORT void stopMonitoringGamepads(GamepadProviderClient&) final;
     const Vector<PlatformGamepad*>& platformGamepads() final { return m_gamepadVector; }
 
-    WEBCORE_EXPORT void stopMonitoringInput();
-    WEBCORE_EXPORT void startMonitoringInput();
-    
     void deviceAdded(IOHIDDeviceRef);
     void deviceRemoved(IOHIDDeviceRef);
     void valuesChanged(IOHIDValueRef);
index 194b876..baf9ef7 100644 (file)
@@ -1,3 +1,15 @@
+2016-08-16  Chris Dumez  <cdumez@apple.com>
+
+        Unreviewed, rolling out r204506.
+
+        Broke the build
+
+        Reverted changeset:
+
+        "Cleanup WK2 platform gamepad handling."
+        https://bugs.webkit.org/show_bug.cgi?id=160871
+        http://trac.webkit.org/changeset/204506
+
 2016-08-16  Darin Adler  <darin@apple.com>
 
         [Cocoa] Remove dependency on Objective-C bindings in WebKit2 editing code
index 338245d..5d8ead0 100644 (file)
@@ -43,7 +43,6 @@ extern "C" {
 
 #define WEBKIT2_LOG_CHANNELS(M) \
     M(ContextMenu) \
-    M(Gamepad) \
     M(IDB) \
     M(IconDatabase) \
     M(IndexedDB) \
index 2046bf9..750eaef 100644 (file)
@@ -48,6 +48,7 @@ UIGamepadProvider& UIGamepadProvider::singleton()
 
 UIGamepadProvider::UIGamepadProvider()
     : m_gamepadSyncTimer(RunLoop::main(), this, &UIGamepadProvider::gamepadSyncTimerFired)
+    , m_disableMonitoringTimer(RunLoop::main(), this, &UIGamepadProvider::disableMonitoringTimerFired)
 {
 }
 
@@ -63,7 +64,17 @@ void UIGamepadProvider::gamepadSyncTimerFired()
     if (!webPageProxy || !m_processPoolsUsingGamepads.contains(&webPageProxy->process().processPool()))
         return;
 
-    webPageProxy->gamepadActivity(snapshotGamepads());
+    Vector<GamepadData> gamepadDatas;
+    gamepadDatas.reserveInitialCapacity(m_gamepads.size());
+
+    for (auto& gamepad : m_gamepads) {
+        if (gamepad)
+            gamepadDatas.uncheckedAppend(gamepad->gamepadData());
+        else
+            gamepadDatas.uncheckedAppend({ });
+    }
+
+    webPageProxy->gamepadActivity(gamepadDatas);
 }
 
 void UIGamepadProvider::scheduleGamepadStateSync()
@@ -79,24 +90,6 @@ void UIGamepadProvider::scheduleGamepadStateSync()
     m_gamepadSyncTimer.startOneShot(maximumGamepadUpdateInterval);
 }
 
-void UIGamepadProvider::setInitialConnectedGamepads(const Vector<PlatformGamepad*>& initialGamepads)
-{
-    ASSERT(!m_hasInitialGamepads);
-
-    m_gamepads.resize(initialGamepads.size());
-
-    for (auto* gamepad : initialGamepads) {
-        if (!gamepad)
-            continue;
-        m_gamepads[gamepad->index()] = std::make_unique<UIGamepad>(*gamepad);
-    }
-
-    for (auto& pool : m_processPoolsUsingGamepads)
-        pool->setInitialConnectedGamepads(m_gamepads);
-
-    m_hasInitialGamepads = true;
-}
-
 void UIGamepadProvider::platformGamepadConnected(PlatformGamepad& gamepad)
 {
     if (m_gamepads.size() <= gamepad.index())
@@ -159,7 +152,7 @@ void UIGamepadProvider::processPoolStoppedUsingGamepads(WebProcessPool& pool)
     m_processPoolsUsingGamepads.remove(&pool);
 
     if (m_isMonitoringGamepads && !platformWebPageProxyForGamepadInput())
-        platformStopMonitoringInput();
+        scheduleDisableGamepadMonitoring();
 
     scheduleGamepadStateSync();
 }
@@ -169,18 +162,26 @@ void UIGamepadProvider::viewBecameActive(WebPageProxy& page)
     if (!m_processPoolsUsingGamepads.contains(&page.process().processPool()))
         return;
 
-    if (!m_isMonitoringGamepads)
-        startMonitoringGamepads();
-
-    if (platformWebPageProxyForGamepadInput())
-        platformStartMonitoringInput();
+    m_disableMonitoringTimer.stop();
+    startMonitoringGamepads();
 }
 
 void UIGamepadProvider::viewBecameInactive(WebPageProxy& page)
 {
     auto pageForGamepadInput = platformWebPageProxyForGamepadInput();
     if (pageForGamepadInput == &page)
-        platformStopMonitoringInput();
+        scheduleDisableGamepadMonitoring();
+}
+
+void UIGamepadProvider::scheduleDisableGamepadMonitoring()
+{
+    if (!m_disableMonitoringTimer.isActive())
+        m_disableMonitoringTimer.startOneShot(0);
+}
+
+void UIGamepadProvider::disableMonitoringTimerFired()
+{
+    stopMonitoringGamepads();
 }
 
 void UIGamepadProvider::startMonitoringGamepads()
@@ -199,22 +200,6 @@ void UIGamepadProvider::stopMonitoringGamepads()
 
     m_isMonitoringGamepads = false;
     platformStopMonitoringGamepads();
-    m_gamepads.clear();
-}
-
-Vector<GamepadData> UIGamepadProvider::snapshotGamepads()
-{
-    Vector<GamepadData> gamepadDatas;
-    gamepadDatas.reserveInitialCapacity(m_gamepads.size());
-
-    for (auto& gamepad : m_gamepads) {
-        if (gamepad)
-            gamepadDatas.uncheckedAppend(gamepad->gamepadData());
-        else
-            gamepadDatas.uncheckedAppend({ });
-    }
-
-    return gamepadDatas;
 }
 
 #if !PLATFORM(MAC)
@@ -242,14 +227,6 @@ WebProcessProxy* UIGamepadProvider::platformWebProcessProxyForGamepadInput()
     // FIXME: Implement for other platforms
 }
 
-void UIGamepadProvider::platformStopMonitoringInput()
-{
-}
-
-void UIGamepadProvider::platformStartMonitoringInput()
-{
-}
-
 #endif // !PLATFORM(MAC)
 
 }
index 42ca421..70dc842 100644 (file)
@@ -64,10 +64,7 @@ private:
     void platformStopMonitoringGamepads();
     const Vector<WebCore::PlatformGamepad*>& platformGamepads();
     WebPageProxy* platformWebPageProxyForGamepadInput();
-    void platformStopMonitoringInput();
-    void platformStartMonitoringInput();
 
-    void setInitialConnectedGamepads(const Vector<WebCore::PlatformGamepad*>&) final;
     void platformGamepadConnected(WebCore::PlatformGamepad&) final;
     void platformGamepadDisconnected(WebCore::PlatformGamepad&) final;
     void platformGamepadInputActivity() final;
@@ -75,16 +72,17 @@ private:
     void scheduleGamepadStateSync();
     void gamepadSyncTimerFired();
 
-    Vector<GamepadData> snapshotGamepads();
+    void scheduleDisableGamepadMonitoring();
+    void disableMonitoringTimerFired();
 
     HashSet<WebProcessPool*> m_processPoolsUsingGamepads;
 
     Vector<std::unique_ptr<UIGamepad>> m_gamepads;
 
     RunLoop::Timer<UIGamepadProvider> m_gamepadSyncTimer;
+    RunLoop::Timer<UIGamepadProvider> m_disableMonitoringTimer;
 
     bool m_isMonitoringGamepads { false };
-    bool m_hasInitialGamepads { false };
 };
 
 }
index 1ba7a41..79ea33c 100644 (file)
@@ -51,16 +51,6 @@ const Vector<PlatformGamepad*>& UIGamepadProvider::platformGamepads()
     return HIDGamepadProvider::singleton().platformGamepads();
 }
 
-void UIGamepadProvider::platformStopMonitoringInput()
-{
-    return HIDGamepadProvider::singleton().stopMonitoringInput();
-}
-
-void UIGamepadProvider::platformStartMonitoringInput()
-{
-    return HIDGamepadProvider::singleton().startMonitoringInput();
-}
-
 }
 
 #endif // ENABLE(GAMEPAD)
index aeaaf4b..d751e12 100644 (file)
@@ -1286,20 +1286,6 @@ void WebProcessPool::gamepadDisconnected(const UIGamepad& gamepad)
         process->send(Messages::WebProcess::GamepadDisconnected(gamepad.index()), 0);
 }
 
-void WebProcessPool::setInitialConnectedGamepads(const Vector<std::unique_ptr<UIGamepad>>& gamepads)
-{
-    Vector<GamepadData> gamepadDatas;
-    gamepadDatas.resize(gamepads.size());
-    for (size_t i = 0; i < gamepads.size(); ++i) {
-        if (!gamepads[i])
-            continue;
-        gamepadDatas[i] = gamepads[i]->gamepadData();
-    }
-
-    for (auto& process : m_processesUsingGamepads)
-        process->send(Messages::WebProcess::SetInitialGamepads(gamepadDatas), 0);
-}
-
 #endif // ENABLE(GAMEPAD)
 
 void WebProcessPool::garbageCollectJavaScriptObjects()
index 0584bc0..6b09b00 100644 (file)
@@ -370,8 +370,6 @@ public:
 #if ENABLE(GAMEPAD)
     void gamepadConnected(const UIGamepad&);
     void gamepadDisconnected(const UIGamepad&);
-
-    void setInitialConnectedGamepads(const Vector<std::unique_ptr<UIGamepad>>&);
 #endif
 
 private:
index d37164b..416039e 100644 (file)
@@ -53,21 +53,6 @@ WebGamepadProvider::~WebGamepadProvider()
 {
 }
 
-void WebGamepadProvider::setInitialGamepads(const Vector<GamepadData>& gamepadDatas)
-{
-    ASSERT(m_gamepads.isEmpty());
-
-    m_gamepads.resize(gamepadDatas.size());
-    m_rawGamepads.resize(gamepadDatas.size());
-    for (size_t i = 0; i < gamepadDatas.size(); ++i) {
-        if (gamepadDatas[i].isNull())
-            continue;
-
-        m_gamepads[i] = std::make_unique<WebGamepad>(gamepadDatas[i]);
-        m_rawGamepads[i] = m_gamepads[i].get();
-    }
-}
-
 void WebGamepadProvider::gamepadConnected(const GamepadData& gamepadData)
 {
     if (m_gamepads.size() <= gamepadData.index) {
index cea84e2..a53483d 100644 (file)
@@ -46,8 +46,6 @@ public:
     void gamepadDisconnected(unsigned index);
     void gamepadActivity(const Vector<GamepadData>&);
 
-    void setInitialGamepads(const Vector<GamepadData>&);
-
 private:
     friend NeverDestroyed<WebGamepadProvider>;
     WebGamepadProvider();
index 208b6e6..14ad79d 100644 (file)
@@ -1030,11 +1030,6 @@ void WebProcess::mainThreadPing()
 
 #if ENABLE(GAMEPAD)
 
-void WebProcess::setInitialGamepads(const Vector<WebKit::GamepadData>& gamepadDatas)
-{
-    WebGamepadProvider::singleton().setInitialGamepads(gamepadDatas);
-}
-
 void WebProcess::gamepadConnected(const GamepadData& gamepadData)
 {
     WebGamepadProvider::singleton().gamepadConnected(gamepadData);
index bb88782..c8ae1d5 100644 (file)
@@ -276,7 +276,6 @@ private:
     void mainThreadPing();
 
 #if ENABLE(GAMEPAD)
-    void setInitialGamepads(const Vector<GamepadData>&);
     void gamepadConnected(const GamepadData&);
     void gamepadDisconnected(unsigned index);
 #endif
index 1245864..56810a9 100644 (file)
@@ -103,7 +103,6 @@ messages -> WebProcess LegacyReceiver {
     MainThreadPing()
 
 #if ENABLE(GAMEPAD)
-    SetInitialGamepads(Vector<WebKit::GamepadData> gamepadDatas)
     GamepadConnected(struct WebKit::GamepadData gamepadData)
     GamepadDisconnected(unsigned index)
 #endif