dom/gamepad/ipc/GamepadEventChannelParent.h
author Daosheng Mu <daoshengmu@gmail.com>
Tue, 07 Mar 2017 10:17:57 +0800
changeset 349320 5d8e162ef5f73106037a6ad5c34770f26ab86447
parent 349319 3c1984bdf4047df79fde8e84264f17de80351f20
child 363625 351a4d47496ecc6d03585474d89f48b602b007e7
permissions -rw-r--r--
Bug 1299937 - Part 6: Handle Stop vibrating when the window defoucses; r=qdot MozReview-Commit-ID: Kvd40jnSPvK

/* 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/. */
#include "mozilla/dom/PGamepadEventChannelParent.h"

#ifndef mozilla_dom_GamepadEventChannelParent_h_
#define mozilla_dom_GamepadEventChannelParent_h_

namespace mozilla{
namespace dom{

class GamepadEventChannelParent final : public PGamepadEventChannelParent
{
 public:
  NS_INLINE_DECL_THREADSAFE_REFCOUNTING(GamepadEventChannelParent)
  GamepadEventChannelParent();
  virtual void ActorDestroy(ActorDestroyReason aWhy) override;
  virtual mozilla::ipc::IPCResult RecvGamepadListenerAdded() override;
  virtual mozilla::ipc::IPCResult RecvGamepadListenerRemoved() override;
  virtual mozilla::ipc::IPCResult RecvVibrateHaptic(const uint32_t& aControllerIdx,
                                                    const uint32_t& aHapticIndex,
                                                    const double& aIntensity,
                                                    const double& aDuration,
                                                    const uint32_t& aPromiseID) override;
  virtual mozilla::ipc::IPCResult RecvStopVibrateHaptic(
                                    const uint32_t& aGamepadIndex) override;
  void DispatchUpdateEvent(const GamepadChangeEvent& aEvent);
  bool HasGamepadListener() const { return mHasGamepadListener; }
 private:
  ~GamepadEventChannelParent() {}
  bool mHasGamepadListener;
  nsCOMPtr<nsIThread> mBackgroundThread;
};

}// namespace dom
}// namespace mozilla

#endif