VsyncMainChild.h (1539B)
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_VsyncMainChild_h 8 #define mozilla_dom_ipc_VsyncMainChild_h 9 10 #include "mozilla/dom/VsyncChild.h" 11 #include "nsTObserverArray.h" 12 13 namespace mozilla { 14 15 class VsyncObserver; 16 17 namespace dom { 18 19 // The PVsyncChild actor receives a vsync event from the main process and 20 // delivers it to the child process. Currently this is restricted to the main 21 // thread only. The actor will stay alive until the process dies or its 22 // PVsyncParent actor dies. 23 class VsyncMainChild final : public VsyncChild { 24 NS_INLINE_DECL_REFCOUNTING(VsyncMainChild, override) 25 26 friend class PVsyncChild; 27 28 public: 29 VsyncMainChild(); 30 31 void AddChildRefreshTimer(VsyncObserver* aVsyncObserver); 32 void RemoveChildRefreshTimer(VsyncObserver* aVsyncObserver); 33 34 TimeDuration GetVsyncRate(); 35 36 private: 37 ~VsyncMainChild() override; 38 39 mozilla::ipc::IPCResult RecvNotify(const VsyncEvent& aVsync, 40 const float& aVsyncRate) override; 41 void ActorDestroy(ActorDestroyReason aActorDestroyReason) override; 42 43 bool mIsShutdown; 44 TimeDuration mVsyncRate; 45 nsTObserverArray<VsyncObserver*> mObservers; 46 }; 47 48 } // namespace dom 49 } // namespace mozilla 50 51 #endif // mozilla_dom_ipc_VsyncChild_h