Backed out 4 changesets (bug 1879154) for causing bustage on nsUserCharacteristics...
[gecko.git] / dom / ipc / VsyncParent.h
blob3fe8a8e5f2336c2c1a7fc935da5e61db14599676
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"
12 #include "nsCOMPtr.h"
13 #include "mozilla/RefPtr.h"
15 class nsIThread;
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)
27 public:
28 VsyncParent();
29 void UpdateVsyncDispatcher(const RefPtr<VsyncDispatcher>& aVsyncDispatcher);
31 private:
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();
46 bool mObservingVsync;
47 bool mDestroyed;
48 nsCOMPtr<nsIThread> mInitialThread;
49 RefPtr<VsyncDispatcher> mVsyncDispatcher;
52 } // namespace mozilla::dom
54 #endif // mozilla_dom_ipc_VsyncParent_h