Bug 1408333 Get rid of nsIIPCBackgroundChildCreateCallback - part 10 - Gamepad API, r=asuth
authorAndrea Marchesini <amarchesini@mozilla.com>
Tue, 24 Oct 2017 12:02:40 +0200
changeset 438593 dcc1d3e8fb77c30a045317f1de191e7dbe92ac68
parent 438592 084984f47abf56fd660980676fbaa0eaf00c3869
child 438594 59a00383205ecdc6b30badf98941bd4b04832225
push id8114
push userjlorenzo@mozilla.com
push dateThu, 02 Nov 2017 16:33:21 +0000
treeherdermozilla-beta@73e0d89a540f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersasuth
bugs1408333
milestone58.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1408333 Get rid of nsIIPCBackgroundChildCreateCallback - part 10 - Gamepad API, r=asuth
dom/gamepad/GamepadManager.cpp
dom/gamepad/GamepadManager.h
--- a/dom/gamepad/GamepadManager.cpp
+++ b/dom/gamepad/GamepadManager.cpp
@@ -135,22 +135,38 @@ void
 GamepadManager::AddListener(nsGlobalWindow* aWindow)
 {
   MOZ_ASSERT(aWindow);
   MOZ_ASSERT(aWindow->IsInnerWindow());
   MOZ_ASSERT(NS_IsMainThread());
 
   // IPDL child has not been created
   if (mChannelChildren.IsEmpty()) {
-    PBackgroundChild *actor = BackgroundChild::GetForCurrentThread();
-    //Try to get the PBackground Child actor
-    if (actor) {
-      ActorCreated(actor);
-    } else {
-      Unused << BackgroundChild::GetOrCreateForCurrentThread(this);
+    PBackgroundChild* actor = BackgroundChild::GetOrCreateForCurrentThread();
+    if (NS_WARN_IF(!actor)) {
+      MOZ_CRASH("Failed to create a PBackgroundChild actor!");
+    }
+
+    GamepadEventChannelChild *child = new GamepadEventChannelChild();
+    PGamepadEventChannelChild *initedChild =
+      actor->SendPGamepadEventChannelConstructor(child);
+    if (NS_WARN_IF(!initedChild)) {
+      MOZ_CRASH("Failed to create a PBackgroundChild actor!");
+      return;
+    }
+
+    MOZ_ASSERT(initedChild == child);
+    child->SendGamepadListenerAdded();
+    mChannelChildren.AppendElement(child);
+
+    if (gfx::VRManagerChild::IsCreated()) {
+      // Construct VRManagerChannel and ask adding the connected
+      // VR controllers to GamepadManager
+      gfx::VRManagerChild* vm = gfx::VRManagerChild::Get();
+      vm->SendControllerListenerAdded();
     }
   }
 
   if (!mEnabled || mShuttingDown || nsContentUtils::ShouldResistFingerprinting()) {
     return;
   }
 
   if (mListeners.IndexOf(aWindow) != NoIndex) {
@@ -688,41 +704,10 @@ GamepadManager::StopHaptics()
     } else {
       for (auto& channelChild : mChannelChildren) {
         channelChild->SendStopVibrateHaptic(gamepadIndex);
       }
     }
   }
 }
 
-//Override nsIIPCBackgroundChildCreateCallback
-void
-GamepadManager::ActorCreated(PBackgroundChild *aActor)
-{
-  MOZ_ASSERT(aActor);
-  GamepadEventChannelChild *child = new GamepadEventChannelChild();
-  PGamepadEventChannelChild *initedChild =
-    aActor->SendPGamepadEventChannelConstructor(child);
-  if (NS_WARN_IF(!initedChild)) {
-    ActorFailed();
-    return;
-  }
-  MOZ_ASSERT(initedChild == child);
-  child->SendGamepadListenerAdded();
-  mChannelChildren.AppendElement(child);
-
-  if (gfx::VRManagerChild::IsCreated()) {
-    // Construct VRManagerChannel and ask adding the connected
-    // VR controllers to GamepadManager
-    gfx::VRManagerChild* vm = gfx::VRManagerChild::Get();
-    vm->SendControllerListenerAdded();
-  }
-}
-
-//Override nsIIPCBackgroundChildCreateCallback
-void
-GamepadManager::ActorFailed()
-{
-  MOZ_CRASH("Gamepad IPC actor create failed!");
-}
-
 } // namespace dom
 } // namespace mozilla
--- a/dom/gamepad/GamepadManager.h
+++ b/dom/gamepad/GamepadManager.h
@@ -2,17 +2,16 @@
 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_dom_GamepadManager_h_
 #define mozilla_dom_GamepadManager_h_
 
-#include "nsIIPCBackgroundChildCreateCallback.h"
 #include "nsIObserver.h"
 // Needed for GamepadMappingType
 #include "mozilla/dom/GamepadBinding.h"
 #include "mozilla/dom/GamepadServiceType.h"
 
 class nsGlobalWindow;
 
 namespace mozilla {
@@ -21,23 +20,21 @@ class VRManagerChild;
 } // namespace gfx
 namespace dom {
 
 class EventTarget;
 class Gamepad;
 class GamepadChangeEvent;
 class GamepadEventChannelChild;
 
-class GamepadManager final : public nsIObserver,
-                             public nsIIPCBackgroundChildCreateCallback
+class GamepadManager final : public nsIObserver
 {
  public:
   NS_DECL_ISUPPORTS
   NS_DECL_NSIOBSERVER
-  NS_DECL_NSIIPCBACKGROUNDCHILDCREATECALLBACK
 
   // Returns true if we actually have a service up and running
   static bool IsServiceRunning();
   // Get the singleton service
   static already_AddRefed<GamepadManager> GetService();
   // Return true if the API is preffed on.
   static bool IsAPIEnabled();