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/. */
7 #ifndef mozilla_dom_ipc_VsyncParent_h
8 #define mozilla_dom_ipc_VsyncParent_h
10 #include "mozilla/dom/PVsyncParent.h"
11 #include "mozilla/VsyncDispatcher.h"
13 #include "mozilla/RefPtr.h"
17 namespace mozilla::dom
{
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
;
25 NS_INLINE_DECL_THREADSAFE_REFCOUNTING(VsyncParent
, override
)
29 void UpdateVsyncDispatcher(const RefPtr
<VsyncDispatcher
>& aVsyncDispatcher
);
32 virtual ~VsyncParent() = default;
34 void NotifyVsync(const VsyncEvent
& aVsync
) override
;
35 virtual void ActorDestroy(ActorDestroyReason aActorDestroyReason
) override
;
37 mozilla::ipc::IPCResult
RecvObserve();
38 mozilla::ipc::IPCResult
RecvUnobserve();
40 void DispatchVsyncEvent(const VsyncEvent
& aVsync
);
41 void UpdateVsyncRate();
43 bool IsOnInitialThread();
44 void AssertIsOnInitialThread();
48 nsCOMPtr
<nsIThread
> mInitialThread
;
49 RefPtr
<VsyncDispatcher
> mVsyncDispatcher
;
52 } // namespace mozilla::dom
54 #endif // mozilla_dom_ipc_VsyncParent_h