Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* -*- Mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; tab-width: 40 -*- */ |
michael@0 | 2 | /* vim: set ts=2 et sw=2 tw=80: */ |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 5 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | #ifndef mozilla_dom_fmradiochild_h__ |
michael@0 | 8 | #define mozilla_dom_fmradiochild_h__ |
michael@0 | 9 | |
michael@0 | 10 | #include "FMRadioCommon.h" |
michael@0 | 11 | #include "FMRadioService.h" |
michael@0 | 12 | #include "mozilla/dom/PFMRadioChild.h" |
michael@0 | 13 | #include "mozilla/StaticPtr.h" |
michael@0 | 14 | |
michael@0 | 15 | BEGIN_FMRADIO_NAMESPACE |
michael@0 | 16 | |
michael@0 | 17 | /** |
michael@0 | 18 | * FMRadioChild plays two roles: |
michael@0 | 19 | * - Kind of proxy of FMRadioService |
michael@0 | 20 | * Redirect all the requests coming from web content to FMRadioService |
michael@0 | 21 | * in parent through IPC channel. |
michael@0 | 22 | * - Child Actor of PFMRadio |
michael@0 | 23 | * IPC channel to transfer the requests. |
michael@0 | 24 | */ |
michael@0 | 25 | class FMRadioChild MOZ_FINAL : public IFMRadioService |
michael@0 | 26 | , public PFMRadioChild |
michael@0 | 27 | { |
michael@0 | 28 | public: |
michael@0 | 29 | static FMRadioChild* Singleton(); |
michael@0 | 30 | ~FMRadioChild(); |
michael@0 | 31 | |
michael@0 | 32 | void SendRequest(FMRadioReplyRunnable* aReplyRunnable, |
michael@0 | 33 | FMRadioRequestArgs aArgs); |
michael@0 | 34 | |
michael@0 | 35 | /* IFMRadioService */ |
michael@0 | 36 | virtual bool IsEnabled() const MOZ_OVERRIDE; |
michael@0 | 37 | virtual double GetFrequency() const MOZ_OVERRIDE; |
michael@0 | 38 | virtual double GetFrequencyUpperBound() const MOZ_OVERRIDE; |
michael@0 | 39 | virtual double GetFrequencyLowerBound() const MOZ_OVERRIDE; |
michael@0 | 40 | virtual double GetChannelWidth() const MOZ_OVERRIDE; |
michael@0 | 41 | |
michael@0 | 42 | virtual void Enable(double aFrequency, |
michael@0 | 43 | FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE; |
michael@0 | 44 | virtual void Disable(FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE; |
michael@0 | 45 | virtual void SetFrequency(double frequency, |
michael@0 | 46 | FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE; |
michael@0 | 47 | virtual void Seek(mozilla::hal::FMRadioSeekDirection aDirection, |
michael@0 | 48 | FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE; |
michael@0 | 49 | virtual void CancelSeek(FMRadioReplyRunnable* aReplyRunnable) MOZ_OVERRIDE; |
michael@0 | 50 | |
michael@0 | 51 | virtual void AddObserver(FMRadioEventObserver* aObserver) MOZ_OVERRIDE; |
michael@0 | 52 | virtual void RemoveObserver(FMRadioEventObserver* aObserver) MOZ_OVERRIDE; |
michael@0 | 53 | |
michael@0 | 54 | virtual void EnableAudio(bool aAudioEnabled) MOZ_OVERRIDE; |
michael@0 | 55 | |
michael@0 | 56 | /* PFMRadioChild */ |
michael@0 | 57 | virtual bool |
michael@0 | 58 | Recv__delete__() MOZ_OVERRIDE; |
michael@0 | 59 | |
michael@0 | 60 | virtual bool |
michael@0 | 61 | RecvNotifyFrequencyChanged(const double& aFrequency) MOZ_OVERRIDE; |
michael@0 | 62 | |
michael@0 | 63 | virtual bool |
michael@0 | 64 | RecvNotifyEnabledChanged(const bool& aEnabled, |
michael@0 | 65 | const double& aFrequency) MOZ_OVERRIDE; |
michael@0 | 66 | |
michael@0 | 67 | virtual PFMRadioRequestChild* |
michael@0 | 68 | AllocPFMRadioRequestChild(const FMRadioRequestArgs& aArgs) MOZ_OVERRIDE; |
michael@0 | 69 | |
michael@0 | 70 | virtual bool |
michael@0 | 71 | DeallocPFMRadioRequestChild(PFMRadioRequestChild* aActor) MOZ_OVERRIDE; |
michael@0 | 72 | |
michael@0 | 73 | private: |
michael@0 | 74 | FMRadioChild(); |
michael@0 | 75 | |
michael@0 | 76 | void Init(); |
michael@0 | 77 | |
michael@0 | 78 | inline void NotifyFMRadioEvent(FMRadioEventType aType); |
michael@0 | 79 | |
michael@0 | 80 | bool mEnabled; |
michael@0 | 81 | double mFrequency; |
michael@0 | 82 | double mUpperBound; |
michael@0 | 83 | double mLowerBound; |
michael@0 | 84 | double mChannelWidth; |
michael@0 | 85 | |
michael@0 | 86 | FMRadioEventObserverList mObserverList; |
michael@0 | 87 | |
michael@0 | 88 | private: |
michael@0 | 89 | static StaticAutoPtr<FMRadioChild> sFMRadioChild; |
michael@0 | 90 | }; |
michael@0 | 91 | |
michael@0 | 92 | END_FMRADIO_NAMESPACE |
michael@0 | 93 | |
michael@0 | 94 | #endif // mozilla_dom_fmradiochild_h__ |
michael@0 | 95 |