VsyncParent.h (1635B)
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_ipc_VsyncParent_h 8 #define mozilla_dom_ipc_VsyncParent_h 9 10 #include "mozilla/RefPtr.h" 11 #include "mozilla/VsyncDispatcher.h" 12 #include "mozilla/dom/PVsyncParent.h" 13 #include "nsCOMPtr.h" 14 15 class nsIThread; 16 17 namespace mozilla::dom { 18 19 // Use PBackground thread in the main process to send vsync notifications to 20 // content process. This actor will be released when its parent protocol calls 21 // DeallocPVsyncParent(). 22 class VsyncParent final : public PVsyncParent, public VsyncObserver { 23 friend class PVsyncParent; 24 25 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VsyncParent, override) 26 27 public: 28 VsyncParent(); 29 void UpdateVsyncDispatcher(const RefPtr<VsyncDispatcher>& aVsyncDispatcher); 30 31 private: 32 virtual ~VsyncParent() = default; 33 34 void NotifyVsync(const VsyncEvent& aVsync) override; 35 virtual void ActorDestroy(ActorDestroyReason aActorDestroyReason) override; 36 37 mozilla::ipc::IPCResult RecvObserve(); 38 mozilla::ipc::IPCResult RecvUnobserve(); 39 40 void DispatchVsyncEvent(const VsyncEvent& aVsync); 41 void UpdateVsyncRate(); 42 43 bool IsOnInitialThread(); 44 void AssertIsOnInitialThread(); 45 46 bool mObservingVsync; 47 bool mDestroyed; 48 nsCOMPtr<nsIThread> mInitialThread; 49 RefPtr<VsyncDispatcher> mVsyncDispatcher; 50 }; 51 52 } // namespace mozilla::dom 53 54 #endif // mozilla_dom_ipc_VsyncParent_h