Backed out changeset b2c7231fc821 (bug 1318839) for Windows build bustage.
authorRyan VanderMeulen <ryanvm@gmail.com>
Wed, 30 Nov 2016 11:43:51 -0500
changeset 359016 aef032ba201c027510f804901477113748db6681
parent 359015 a4196f4641360bc2f8fb34fd608cb37b68fc169a
child 359017 b48e9c3fa1709a5af6b66ea9404876970350c822
push id1324
push usermtabara@mozilla.com
push dateMon, 16 Jan 2017 13:07:44 +0000
treeherdermozilla-release@a01c49833940 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1318839
milestone51.0
backs outb2c7231fc821c5008b9bc97e8d8a996fc5584be9
Backed out changeset b2c7231fc821 (bug 1318839) for Windows build bustage.
dom/gamepad/windows/WindowsGamepad.cpp
--- a/dom/gamepad/windows/WindowsGamepad.cpp
+++ b/dom/gamepad/windows/WindowsGamepad.cpp
@@ -41,20 +41,19 @@ const unsigned kFirstAxis = 0x30;
 const unsigned kDesktopUsagePage = 0x1;
 const unsigned kButtonUsagePage = 0x9;
 
 // Multiple devices-changed notifications can be sent when a device
 // is connected, because USB devices consist of multiple logical devices.
 // Therefore, we wait a bit after receiving one before looking for
 // device changes.
 const uint32_t kDevicesChangedStableDelay = 200;
-// Both DirectInput and XInput are polling-driven here,
-// so we need to poll it periodically.
-// 50ms is arbitrarily chosen.
-const uint32_t kWindowsGamepadPollInterval = 50;
+// XInput is a purely polling-driven API, so we need to
+// poll it periodically. 50ms is arbitrarily chosen.
+const uint32_t kXInputPollInterval = 50;
 
 const UINT kRawInputError = (UINT)-1;
 
 #ifndef XUSER_MAX_COUNT
 #define XUSER_MAX_COUNT 4
 #endif
 
 const struct {
@@ -410,17 +409,17 @@ WindowsGamepadService::XInputMessageLoop
                                                      void* aService)
 {
   MOZ_ASSERT(aService);
   WindowsGamepadService* self = static_cast<WindowsGamepadService*>(aService);
   self->PollXInput();
   if (self->mIsXInputMonitoring) {
     aTimer->Cancel();
     aTimer->InitWithFuncCallback(XInputMessageLoopOnceCallback, self,
-                                 kWindowsGamepadPollInterval, nsITimer::TYPE_ONE_SHOT);
+                                 kXInputPollInterval, nsITimer::TYPE_ONE_SHOT);
   }
 }
 
 // static
 void
 WindowsGamepadService::DevicesChangeCallback(nsITimer *aTimer, void* aService)
 {
   MOZ_ASSERT(aService);
@@ -497,17 +496,17 @@ WindowsGamepadService::ScanForDevices()
   if (mHID) {
     ScanForRawInputDevices();
   }
   if (mXInput) {
     mXInputTimer->Cancel();
     if (ScanForXInputDevices()) {
       mIsXInputMonitoring = true;
       mXInputTimer->InitWithFuncCallback(XInputMessageLoopOnceCallback, this,
-                                         kWindowsGamepadPollInterval,
+                                         kXInputPollInterval,
                                          nsITimer::TYPE_ONE_SHOT);
     } else {
       mIsXInputMonitoring = false;
     }
   }
 
   // Look for devices that are no longer present and remove them.
   for (int i = mGamepads.Length() - 1; i >= 0; i--) {
@@ -972,19 +971,17 @@ public:
   {
     MOZ_ASSERT(NS_GetCurrentThread() == gMonitorThread);
     MSG msg;
     while (PeekMessageW(&msg, sHWnd, 0, 0, PM_REMOVE) > 0) {
       TranslateMessage(&msg);
       DispatchMessage(&msg);
     }
     if (!sIsShutdown) {
-      nsCOMPtr<nsIRunnable> runnable = new WindowGamepadMessageLoopOnceRunnable();
-      NS_DelayedDispatchToCurrentThread(runnable.forget(),
-                                        kWindowsGamepadPollInterval);
+      NS_DispatchToCurrentThread(new WindowGamepadMessageLoopOnceRunnable());
     }
     return NS_OK;
   }
 private:
   ~WindowGamepadMessageLoopOnceRunnable() {}
 };
 
 class StartWindowsGamepadServiceRunnable final : public Runnable