Lay WebProcess/UIProcess groundwork for an IPC GamepadProvider.
authorbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Aug 2016 08:00:20 +0000 (08:00 +0000)
committerbeidson@apple.com <beidson@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Aug 2016 08:00:20 +0000 (08:00 +0000)
https://bugs.webkit.org/show_bug.cgi?id=160605

Reviewed by Alex Christensen.

This patch:
  - Introduces the GamepadProvider that the WebProcess will use (WebGamepadProvider)
  - Has that provider message to the UIProcess notifying interest in gamepad state
  - Introduces a GamepadProviderClient in the UIProcess (UIGamepadProvider) that will use
    one of the existing GamepadProviders to pass gamepad state along to WebProcesses.
  - Adds an empty skeleton for the soon-to-be-used WebGamepad, which will be the
    "PlatformGamepad" for WebProcesses.

* CMakeLists.txt:
* WebKit2.xcodeproj/project.pbxproj:

* UIProcess/Gamepads/UIGamepadProvider.cpp: Added.
(WebKit::UIGamepadProvider::singleton):
(WebKit::UIGamepadProvider::UIGamepadProvider):
(WebKit::UIGamepadProvider::~UIGamepadProvider):
(WebKit::UIGamepadProvider::platformGamepadConnected):
(WebKit::UIGamepadProvider::platformGamepadDisconnected):
(WebKit::UIGamepadProvider::platformGamepadInputActivity):
(WebKit::UIGamepadProvider::processPoolStartedUsingGamepads):
(WebKit::UIGamepadProvider::processPoolStoppedUsingGamepads):
(WebKit::UIGamepadProvider::platformStartMonitoringGamepads):
(WebKit::UIGamepadProvider::platformStopMonitoringGamepads):
* UIProcess/Gamepads/UIGamepadProvider.h: Added.

* UIProcess/Gamepads/mac/UIGamepadProviderHID.cpp: Added.
(WebKit::UIGamepadProvider::platformStartMonitoringGamepads):
(WebKit::UIGamepadProvider::platformStopMonitoringGamepads):

* UIProcess/WebProcessPool.cpp:
(WebKit::WebProcessPool::~WebProcessPool):
(WebKit::WebProcessPool::disconnectProcess):
(WebKit::WebProcessPool::startedUsingGamepads):
(WebKit::WebProcessPool::stoppedUsingGamepads):
(WebKit::WebProcessPool::processStoppedUsingGamepads):
* UIProcess/WebProcessPool.h:
* UIProcess/WebProcessPool.messages.in:

* WebProcess/Gamepad/WebGamepad.cpp: Added.
* WebProcess/Gamepad/WebGamepad.h: Added.

* WebProcess/Gamepad/WebGamepadProvider.cpp: Added.
(WebKit::WebGamepadProvider::singleton):
(WebKit::WebGamepadProvider::WebGamepadProvider):
(WebKit::WebGamepadProvider::~WebGamepadProvider):
(WebKit::WebGamepadProvider::startMonitoringGamepads):
(WebKit::WebGamepadProvider::stopMonitoringGamepads):
(WebKit::WebGamepadProvider::platformGamepads):
* WebProcess/Gamepad/WebGamepadProvider.h: Added.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):

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

14 files changed:
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/Gamepad/UIGamepadProvider.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/Gamepad/UIGamepadProvider.h [new file with mode: 0644]
Source/WebKit2/UIProcess/Gamepad/mac/UIGamepadProviderHID.cpp [new file with mode: 0644]
Source/WebKit2/UIProcess/WebProcessPool.cpp
Source/WebKit2/UIProcess/WebProcessPool.h
Source/WebKit2/UIProcess/WebProcessPool.messages.in
Source/WebKit2/WebKit2.xcodeproj/project.pbxproj
Source/WebKit2/WebProcess/Gamepad/WebGamepad.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/Gamepad/WebGamepad.h [new file with mode: 0644]
Source/WebKit2/WebProcess/Gamepad/WebGamepadProvider.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/Gamepad/WebGamepadProvider.h [new file with mode: 0644]
Source/WebKit2/WebProcess/WebProcess.cpp

index 2ab0cdf..a684255 100644 (file)
@@ -34,6 +34,7 @@ set(WebKit2_INCLUDE_DIRECTORIES
     "${WEBKIT2_DIR}/UIProcess/Automation"
     "${WEBKIT2_DIR}/UIProcess/Databases"
     "${WEBKIT2_DIR}/UIProcess/Downloads"
+    "${WEBKIT2_DIR}/UIProcess/Gamepad"
     "${WEBKIT2_DIR}/UIProcess/InspectorServer"
     "${WEBKIT2_DIR}/UIProcess/Launcher"
     "${WEBKIT2_DIR}/UIProcess/Network"
@@ -53,6 +54,7 @@ set(WebKit2_INCLUDE_DIRECTORIES
     "${WEBKIT2_DIR}/WebProcess/Databases/IndexedDB"
     "${WEBKIT2_DIR}/WebProcess/FileAPI"
     "${WEBKIT2_DIR}/WebProcess/FullScreen"
+    "${WEBKIT2_DIR}/WebProcess/Gamepad"
     "${WEBKIT2_DIR}/WebProcess/Geolocation"
     "${WEBKIT2_DIR}/WebProcess/IconDatabase"
     "${WEBKIT2_DIR}/WebProcess/InjectedBundle"
@@ -478,6 +480,8 @@ set(WebKit2_SOURCES
     UIProcess/Downloads/DownloadProxy.cpp
     UIProcess/Downloads/DownloadProxyMap.cpp
 
+    UIProcess/Gamepad/UIGamepadProvider.cpp
+
     UIProcess/InspectorServer/HTTPRequest.cpp
     UIProcess/InspectorServer/WebInspectorServer.cpp
     UIProcess/InspectorServer/WebSocketServer.cpp
@@ -525,6 +529,9 @@ set(WebKit2_SOURCES
 
     WebProcess/FullScreen/WebFullScreenManager.cpp
 
+    WebProcess/Gamepad/WebGamepad.cpp
+    WebProcess/Gamepad/WebGamepadProvider.cpp
+
     WebProcess/Geolocation/GeolocationPermissionRequestManager.cpp
     WebProcess/Geolocation/WebGeolocationManager.cpp
 
index 498331f..ee7a5b1 100644 (file)
@@ -1,3 +1,61 @@
+2016-08-06  Brady Eidson  <beidson@apple.com>
+
+        Lay WebProcess/UIProcess groundwork for an IPC GamepadProvider.
+        https://bugs.webkit.org/show_bug.cgi?id=160605
+
+        Reviewed by Alex Christensen.
+
+        This patch:
+          - Introduces the GamepadProvider that the WebProcess will use (WebGamepadProvider)
+          - Has that provider message to the UIProcess notifying interest in gamepad state
+          - Introduces a GamepadProviderClient in the UIProcess (UIGamepadProvider) that will use
+            one of the existing GamepadProviders to pass gamepad state along to WebProcesses.
+          - Adds an empty skeleton for the soon-to-be-used WebGamepad, which will be the 
+            "PlatformGamepad" for WebProcesses.
+
+        * CMakeLists.txt:
+        * WebKit2.xcodeproj/project.pbxproj:
+
+        * UIProcess/Gamepads/UIGamepadProvider.cpp: Added.
+        (WebKit::UIGamepadProvider::singleton):
+        (WebKit::UIGamepadProvider::UIGamepadProvider):
+        (WebKit::UIGamepadProvider::~UIGamepadProvider):
+        (WebKit::UIGamepadProvider::platformGamepadConnected):
+        (WebKit::UIGamepadProvider::platformGamepadDisconnected):
+        (WebKit::UIGamepadProvider::platformGamepadInputActivity):
+        (WebKit::UIGamepadProvider::processPoolStartedUsingGamepads):
+        (WebKit::UIGamepadProvider::processPoolStoppedUsingGamepads):
+        (WebKit::UIGamepadProvider::platformStartMonitoringGamepads):
+        (WebKit::UIGamepadProvider::platformStopMonitoringGamepads):
+        * UIProcess/Gamepads/UIGamepadProvider.h: Added.
+
+        * UIProcess/Gamepads/mac/UIGamepadProviderHID.cpp: Added.
+        (WebKit::UIGamepadProvider::platformStartMonitoringGamepads):
+        (WebKit::UIGamepadProvider::platformStopMonitoringGamepads):
+
+        * UIProcess/WebProcessPool.cpp:
+        (WebKit::WebProcessPool::~WebProcessPool):
+        (WebKit::WebProcessPool::disconnectProcess):
+        (WebKit::WebProcessPool::startedUsingGamepads):
+        (WebKit::WebProcessPool::stoppedUsingGamepads):
+        (WebKit::WebProcessPool::processStoppedUsingGamepads):
+        * UIProcess/WebProcessPool.h:
+        * UIProcess/WebProcessPool.messages.in:
+                
+        * WebProcess/Gamepad/WebGamepad.cpp: Added.
+        * WebProcess/Gamepad/WebGamepad.h: Added.
+        
+        * WebProcess/Gamepad/WebGamepadProvider.cpp: Added.
+        (WebKit::WebGamepadProvider::singleton):
+        (WebKit::WebGamepadProvider::WebGamepadProvider):
+        (WebKit::WebGamepadProvider::~WebGamepadProvider):
+        (WebKit::WebGamepadProvider::startMonitoringGamepads):
+        (WebKit::WebGamepadProvider::stopMonitoringGamepads):
+        (WebKit::WebGamepadProvider::platformGamepads):
+        * WebProcess/Gamepad/WebGamepadProvider.h: Added.
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess):
+
 2016-08-05  Commit Queue  <commit-queue@webkit.org>
 
         Unreviewed, rolling out r204195.
diff --git a/Source/WebKit2/UIProcess/Gamepad/UIGamepadProvider.cpp b/Source/WebKit2/UIProcess/Gamepad/UIGamepadProvider.cpp
new file mode 100644 (file)
index 0000000..63c113a
--- /dev/null
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "UIGamepadProvider.h"
+
+#if ENABLE(GAMEPAD)
+
+#include <WebCore/HIDGamepadProvider.h>
+#include <wtf/NeverDestroyed.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+UIGamepadProvider& UIGamepadProvider::singleton()
+{
+    static NeverDestroyed<UIGamepadProvider> sharedProvider;
+    return sharedProvider;
+}
+
+UIGamepadProvider::UIGamepadProvider()
+{
+}
+
+UIGamepadProvider::~UIGamepadProvider()
+{
+    if (!m_processPoolsUsingGamepads.isEmpty())
+        platformStopMonitoringGamepads();
+}
+
+void UIGamepadProvider::platformGamepadConnected(PlatformGamepad&)
+{
+}
+
+void UIGamepadProvider::platformGamepadDisconnected(PlatformGamepad&)
+{
+}
+
+void UIGamepadProvider::platformGamepadInputActivity()
+{
+}
+
+void UIGamepadProvider::processPoolStartedUsingGamepads(WebProcessPool& pool)
+{
+    ASSERT(!m_processPoolsUsingGamepads.contains(&pool));
+    m_processPoolsUsingGamepads.add(&pool);
+
+    if (m_processPoolsUsingGamepads.size() == 1)
+        platformStartMonitoringGamepads();
+}
+
+void UIGamepadProvider::processPoolStoppedUsingGamepads(WebProcessPool& pool)
+{
+    ASSERT(m_processPoolsUsingGamepads.contains(&pool));
+    m_processPoolsUsingGamepads.remove(&pool);
+
+    if (m_processPoolsUsingGamepads.isEmpty())
+        platformStopMonitoringGamepads();
+}
+
+#if !PLATFORM(MAC)
+void UIGamepadProvider::platformStartMonitoringGamepads()
+{
+    // FIXME: Implement for other platforms
+}
+
+void UIGamepadProvider::platformStopMonitoringGamepads()
+{
+    // FIXME: Implement for other platforms
+}
+#endif // !PLATFORM(MAC)
+
+}
+
+#endif // ENABLE(GAMEPAD)
diff --git a/Source/WebKit2/UIProcess/Gamepad/UIGamepadProvider.h b/Source/WebKit2/UIProcess/Gamepad/UIGamepadProvider.h
new file mode 100644 (file)
index 0000000..f372c02
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(GAMEPAD)
+
+#include <WebCore/GamepadProvider.h>
+#include <WebCore/GamepadProviderClient.h>
+#include <wtf/HashSet.h>
+
+namespace WebKit {
+
+class WebProcessPool;
+
+class UIGamepadProvider : public WebCore::GamepadProviderClient {
+public:
+    UIGamepadProvider();
+    ~UIGamepadProvider() final;
+
+    static UIGamepadProvider& singleton();
+
+    void platformGamepadConnected(WebCore::PlatformGamepad&) final;
+    void platformGamepadDisconnected(WebCore::PlatformGamepad&) final;
+    void platformGamepadInputActivity() final;
+
+    void processPoolStartedUsingGamepads(WebProcessPool&);
+    void processPoolStoppedUsingGamepads(WebProcessPool&);
+
+private:
+    void platformStartMonitoringGamepads();
+    void platformStopMonitoringGamepads();
+
+    HashSet<WebProcessPool*> m_processPoolsUsingGamepads;
+};
+
+}
+
+#endif // ENABLE(GAMEPAD)
diff --git a/Source/WebKit2/UIProcess/Gamepad/mac/UIGamepadProviderHID.cpp b/Source/WebKit2/UIProcess/Gamepad/mac/UIGamepadProviderHID.cpp
new file mode 100644 (file)
index 0000000..f8e47b6
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "UIGamepadProvider.h"
+
+#if ENABLE(GAMEPAD)
+
+#include <WebCore/HIDGamepadProvider.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+void UIGamepadProvider::platformStartMonitoringGamepads()
+{
+    ASSERT(!m_processPoolsUsingGamepads.isEmpty());
+    HIDGamepadProvider::singleton().startMonitoringGamepads(this);
+}
+
+void UIGamepadProvider::platformStopMonitoringGamepads()
+{
+    ASSERT(m_processPoolsUsingGamepads.isEmpty());
+    HIDGamepadProvider::singleton().stopMonitoringGamepads(this);
+}
+
+}
+
+#endif // ENABLE(GAMEPAD)
index 5d71c0d..922b6c6 100644 (file)
@@ -42,6 +42,7 @@
 #include "SandboxExtension.h"
 #include "StatisticsData.h"
 #include "TextChecker.h"
+#include "UIGamepadProvider.h"
 #include "WKContextPrivate.h"
 #include "WebAutomationSession.h"
 #include "WebCertificateInfo.h"
@@ -259,6 +260,11 @@ WebProcessPool::~WebProcessPool()
 
     if (m_networkProcess)
         m_networkProcess->shutDownProcess();
+
+#if ENABLE(GAMEPAD)
+    if (!m_processesUsingGamepads.isEmpty())
+        UIGamepadProvider::singleton().processPoolStoppedUsingGamepads(*this);
+#endif
 }
 
 void WebProcessPool::initializeClient(const WKContextClientBase* client)
@@ -752,6 +758,11 @@ void WebProcessPool::disconnectProcess(WebProcessProxy* process)
     static_cast<WebContextSupplement*>(supplement<WebGeolocationManagerProxy>())->processDidClose(process);
 
     m_processes.removeFirst(process);
+
+#if ENABLE(GAMEPAD)
+    if (m_processesUsingGamepads.contains(process))
+        processStoppedUsingGamepads(process);
+#endif
 }
 
 WebProcessProxy& WebProcessPool::createNewWebProcessRespectingProcessCountLimit()
@@ -1231,6 +1242,42 @@ void WebProcessPool::didGetStatistics(const StatisticsData& statisticsData, uint
     request->completedRequest(requestID, statisticsData);
 }
 
+#if ENABLE(GAMEPAD)
+
+void WebProcessPool::startedUsingGamepads(IPC::Connection& connection)
+{
+    auto* webProcessProxy = WebProcessProxy::fromConnection(&connection);
+    if (!webProcessProxy)
+        return;
+
+    ASSERT(!m_processesUsingGamepads.contains(webProcessProxy));
+    m_processesUsingGamepads.add(webProcessProxy);
+
+    if (m_processesUsingGamepads.size() == 1)
+        UIGamepadProvider::singleton().processPoolStartedUsingGamepads(*this);
+}
+
+void WebProcessPool::stoppedUsingGamepads(IPC::Connection& connection)
+{
+    auto* webProcessProxy = WebProcessProxy::fromConnection(&connection);
+    if (!webProcessProxy)
+        return;
+
+    ASSERT(m_processesUsingGamepads.contains(webProcessProxy));
+    processStoppedUsingGamepads(webProcessProxy);
+}
+
+void WebProcessPool::processStoppedUsingGamepads(WebProcessProxy* webProcessProxy)
+{
+    ASSERT(m_processesUsingGamepads.contains(webProcessProxy));
+    m_processesUsingGamepads.remove(webProcessProxy);
+
+    if (m_processesUsingGamepads.isEmpty())
+        UIGamepadProvider::singleton().processPoolStoppedUsingGamepads(*this);
+}
+
+#endif // ENABLE(GAMEPAD)
+
 void WebProcessPool::garbageCollectJavaScriptObjects()
 {
     sendToAllProcesses(Messages::WebProcess::GarbageCollectJavaScriptObjects());
index d57b09e..3190725 100644 (file)
@@ -387,6 +387,15 @@ private:
 
     void didGetStatistics(const StatisticsData&, uint64_t callbackID);
 
+#if ENABLE(GAMEPAD)
+    void startedUsingGamepads(IPC::Connection&);
+    void stoppedUsingGamepads(IPC::Connection&);
+
+    void processStoppedUsingGamepads(WebProcessProxy*);
+
+    HashSet<WebProcessProxy*> m_processesUsingGamepads;
+#endif
+
     // IPC::MessageReceiver.
     // Implemented in generated WebProcessPoolMessageReceiver.cpp
     void didReceiveMessage(IPC::Connection&, IPC::MessageDecoder&) override;
index 76b75cf..8eba8e5 100644 (file)
@@ -26,6 +26,11 @@ messages -> WebProcessPool {
 
     DidGetStatistics(struct WebKit::StatisticsData statisticsData, uint64_t callbackID)
 
+#if ENABLE(GAMEPAD)
+    StartedUsingGamepads() WantsConnection
+    StoppedUsingGamepads() WantsConnection
+#endif
+
     # Plug-in messages.
     void AddPlugInAutoStartOriginHash(String pageOrigin, uint32_t hash, WebCore::SessionID sessionID)
     void PlugInDidReceiveUserInteraction(uint32_t hash, WebCore::SessionID sessionID)
index 753e029..341f41e 100644 (file)
                514D9F5719119D35000063A7 /* ServicesController.h in Headers */ = {isa = PBXBuildFile; fileRef = 514D9F5519119D35000063A7 /* ServicesController.h */; };
                514D9F5819119D35000063A7 /* ServicesController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 514D9F5619119D35000063A7 /* ServicesController.mm */; };
                51578B831209ECEF00A37C4A /* APIData.h in Headers */ = {isa = PBXBuildFile; fileRef = 51578B821209ECEF00A37C4A /* APIData.h */; };
+               515BE1771D53FE8700DD7C68 /* WebGamepadProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515BE1731D53FDDC00DD7C68 /* WebGamepadProvider.cpp */; };
+               515BE1791D53FE8F00DD7C68 /* WebGamepadProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE1741D53FDDC00DD7C68 /* WebGamepadProvider.h */; };
+               515BE1A71D55293400DD7C68 /* UIGamepadProviderHID.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515BE1A61D55293000DD7C68 /* UIGamepadProviderHID.cpp */; };
+               515BE1A81D55293400DD7C68 /* UIGamepadProvider.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515BE1A41D55292800DD7C68 /* UIGamepadProvider.cpp */; };
+               515BE1A91D55293400DD7C68 /* UIGamepadProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 515BE1A51D55292800DD7C68 /* UIGamepadProvider.h */; };
                515E7727183DD6F60007203F /* AsyncRequest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515E7725183DD6F60007203F /* AsyncRequest.cpp */; };
                515E7728183DD6F60007203F /* AsyncRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 515E7726183DD6F60007203F /* AsyncRequest.h */; };
                515E772B184008B90007203F /* DatabaseProcessCreationParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 515E7729184008B90007203F /* DatabaseProcessCreationParameters.cpp */; };
                514D9F5519119D35000063A7 /* ServicesController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ServicesController.h; sourceTree = "<group>"; };
                514D9F5619119D35000063A7 /* ServicesController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ServicesController.mm; sourceTree = "<group>"; };
                51578B821209ECEF00A37C4A /* APIData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = APIData.h; sourceTree = "<group>"; };
+               515BE1731D53FDDC00DD7C68 /* WebGamepadProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGamepadProvider.cpp; sourceTree = "<group>"; };
+               515BE1741D53FDDC00DD7C68 /* WebGamepadProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGamepadProvider.h; sourceTree = "<group>"; };
+               515BE19F1D550AB000DD7C68 /* WebGamepad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebGamepad.cpp; sourceTree = "<group>"; };
+               515BE1A01D550AB000DD7C68 /* WebGamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebGamepad.h; sourceTree = "<group>"; };
+               515BE1A41D55292800DD7C68 /* UIGamepadProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIGamepadProvider.cpp; sourceTree = "<group>"; };
+               515BE1A51D55292800DD7C68 /* UIGamepadProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIGamepadProvider.h; sourceTree = "<group>"; };
+               515BE1A61D55293000DD7C68 /* UIGamepadProviderHID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = UIGamepadProviderHID.cpp; path = UIProcess/Gamepad/mac/UIGamepadProviderHID.cpp; sourceTree = SOURCE_ROOT; };
                515E7725183DD6F60007203F /* AsyncRequest.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncRequest.cpp; sourceTree = "<group>"; };
                515E7726183DD6F60007203F /* AsyncRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncRequest.h; sourceTree = "<group>"; };
                515E7729184008B90007203F /* DatabaseProcessCreationParameters.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DatabaseProcessCreationParameters.cpp; sourceTree = "<group>"; };
                        path = Authentication;
                        sourceTree = "<group>";
                };
+               515BE1721D53FDB900DD7C68 /* Gamepad */ = {
+                       isa = PBXGroup;
+                       children = (
+                               515BE19F1D550AB000DD7C68 /* WebGamepad.cpp */,
+                               515BE1A01D550AB000DD7C68 /* WebGamepad.h */,
+                               515BE1731D53FDDC00DD7C68 /* WebGamepadProvider.cpp */,
+                               515BE1741D53FDDC00DD7C68 /* WebGamepadProvider.h */,
+                       );
+                       path = Gamepad;
+                       sourceTree = "<group>";
+               };
+               515BE17B1D54EF5A00DD7C68 /* Gamepad */ = {
+                       isa = PBXGroup;
+                       children = (
+                               515BE1A11D5523B300DD7C68 /* mac */,
+                               515BE1A41D55292800DD7C68 /* UIGamepadProvider.cpp */,
+                               515BE1A51D55292800DD7C68 /* UIGamepadProvider.h */,
+                       );
+                       path = Gamepad;
+                       sourceTree = "<group>";
+               };
+               515BE1A11D5523B300DD7C68 /* mac */ = {
+                       isa = PBXGroup;
+                       children = (
+                               515BE1A61D55293000DD7C68 /* UIGamepadProviderHID.cpp */,
+                       );
+                       name = mac;
+                       path = UIProcess/Gamepad/mac;
+                       sourceTree = "<group>";
+               };
                516319931628980E00E22F00 /* mac */ = {
                        isa = PBXGroup;
                        children = (
                                BCACC43B16B24C5D00B6E092 /* EntryPoint */,
                                E170876D16D6CA7200F99226 /* FileAPI */,
                                CD73BA3D131A2A2100EEDED2 /* FullScreen */,
+                               515BE1721D53FDB900DD7C68 /* Gamepad */,
                                BC0E5FCB12D696DD0012A72A /* Geolocation */,
                                51FBB9C1132E079200F327B4 /* IconDatabase */,
                                BC204EDF11C83E72008F3375 /* InjectedBundle */,
                                9955A6E81C79809000EB6A93 /* Automation */,
                                1ABC3DF21899E415004F0626 /* Cocoa */,
                                1AB7D4C71288AA9A00CFD08C /* Downloads */,
+                               515BE17B1D54EF5A00DD7C68 /* Gamepad */,
                                2DA944A81884E9AB00ED86DB /* ios */,
                                BC111B18112F5FB400337BAB /* Launcher */,
                                BCCF085C113F3B7500C650C5 /* mac */,
                                2DA944A41884E4F000ED86DB /* GestureTypes.h in Headers */,
                                2DA049B8180CCD0A00AAFA9E /* GraphicsLayerCARemote.h in Headers */,
                                C0CE72AD1247E78D00BC0EC4 /* HandleMessage.h in Headers */,
+                               515BE1A91D55293400DD7C68 /* UIGamepadProvider.h in Headers */,
                                1AC75A1B1B3368270056745B /* HangDetectionDisabler.h in Headers */,
                                37F90DE31376560E0051CF68 /* HTTPCookieAcceptPolicy.h in Headers */,
                                51E351CB180F2CCC00E53BE9 /* IDBUtilities.h in Headers */,
                                1AB7D78D1288CD9A00CFD08C /* WKDownload.h in Headers */,
                                1AF4592F19464B2000F9D4A2 /* WKError.h in Headers */,
                                BCFD548C132D82680055D816 /* WKErrorCF.h in Headers */,
+                               515BE1791D53FE8F00DD7C68 /* WebGamepadProvider.h in Headers */,
                                37B5045219EEF31300CE2CF8 /* WKErrorPrivate.h in Headers */,
                                BC4075FC124FF0270068F20A /* WKErrorRef.h in Headers */,
                                BC40783D1250FADD0068F20A /* WKEvent.h in Headers */,
                                E179088D169BAA62006904C7 /* SecItemShim.cpp in Sources */,
                                E1790890169BAA7F006904C7 /* SecItemShimMessageReceiver.cpp in Sources */,
                                E18E690B169B563F009B6670 /* SecItemShimProxy.cpp in Sources */,
+                               515BE1A71D55293400DD7C68 /* UIGamepadProviderHID.cpp in Sources */,
                                E18E6917169B667B009B6670 /* SecItemShimProxyMessageReceiver.cpp in Sources */,
                                514D9F5819119D35000063A7 /* ServicesController.mm in Sources */,
                                1AFDE6591954A42B00C48FFA /* SessionState.cpp in Sources */,
                                1A44B95B16B73F9F00B7BBD8 /* StorageManager.cpp in Sources */,
                                1AB31A9616BC688100F6DBC9 /* StorageManagerMessageReceiver.cpp in Sources */,
                                1A44B95716B737AA00B7BBD8 /* StorageNamespaceImpl.cpp in Sources */,
+                               515BE1771D53FE8700DD7C68 /* WebGamepadProvider.cpp in Sources */,
                                1AE00D6B18327C1200087DD7 /* StringReference.cpp in Sources */,
                                296BD85E15019BC30071F424 /* StringUtilities.mm in Sources */,
                                1ZZ417EF12C00D87002BE67B /* TextCheckerCompletion.cpp in Sources */,
                                7C4ABED01AA8E9F00088AA37 /* WebCompiledContentExtension.cpp in Sources */,
                                7C4ABED41AA8FCB80088AA37 /* WebCompiledContentExtensionData.cpp in Sources */,
                                BC4A628F147312BE006C681A /* WebConnection.cpp in Sources */,
+                               515BE1A81D55293400DD7C68 /* UIGamepadProvider.cpp in Sources */,
                                BC4A6291147312BE006C681A /* WebConnectionClient.cpp in Sources */,
                                1A1FEC1C1627B45700700F6D /* WebConnectionMessageReceiver.cpp in Sources */,
                                BCD3675C148C26C000447E87 /* WebConnectionToUIProcess.cpp in Sources */,
diff --git a/Source/WebKit2/WebProcess/Gamepad/WebGamepad.cpp b/Source/WebKit2/WebProcess/Gamepad/WebGamepad.cpp
new file mode 100644 (file)
index 0000000..9d270c5
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebGamepad.h"
+
+#if ENABLE(GAMEPAD)
+
+namespace WebKit {
+
+}
+
+#endif // ENABLE(GAMEPAD)
diff --git a/Source/WebKit2/WebProcess/Gamepad/WebGamepad.h b/Source/WebKit2/WebProcess/Gamepad/WebGamepad.h
new file mode 100644 (file)
index 0000000..5499086
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(GAMEPAD)
+
+namespace WebKit {
+
+}
+
+#endif // ENABLE(GAMEPAD)
diff --git a/Source/WebKit2/WebProcess/Gamepad/WebGamepadProvider.cpp b/Source/WebKit2/WebProcess/Gamepad/WebGamepadProvider.cpp
new file mode 100644 (file)
index 0000000..525ac7b
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "WebGamepadProvider.h"
+
+#if ENABLE(GAMEPAD)
+
+#include "WebProcess.h"
+#include "WebProcessPoolMessages.h"
+#include <wtf/NeverDestroyed.h>
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebGamepadProvider& WebGamepadProvider::singleton()
+{
+    static NeverDestroyed<WebGamepadProvider> provider;
+    return provider;
+}
+
+WebGamepadProvider::WebGamepadProvider()
+{
+}
+
+WebGamepadProvider::~WebGamepadProvider()
+{
+}
+
+void WebGamepadProvider::startMonitoringGamepads(GamepadProviderClient* client)
+{
+    ASSERT(!m_clients.contains(client));
+    m_clients.add(client);
+
+    if (m_clients.size() == 1)
+        WebProcess::singleton().send(Messages::WebProcessPool::StartedUsingGamepads(), 0);
+}
+
+void WebGamepadProvider::stopMonitoringGamepads(GamepadProviderClient* client)
+{
+    ASSERT(m_clients.contains(client));
+    m_clients.remove(client);
+
+    if (m_clients.isEmpty())
+        WebProcess::singleton().send(Messages::WebProcessPool::StoppedUsingGamepads(), 0);
+}
+
+const Vector<PlatformGamepad*>& WebGamepadProvider::platformGamepads()
+{
+    static NeverDestroyed<Vector<PlatformGamepad*>> gamepads;
+    return gamepads;
+}
+
+}
+
+#endif // ENABLE(GAMEPAD)
diff --git a/Source/WebKit2/WebProcess/Gamepad/WebGamepadProvider.h b/Source/WebKit2/WebProcess/Gamepad/WebGamepadProvider.h
new file mode 100644 (file)
index 0000000..e88618c
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(GAMEPAD)
+
+#include <WebCore/GamepadProvider.h>
+#include <wtf/HashSet.h>
+
+namespace WebKit {
+
+class WebGamepadProvider : public WebCore::GamepadProvider {
+public:
+    WebGamepadProvider();
+    ~WebGamepadProvider() final;
+
+    static WebGamepadProvider& singleton();
+
+    void startMonitoringGamepads(WebCore::GamepadProviderClient*) final;
+    void stopMonitoringGamepads(WebCore::GamepadProviderClient*) final;
+    const Vector<WebCore::PlatformGamepad*>& platformGamepads() final;
+
+private:
+    HashSet<WebCore::GamepadProviderClient*> m_clients;
+};
+
+}
+
+#endif // ENABLE(GAMEPAD)
index 1475287..ba2cb9c 100644 (file)
@@ -47,6 +47,7 @@
 #include "WebCoreArgumentCoders.h"
 #include "WebFrame.h"
 #include "WebFrameNetworkingContext.h"
+#include "WebGamepadProvider.h"
 #include "WebGeolocationManager.h"
 #include "WebIconDatabaseProxy.h"
 #include "WebLoaderStrategy.h"
@@ -400,6 +401,10 @@ void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters)
         }
     }
 #endif
+
+#if ENABLE(GAMEPAD)
+    GamepadProvider::singleton().setSharedProvider(WebGamepadProvider::singleton());
+#endif
 }
 
 void WebProcess::ensureNetworkProcessConnection()