layout/ipc/VsyncChild.h
author Mike Hommey <mh+mozilla@glandium.org>
Tue, 07 Jun 2016 08:25:10 +0900
changeset 301950 a2e4369f86dcf620b453de3da6525a87ea1808fc
parent 271616 43305927701d23fa5eb5f950fb520f3c16f0bf4d
child 322595 39ac4382a2c019178604b90acd816753fe142908
permissions -rw-r--r--
Bug 1278415 - Make the buildconfig module use MozbuildObject.from_environment. r=gps The buildconfig module predates MozbuildObject.from_environment, and it's about time to start factoring things out such that we only have one way to get config.status data. This is step 1: making the buildconfig module use MozbuildObject.from_environment. Eventually, we'll want to remove the buildconfig module uses everywhere.

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

#ifndef mozilla_layout_ipc_VsyncChild_h
#define mozilla_layout_ipc_VsyncChild_h

#include "mozilla/layout/PVsyncChild.h"
#include "nsISupportsImpl.h"
#include "mozilla/RefPtr.h"

namespace mozilla {

class VsyncObserver;

namespace ipc {
class BackgroundChildImpl;
} // namespace ipc

namespace layout {

// The PVsyncChild actor receives a vsync event from the main process and
// delivers it to the child process. Currently this is restricted to the main
// thread only. The actor will stay alive until the process dies or its
// PVsyncParent actor dies.
class VsyncChild final : public PVsyncChild
{
  NS_INLINE_DECL_REFCOUNTING(VsyncChild)

  friend class mozilla::ipc::BackgroundChildImpl;

public:
  // Hide the SendObserve/SendUnobserve in PVsyncChild. We add an flag
  // mObservingVsync to handle the race problem of unobserving vsync event.
  bool SendObserve();
  bool SendUnobserve();

  // Bind a VsyncObserver into VsyncChild after ipc channel connected.
  void SetVsyncObserver(VsyncObserver* aVsyncObserver);
  TimeDuration GetVsyncRate();

private:
  VsyncChild();
  virtual ~VsyncChild();

  virtual bool RecvNotify(const TimeStamp& aVsyncTimestamp) override;
  virtual bool RecvVsyncRate(const float& aVsyncRate) override;
  virtual void ActorDestroy(ActorDestroyReason aActorDestroyReason) override;

  bool mObservingVsync;
  bool mIsShutdown;

  // The content side vsync observer.
  RefPtr<VsyncObserver> mObserver;
  TimeDuration mVsyncRate;
};

} // namespace layout
} // namespace mozilla

#endif  // mozilla_layout_ipc_VsyncChild_h