GamepadMonitoring.cpp 859 B

1234567891011121314151617181920212223242526272829303132
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* This Source Code Form is subject to the terms of the Mozilla Public
  3. * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  4. * You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #include "mozilla/dom/GamepadMonitoring.h"
  6. #include "mozilla/dom/GamepadPlatformService.h"
  7. #include "mozilla/ipc/BackgroundParent.h"
  8. using namespace mozilla::ipc;
  9. namespace mozilla {
  10. namespace dom {
  11. void
  12. MaybeStopGamepadMonitoring()
  13. {
  14. AssertIsOnBackgroundThread();
  15. RefPtr<GamepadPlatformService> service =
  16. GamepadPlatformService::GetParentService();
  17. MOZ_ASSERT(service);
  18. if(service->HasGamepadListeners()) {
  19. return;
  20. }
  21. StopGamepadMonitoring();
  22. service->ResetGamepadIndexes();
  23. service->MaybeShutdown();
  24. }
  25. } // namespace dom
  26. } // namespace mozilla