Bug 1568157 - Part 5: Move the NodePicker initialization into a getter. r=yulia
[gecko.git] / layout / ipc / VsyncChild.h
blob23c915f3358fad2d8f9582bac5a6784700264e7b
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"
14 namespace mozilla {
16 class VsyncObserver;
18 namespace ipc {
19 class BackgroundChildImpl;
20 } // namespace ipc
22 namespace layout {
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;
34 public:
35 // Hide the SendObserve/SendUnobserve in PVsyncChild. We add an flag
36 // mObservingVsync to handle the race problem of unobserving vsync event.
37 bool SendObserve();
38 bool SendUnobserve();
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
49 // GetVsyncRate.
50 TimeDuration VsyncRate();
52 private:
53 VsyncChild();
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;
60 bool mObservingVsync;
61 bool mIsShutdown;
63 // The content side vsync observer.
64 RefPtr<VsyncObserver> mObserver;
65 TimeDuration mVsyncRate;
68 } // namespace layout
69 } // namespace mozilla
71 #endif // mozilla_layout_ipc_VsyncChild_h