tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

VsyncWorkerChild.h (1518B)


      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_VsyncWorkerChild_h
      8 #define mozilla_dom_ipc_VsyncWorkerChild_h
      9 
     10 #include "mozilla/RefPtr.h"
     11 #include "mozilla/dom/VsyncChild.h"
     12 #include "nsISupportsImpl.h"
     13 
     14 namespace mozilla::dom {
     15 class DedicatedWorkerGlobalScope;
     16 class IPCWorkerRef;
     17 class WorkerPrivate;
     18 
     19 // The PVsyncWorkerChild actor receives a vsync event from the main process and
     20 // delivers it to the child process. This is specific for workers which wish to
     21 // subscribe to vsync events to drive requestAnimationFrame callbacks.
     22 class VsyncWorkerChild final : public VsyncChild {
     23  NS_INLINE_DECL_REFCOUNTING(VsyncWorkerChild, override)
     24 
     25  friend class PVsyncChild;
     26 
     27 public:
     28  VsyncWorkerChild();
     29 
     30  bool Initialize(WorkerPrivate* aWorkerPrivate);
     31 
     32  void Destroy();
     33 
     34  void TryObserve();
     35 
     36  void TryUnobserve();
     37 
     38 private:
     39  ~VsyncWorkerChild() override;
     40 
     41  mozilla::ipc::IPCResult RecvNotify(const VsyncEvent& aVsync,
     42                                     const float& aVsyncRate) override;
     43 
     44  void ActorDestroy(ActorDestroyReason aActorDestroyReason) override;
     45 
     46  RefPtr<IPCWorkerRef> mWorkerRef;
     47  bool mObserving = false;
     48 };
     49 
     50 }  // namespace mozilla::dom
     51 
     52 #endif  // mozilla_dom_ipc_VsyncWorkerChild_h