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_layout_ipc_VsyncChild_h
8 #define mozilla_layout_ipc_VsyncChild_h
10 #include "mozilla/layout/PVsyncChild.h"
11 #include "nsISupportsImpl.h"
12 #include "mozilla/RefPtr.h"
19 class BackgroundChildImpl
;
24 // The PVsyncChild actor receives a vsync event from the main process and
25 // delivers it to the child process. Currently this is restricted to the main
26 // thread only. The actor will stay alive until the process dies or its
27 // PVsyncParent actor dies.
28 class VsyncChild final
: public PVsyncChild
{
29 NS_INLINE_DECL_REFCOUNTING(VsyncChild
)
31 friend class mozilla::ipc::BackgroundChildImpl
;
32 friend class PVsyncChild
;
35 // Hide the SendObserve/SendUnobserve in PVsyncChild. We add an flag
36 // mObservingVsync to handle the race problem of unobserving vsync event.
40 // Bind a VsyncObserver into VsyncChild after ipc channel connected.
41 void SetVsyncObserver(VsyncObserver
* aVsyncObserver
);
42 // GetVsyncRate is a getter for mVsyncRate which sends a requests to
43 // VsyncParent to retreive the hardware vsync rate if mVsyncRate
44 // hasn't already been set.
45 TimeDuration
GetVsyncRate();
46 // VsyncRate is a getter for mVsyncRate which always returns
47 // mVsyncRate directly, potentially returning
48 // TimeDuration::Forever() if mVsyncRate hasn't been set by calling
50 TimeDuration
VsyncRate();
54 virtual ~VsyncChild();
56 mozilla::ipc::IPCResult
RecvNotify(const VsyncEvent
& aVsync
);
57 mozilla::ipc::IPCResult
RecvVsyncRate(const float& aVsyncRate
);
58 virtual void ActorDestroy(ActorDestroyReason aActorDestroyReason
) override
;
63 // The content side vsync observer.
64 RefPtr
<VsyncObserver
> mObserver
;
65 TimeDuration mVsyncRate
;
69 } // namespace mozilla
71 #endif // mozilla_layout_ipc_VsyncChild_h