michael@0: /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ michael@0: /* vim: set ts=2 et sw=2 tw=80: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef mozilla_dom_fmradiochild_h__ michael@0: #define mozilla_dom_fmradiochild_h__ michael@0: michael@0: #include "FMRadioCommon.h" michael@0: #include "FMRadioService.h" michael@0: #include "mozilla/dom/PFMRadioChild.h" michael@0: #include "mozilla/StaticPtr.h" michael@0: michael@0: BEGIN_FMRADIO_NAMESPACE michael@0: michael@0: /** michael@0: * FMRadioChild plays two roles: michael@0: * - Kind of proxy of FMRadioService michael@0: * Redirect all the requests coming from web content to FMRadioService michael@0: * in parent through IPC channel. michael@0: * - Child Actor of PFMRadio michael@0: * IPC channel to transfer the requests. michael@0: */ michael@0: class FMRadioChild MOZ_FINAL : public IFMRadioService michael@0: , public PFMRadioChild michael@0: { michael@0: public: michael@0: static FMRadioChild* Singleton(); michael@0: ~FMRadioChild(); michael@0: michael@0: void SendRequest(FMRadioReplyRunnable* aReplyRunnable, michael@0: FMRadioRequestArgs aArgs); michael@0: michael@0: /* IFMRadioService */ michael@0: virtual bool IsEnabled() const MOZ_OVERRIDE; michael@0: virtual double GetFrequency() const MOZ_OVERRIDE; michael@0: virtual double GetFrequencyUpperBound() const MOZ_OVERRIDE; michael@0: virtual double GetFrequencyLowerBound() const MOZ_OVERRIDE; michael@0: virtual double GetChannelWidth() const MOZ_OVERRIDE; michael@0: michael@0: virtual void Enable(double aFrequency, michael@0: FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE; michael@0: virtual void Disable(FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE; michael@0: virtual void SetFrequency(double frequency, michael@0: FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE; michael@0: virtual void Seek(mozilla::hal::FMRadioSeekDirection aDirection, michael@0: FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE; michael@0: virtual void CancelSeek(FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE; michael@0: michael@0: virtual void AddObserver(FMRadioEventObserver* aObserver) MOZ_OVERRIDE; michael@0: virtual void RemoveObserver(FMRadioEventObserver* aObserver) MOZ_OVERRIDE; michael@0: michael@0: virtual void EnableAudio(bool aAudioEnabled) MOZ_OVERRIDE; michael@0: michael@0: /* PFMRadioChild */ michael@0: virtual bool michael@0: Recv__delete__() MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvNotifyFrequencyChanged(const double& aFrequency) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: RecvNotifyEnabledChanged(const bool& aEnabled, michael@0: const double& aFrequency) MOZ_OVERRIDE; michael@0: michael@0: virtual PFMRadioRequestChild* michael@0: AllocPFMRadioRequestChild(const FMRadioRequestArgs& aArgs) MOZ_OVERRIDE; michael@0: michael@0: virtual bool michael@0: DeallocPFMRadioRequestChild(PFMRadioRequestChild* aActor) MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: FMRadioChild(); michael@0: michael@0: void Init(); michael@0: michael@0: inline void NotifyFMRadioEvent(FMRadioEventType aType); michael@0: michael@0: bool mEnabled; michael@0: double mFrequency; michael@0: double mUpperBound; michael@0: double mLowerBound; michael@0: double mChannelWidth; michael@0: michael@0: FMRadioEventObserverList mObserverList; michael@0: michael@0: private: michael@0: static StaticAutoPtr sFMRadioChild; michael@0: }; michael@0: michael@0: END_FMRADIO_NAMESPACE michael@0: michael@0: #endif // mozilla_dom_fmradiochild_h__ michael@0: