VsyncBridgeChild.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  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
  4. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  5. #ifndef include_gfx_ipc_VsyncBridgeChild_h
  6. #define include_gfx_ipc_VsyncBridgeChild_h
  7. #include "mozilla/RefPtr.h"
  8. #include "mozilla/gfx/PVsyncBridgeChild.h"
  9. namespace mozilla {
  10. namespace gfx {
  11. class VsyncIOThreadHolder;
  12. class VsyncBridgeChild final : public PVsyncBridgeChild
  13. {
  14. friend class NotifyVsyncTask;
  15. public:
  16. NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VsyncBridgeChild)
  17. static RefPtr<VsyncBridgeChild> Create(RefPtr<VsyncIOThreadHolder> aThread,
  18. const uint64_t& aProcessToken,
  19. Endpoint<PVsyncBridgeChild>&& aEndpoint);
  20. void Close();
  21. void ActorDestroy(ActorDestroyReason aWhy) override;
  22. void DeallocPVsyncBridgeChild() override;
  23. void ProcessingError(Result aCode, const char* aReason) override;
  24. void NotifyVsync(TimeStamp aTimeStamp, const uint64_t& aLayersId);
  25. virtual void HandleFatalError(const char* aName, const char* aMsg) const override;
  26. private:
  27. VsyncBridgeChild(RefPtr<VsyncIOThreadHolder>, const uint64_t& aProcessToken);
  28. ~VsyncBridgeChild();
  29. void Open(Endpoint<PVsyncBridgeChild>&& aEndpoint);
  30. void NotifyVsyncImpl(TimeStamp aTimeStamp, const uint64_t& aLayersId);
  31. bool IsOnVsyncIOThread() const;
  32. private:
  33. RefPtr<VsyncIOThreadHolder> mThread;
  34. MessageLoop* mLoop;
  35. uint64_t mProcessToken;
  36. };
  37. } // namespace gfx
  38. } // namespace mozilla
  39. #endif // include_gfx_ipc_VsyncBridgeChild_h