dom/fmradio/ipc/FMRadioChild.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/fmradio/ipc/FMRadioChild.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,95 @@
     1.4 +/* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */
     1.5 +/* vim: set ts=2 et sw=2 tw=80: */
     1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.8 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.9 +
    1.10 +#ifndef mozilla_dom_fmradiochild_h__
    1.11 +#define mozilla_dom_fmradiochild_h__
    1.12 +
    1.13 +#include "FMRadioCommon.h"
    1.14 +#include "FMRadioService.h"
    1.15 +#include "mozilla/dom/PFMRadioChild.h"
    1.16 +#include "mozilla/StaticPtr.h"
    1.17 +
    1.18 +BEGIN_FMRADIO_NAMESPACE
    1.19 +
    1.20 +/**
    1.21 + * FMRadioChild plays two roles:
    1.22 + *   - Kind of proxy of FMRadioService
    1.23 + *     Redirect all the requests  coming from web content to FMRadioService
    1.24 + *     in parent through IPC channel.
    1.25 + *   - Child Actor of PFMRadio
    1.26 + *     IPC channel to transfer the requests.
    1.27 + */
    1.28 +class FMRadioChild MOZ_FINAL : public IFMRadioService
    1.29 +                             , public PFMRadioChild
    1.30 +{
    1.31 +public:
    1.32 +  static FMRadioChild* Singleton();
    1.33 +  ~FMRadioChild();
    1.34 +
    1.35 +  void SendRequest(FMRadioReplyRunnable* aReplyRunnable,
    1.36 +                   FMRadioRequestArgs aArgs);
    1.37 +
    1.38 +  /* IFMRadioService */
    1.39 +  virtual bool IsEnabled() const MOZ_OVERRIDE;
    1.40 +  virtual double GetFrequency() const MOZ_OVERRIDE;
    1.41 +  virtual double GetFrequencyUpperBound() const MOZ_OVERRIDE;
    1.42 +  virtual double GetFrequencyLowerBound() const MOZ_OVERRIDE;
    1.43 +  virtual double GetChannelWidth() const MOZ_OVERRIDE;
    1.44 +
    1.45 +  virtual void Enable(double aFrequency,
    1.46 +                      FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
    1.47 +  virtual void Disable(FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
    1.48 +  virtual void SetFrequency(double frequency,
    1.49 +                            FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
    1.50 +  virtual void Seek(mozilla::hal::FMRadioSeekDirection aDirection,
    1.51 +                    FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
    1.52 +  virtual void CancelSeek(FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE;
    1.53 +
    1.54 +  virtual void AddObserver(FMRadioEventObserver* aObserver) MOZ_OVERRIDE;
    1.55 +  virtual void RemoveObserver(FMRadioEventObserver* aObserver) MOZ_OVERRIDE;
    1.56 +
    1.57 +  virtual void EnableAudio(bool aAudioEnabled) MOZ_OVERRIDE;
    1.58 +
    1.59 +  /* PFMRadioChild */
    1.60 +  virtual bool
    1.61 +  Recv__delete__() MOZ_OVERRIDE;
    1.62 +
    1.63 +  virtual bool
    1.64 +  RecvNotifyFrequencyChanged(const double& aFrequency) MOZ_OVERRIDE;
    1.65 +
    1.66 +  virtual bool
    1.67 +  RecvNotifyEnabledChanged(const bool& aEnabled,
    1.68 +                           const double& aFrequency) MOZ_OVERRIDE;
    1.69 +
    1.70 +  virtual PFMRadioRequestChild*
    1.71 +  AllocPFMRadioRequestChild(const FMRadioRequestArgs& aArgs) MOZ_OVERRIDE;
    1.72 +
    1.73 +  virtual bool
    1.74 +  DeallocPFMRadioRequestChild(PFMRadioRequestChild* aActor) MOZ_OVERRIDE;
    1.75 +
    1.76 +private:
    1.77 +  FMRadioChild();
    1.78 +
    1.79 +  void Init();
    1.80 +
    1.81 +  inline void NotifyFMRadioEvent(FMRadioEventType aType);
    1.82 +
    1.83 +  bool mEnabled;
    1.84 +  double mFrequency;
    1.85 +  double mUpperBound;
    1.86 +  double mLowerBound;
    1.87 +  double mChannelWidth;
    1.88 +
    1.89 +  FMRadioEventObserverList mObserverList;
    1.90 +
    1.91 +private:
    1.92 +  static StaticAutoPtr<FMRadioChild> sFMRadioChild;
    1.93 +};
    1.94 +
    1.95 +END_FMRADIO_NAMESPACE
    1.96 +
    1.97 +#endif // mozilla_dom_fmradiochild_h__
    1.98 +

mercurial